am 25eeacbb: MediaPlayerTest local video fixes.
* commit '25eeacbbe9ed622f8da22345e4d324324db6f674':
MediaPlayerTest local video fixes.
diff --git a/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java b/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java
index f162edc..106f1af 100644
--- a/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java
+++ b/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java
@@ -323,7 +323,7 @@
private boolean mAllTestsPassed = true;
private String mTestRunErrorMessage = null;
- public void testEnded(TestIdentifier test, Map<String, String> metrics) {
+ public void testEnded(TestIdentifier test, Map<String, String> metrics) {
// ignore
}
diff --git a/tests/res/drawable/webp_test.webp b/tests/res/drawable/webp_test.webp
new file mode 100644
index 0000000..7b1009f
--- /dev/null
+++ b/tests/res/drawable/webp_test.webp
Binary files differ
diff --git a/tests/tests/database/src/android/database/cts/DatabaseUtilsTest.java b/tests/tests/database/src/android/database/cts/DatabaseUtilsTest.java
index c67002c..c47b65b 100644
--- a/tests/tests/database/src/android/database/cts/DatabaseUtilsTest.java
+++ b/tests/tests/database/src/android/database/cts/DatabaseUtilsTest.java
@@ -50,6 +50,7 @@
"age", // 2
"address" // 3
};
+ private static final String TABLE_NAME = "test";
@Override
protected void setUp() throws Exception {
@@ -61,7 +62,7 @@
}
mDatabase = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null);
assertNotNull(mDatabase);
- mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, " +
+ mDatabase.execSQL("CREATE TABLE " + TABLE_NAME + " (_id INTEGER PRIMARY KEY, " +
"name TEXT, age INTEGER, address TEXT);");
}
@@ -132,11 +133,12 @@
String address = "LA";
// at the beginning, there are no records in the database.
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION,
+ null, null, null, null, null);
assertNotNull(cursor);
assertEquals(0, cursor.getCount());
- String sql = "INSERT INTO test (name, age, address) VALUES (?, ?, ?);";
+ String sql = "INSERT INTO " + TABLE_NAME + " (name, age, address) VALUES (?, ?, ?);";
SQLiteStatement statement = mDatabase.compileStatement(sql);
DatabaseUtils.bindObjectToProgram(statement, 1, name);
DatabaseUtils.bindObjectToProgram(statement, 2, age);
@@ -144,7 +146,7 @@
statement.execute();
statement.close();
- cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION, null, null, null, null, null);
assertNotNull(cursor);
assertEquals(1, cursor.getCount());
cursor.moveToFirst();
@@ -161,8 +163,8 @@
)
public void testCreateDbFromSqlStatements() {
String dbName = "ExampleName";
- String sqls = "CREATE TABLE test (_id INTEGER PRIMARY KEY, name TEXT);\n"
- + "INSERT INTO test (name) VALUES ('Mike');\n";
+ String sqls = "CREATE TABLE " + TABLE_NAME + " (_id INTEGER PRIMARY KEY, name TEXT);\n"
+ + "INSERT INTO " + TABLE_NAME + " (name) VALUES ('Mike');\n";
DatabaseUtils.createDbFromSqlStatements(getContext(), dbName, 1, sqls);
SQLiteDatabase db = getContext().openOrCreateDatabase(dbName, 0, null);
@@ -170,7 +172,7 @@
"_id", // 0
"name" // 1
};
- Cursor cursor = db.query("test", PROJECTION, null, null, null, null, null);
+ Cursor cursor = db.query(TABLE_NAME, PROJECTION, null, null, null, null, null);
assertNotNull(cursor);
assertEquals(1, cursor.getCount());
cursor.moveToFirst();
@@ -185,8 +187,10 @@
android.content.ContentValues.class, java.lang.String.class}
)
public void testCursorDoubleToContentValues() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION,
+ null, null, null, null, null);
assertNotNull(cursor);
ContentValues contentValues = new ContentValues();
@@ -210,8 +214,10 @@
)
@ToBeFixed(bug = "1586458", explanation = "It's probably a typo.")
public void testCursorDoubleToCursorValues() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION,
+ null, null, null, null, null);
assertNotNull(cursor);
ContentValues contentValues = new ContentValues();
@@ -241,8 +247,9 @@
)
})
public void testCursorIntToContentValues() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION, null, null, null, null, null);
assertNotNull(cursor);
ContentValues contentValues = new ContentValues();
@@ -283,8 +290,9 @@
)
})
public void testcursorLongToContentValues() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION, null, null, null, null, null);
assertNotNull(cursor);
ContentValues contentValues = new ContentValues();
@@ -316,8 +324,10 @@
args = {android.database.Cursor.class, android.content.ContentValues.class}
)
public void testCursorRowToContentValues() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION,
+ null, null, null, null, null);
assertNotNull(cursor);
ContentValues contentValues = new ContentValues();
@@ -343,8 +353,10 @@
)
})
public void testCursorStringToContentValues() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION,
+ null, null, null, null, null);
assertNotNull(cursor);
ContentValues contentValues = new ContentValues();
@@ -390,7 +402,8 @@
mDatabase.execSQL("CREATE TABLE test_copy (_id INTEGER PRIMARY KEY, " +
"name TEXT, age INTEGER, address TEXT);");
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
Cursor cursor = mDatabase.query("test_copy", TEST_PROJECTION, null, null, null, null, null);
assertEquals(0, cursor.getCount());
@@ -399,7 +412,7 @@
int indexAge = insertHelper.getColumnIndex("age");
int indexAddress = insertHelper.getColumnIndex("address");
- cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION, null, null, null, null, null);
cursor.moveToNext();
insertHelper.prepareForInsert();
DatabaseUtils.cursorStringToInsertHelper(cursor, "name", insertHelper, indexName);
@@ -438,8 +451,10 @@
)
})
public void testDumpCurrentRow() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION,
+ null, null, null, null, null);
assertNotNull(cursor);
cursor.moveToNext();
String expected = "0 {\n _id=1\n name=Mike\n age=20\n address=LA\n}\n";
@@ -483,9 +498,12 @@
)
})
public void testDumpCursor() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Jack', '30', 'London');");
- Cursor cursor = mDatabase.query("test", TEST_PROJECTION, null, null, null, null, null);
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Jack', '30', 'London');");
+ Cursor cursor = mDatabase.query(TABLE_NAME, TEST_PROJECTION,
+ null, null, null, null, null);
assertNotNull(cursor);
int pos = cursor.getPosition();
String expected = ">>>>> Dumping cursor " + cursor + "\n" +
@@ -564,13 +582,15 @@
)
})
public void testLongForQuery() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
- String query = "SELECT age FROM test";
+ String query = "SELECT age FROM " + TABLE_NAME;
assertEquals(20, DatabaseUtils.longForQuery(mDatabase, query, null));
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Jack', '35', 'London');");
- query = "SELECT age FROM test WHERE name = ?";
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Jack', '35', 'London');");
+ query = "SELECT age FROM " + TABLE_NAME + " WHERE name = ?";
String[] args = new String[] { "Jack" };
assertEquals(35, DatabaseUtils.longForQuery(mDatabase, query, args));
args = new String[] { "No such name" };
@@ -581,11 +601,11 @@
// expected
}
- query = "SELECT count(*) FROM test;";
+ query = "SELECT count(*) FROM " + TABLE_NAME + ";";
SQLiteStatement statement = mDatabase.compileStatement(query);
assertEquals(2, DatabaseUtils.longForQuery(statement, null));
- query = "SELECT age FROM test WHERE address = ?;";
+ query = "SELECT age FROM " + TABLE_NAME + " WHERE address = ?;";
statement = mDatabase.compileStatement(query);
args = new String[] { "London" };
assertEquals(35, DatabaseUtils.longForQuery(statement, args));
@@ -600,19 +620,47 @@
statement.close();
}
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- method = "queryNumEntries",
- args = {android.database.sqlite.SQLiteDatabase.class, java.lang.String.class}
- )
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "queryNumEntries",
+ args = {android.database.sqlite.SQLiteDatabase.class, java.lang.String.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "queryNumEntries",
+ args = {android.database.sqlite.SQLiteDatabase.class, java.lang.String.class,
+ java.lang.String.class}
+ ),
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "queryNumEntries",
+ args = {android.database.sqlite.SQLiteDatabase.class, java.lang.String.class,
+ java.lang.String.class, java.lang.String[].class}
+ )
+ })
public void testQueryNumEntries() {
- assertEquals(0, DatabaseUtils.queryNumEntries(mDatabase, "test"));
+ assertEquals(0, DatabaseUtils.queryNumEntries(mDatabase, TABLE_NAME));
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- assertEquals(1, DatabaseUtils.queryNumEntries(mDatabase, "test"));
+ mDatabase.execSQL(
+ "INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
+ assertEquals(1, DatabaseUtils.queryNumEntries(mDatabase, TABLE_NAME));
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
- assertEquals(2, DatabaseUtils.queryNumEntries(mDatabase, "test"));
+ mDatabase.execSQL(
+ "INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Susan', '20', 'AR');");
+ assertEquals(2, DatabaseUtils.queryNumEntries(mDatabase, TABLE_NAME));
+
+ mDatabase.execSQL(
+ "INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Christian', '25', 'AT');");
+ assertEquals(3, DatabaseUtils.queryNumEntries(mDatabase, TABLE_NAME));
+
+ assertEquals(2, DatabaseUtils.queryNumEntries(mDatabase, TABLE_NAME, "AGE = 20"));
+
+ assertEquals(1, DatabaseUtils.queryNumEntries(mDatabase, TABLE_NAME, "AGE = ?",
+ new String[] { "25" }));
try {
DatabaseUtils.queryNumEntries(mDatabase, "NoSuchTable");
@@ -695,13 +743,15 @@
)
})
public void testStringForQuery() {
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Mike', '20', 'LA');");
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Mike', '20', 'LA');");
- String query = "SELECT name FROM test";
+ String query = "SELECT name FROM " + TABLE_NAME;
assertEquals("Mike", DatabaseUtils.stringForQuery(mDatabase, query, null));
- mDatabase.execSQL("INSERT INTO test (name, age, address) VALUES ('Jack', '35', 'London');");
- query = "SELECT name FROM test WHERE address = ?";
+ mDatabase.execSQL("INSERT INTO " + TABLE_NAME + " (name, age, address)" +
+ " VALUES ('Jack', '35', 'London');");
+ query = "SELECT name FROM " + TABLE_NAME + " WHERE address = ?";
String[] args = new String[] { "London" };
assertEquals("Jack", DatabaseUtils.stringForQuery(mDatabase, query, args));
args = new String[] { "No such address" };
@@ -712,7 +762,7 @@
// expected
}
- query = "SELECT name FROM test WHERE age = ?;";
+ query = "SELECT name FROM " + TABLE_NAME + " WHERE age = ?;";
SQLiteStatement statement = mDatabase.compileStatement(query);
args = new String[] { "20" };
assertEquals("Mike", DatabaseUtils.stringForQuery(statement, args));
@@ -726,4 +776,4 @@
}
statement.close();
}
-}
+}
\ No newline at end of file
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
index 6a836e0..d7d5ff6 100755
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -25,19 +25,24 @@
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Color;
import android.graphics.Rect;
+import android.graphics.Bitmap.CompressFormat;
+import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.os.ParcelFileDescriptor;
import android.test.InstrumentationTestCase;
import android.util.DisplayMetrics;
import android.util.TypedValue;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
@TestTargetClass(BitmapFactory.class)
public class BitmapFactoryTest extends InstrumentationTestCase {
@@ -52,6 +57,20 @@
private int mDefaultDensity;
private int mTargetDensity;
+ // The test images, including baseline JPEG, a PNG, a GIF, a BMP AND a WEBP.
+ private static int[] RES_IDS = new int[] {
+ R.drawable.baseline_jpeg, R.drawable.png_test, R.drawable.gif_test,
+ R.drawable.bmp_test, R.drawable.webp_test
+ };
+ private static String[] NAMES_TEMP_FILES = new String[] {
+ "baseline_temp.jpg", "png_temp.png", "gif_temp.gif",
+ "bmp_temp.bmp", "webp_temp.webp"
+ };
+
+ // The width and height of the above image.
+ private static int WIDTHS[] = new int[] { 1280, 640, 320, 320, 640 };
+ private static int HEIGHTS[] = new int[] { 960, 480, 240, 240, 480 };
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -188,6 +207,54 @@
@TestTargetNew(
level = TestLevel.COMPLETE,
+ method = "decodeStream",
+ args = {java.io.InputStream.class}
+ )
+ public void testDecodeStream3() throws IOException {
+ for (int i = 0; i < RES_IDS.length; ++i) {
+ InputStream is = obtainInputStream(RES_IDS[i]);
+ Bitmap b = BitmapFactory.decodeStream(is);
+ assertNotNull(b);
+ // Test the bitmap size
+ assertEquals(WIDTHS[i], b.getWidth());
+ assertEquals(HEIGHTS[i], b.getHeight());
+ }
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "decodeStream",
+ args = {java.io.InputStream.class}
+ )
+ public void testDecodeStream4() throws IOException {
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inPreferredConfig = Config.ARGB_8888;
+ final int kErrorTol = 16;
+
+ // Decode the PNG & WebP test images. The WebP test image has been encoded from PNG test
+ // image and should have same similar (within some error-tolerance) Bitmap data.
+ InputStream iStreamPng = obtainInputStream(R.drawable.png_test);
+ Bitmap bPng = BitmapFactory.decodeStream(iStreamPng, null, options);
+ assertNotNull(bPng);
+ assertEquals(bPng.getConfig(), Config.ARGB_8888);
+
+ InputStream iStreamWebp1 = obtainInputStream(R.drawable.webp_test);
+ Bitmap bWebp1 = BitmapFactory.decodeStream(iStreamWebp1, null, options);
+ assertNotNull(bWebp1);
+ compareBitmaps(bPng, bWebp1, kErrorTol, true);
+
+ // Compress the PNG image to WebP format (Quality=90) and decode it back.
+ // This will test end-to-end WebP encoding and decoding.
+ ByteArrayOutputStream oStreamWebp = new ByteArrayOutputStream();
+ assertTrue(bPng.compress(CompressFormat.WEBP, 90, oStreamWebp));
+ InputStream iStreamWebp2 = new ByteArrayInputStream(oStreamWebp.toByteArray());
+ Bitmap bWebp2 = BitmapFactory.decodeStream(iStreamWebp2, null, options);
+ assertNotNull(bWebp2);
+ compareBitmaps(bPng, bWebp2, kErrorTol, true);
+ }
+
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
method = "decodeFileDescriptor",
args = {java.io.FileDescriptor.class, android.graphics.Rect.class,
android.graphics.BitmapFactory.Options.class}
@@ -261,6 +328,10 @@
return mRes.openRawResource(R.drawable.start);
}
+ private InputStream obtainInputStream(int resId) {
+ return mRes.openRawResource(resId);
+ }
+
private ParcelFileDescriptor obtainParcelDescriptor(String path)
throws IOException {
File file = new File(path);
@@ -288,4 +359,48 @@
fOutput.close();
return (file.getPath());
}
+
+ // Compare expected to actual to see if their diff is less then mseMargin.
+ // lessThanMargin is to indicate whether we expect the mean square error
+ // to be "less than" or "no less than".
+ private void compareBitmaps(Bitmap expected, Bitmap actual,
+ int mseMargin, boolean lessThanMargin) {
+ final int width = expected.getWidth();
+ final int height = expected.getHeight();
+
+ assertEquals("mismatching widths", width, actual.getWidth());
+ assertEquals("mismatching heights", height, actual.getHeight());
+ assertEquals("mismatching configs", expected.getConfig(),
+ actual.getConfig());
+
+ double mse = 0;
+ int[] expectedColors = new int [width * height];
+ int[] actualColors = new int [width * height];
+
+ expected.getPixels(expectedColors, 0, width, 0, 0, width, height);
+ actual.getPixels(actualColors, 0, width, 0, 0, width, height);
+
+ for (int row = 0; row < height; ++row) {
+ for (int col = 0; col < width; ++col) {
+ int idx = row * width + col;
+ mse += distance(expectedColors[idx], actualColors[idx]);
+ }
+ }
+ mse /= width * height;
+
+ if (lessThanMargin) {
+ assertTrue("MSE too large for normal case: " + mse,
+ mse <= mseMargin);
+ } else {
+ assertFalse("MSE too small for abnormal case: " + mse,
+ mse <= mseMargin);
+ }
+ }
+
+ private double distance(int expect, int actual) {
+ final int r = Color.red(actual) - Color.red(expect);
+ final int g = Color.green(actual) - Color.green(expect);
+ final int b = Color.blue(actual) - Color.blue(expect);
+ return r * r + g * g + b * b;
+ }
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
index 44c91e3..afe3409 100644
--- a/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/Bitmap_CompressFormatTest.java
@@ -37,6 +37,7 @@
public void testValueOf(){
assertEquals(CompressFormat.JPEG, CompressFormat.valueOf("JPEG"));
assertEquals(CompressFormat.PNG, CompressFormat.valueOf("PNG"));
+ assertEquals(CompressFormat.WEBP, CompressFormat.valueOf("WEBP"));
}
@TestTargets({
@@ -55,13 +56,15 @@
public void testValues(){
CompressFormat[] comFormat = CompressFormat.values();
- assertEquals(2, comFormat.length);
+ assertEquals(3, comFormat.length);
assertEquals(CompressFormat.JPEG, comFormat[0]);
assertEquals(CompressFormat.PNG, comFormat[1]);
+ assertEquals(CompressFormat.WEBP, comFormat[2]);
//CompressFormat is used as a argument here for all the methods that use it
Bitmap b = Bitmap.createBitmap(10, 24, Config.ARGB_8888);
assertTrue(b.compress(CompressFormat.JPEG, 24, new ByteArrayOutputStream()));
assertTrue(b.compress(CompressFormat.PNG, 24, new ByteArrayOutputStream()));
+ assertTrue(b.compress(CompressFormat.WEBP, 24, new ByteArrayOutputStream()));
}
}
diff --git a/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java b/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
index a268cba..4541e9d 100644
--- a/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
@@ -526,6 +526,94 @@
assertEquals(2, mockDataSetObserver.getCalledOnChangedCount());
}
+ /**
+ * insert multiple items via add, notify data changed
+ * check count and content
+ */
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "add",
+ args = {Object.class}
+ )
+ })
+ public void testAdd() {
+ mArrayAdapter.setNotifyOnChange(true);
+ final MockDataSetObserver mockDataSetObserver = new MockDataSetObserver();
+ mArrayAdapter.registerDataSetObserver(mockDataSetObserver);
+
+ mArrayAdapter.clear();
+ assertEquals(mArrayAdapter.getCount(), 0);
+
+ mArrayAdapter.add("testing");
+ mArrayAdapter.add("android");
+ assertEquals(mArrayAdapter.getCount(), 2);
+ assertEquals(mArrayAdapter.getItem(0), "testing");
+ assertEquals(mArrayAdapter.getItem(1), "android");
+ }
+
+ /**
+ * insert multiple items via addAll, notify data changed
+ * check count and content
+ */
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "addAll",
+ args = {java.util.Collection.class}
+ )
+ })
+ public void testAddAllCollection() {
+ mArrayAdapter.setNotifyOnChange(true);
+ final MockDataSetObserver mockDataSetObserver = new MockDataSetObserver();
+ mArrayAdapter.registerDataSetObserver(mockDataSetObserver);
+
+ List<String> list = new ArrayList<String>();
+ list.add("");
+ list.add("hello");
+ list.add("android");
+ list.add("!");
+
+ mArrayAdapter.clear();
+ assertEquals(mArrayAdapter.getCount(), 0);
+
+ mArrayAdapter.addAll(list);
+ assertEquals(mArrayAdapter.getCount(), list.size());
+
+ assertEquals(mArrayAdapter.getItem(0), list.get(0));
+ assertEquals(mArrayAdapter.getItem(1), list.get(1));
+ assertEquals(mArrayAdapter.getItem(2), list.get(2));
+ assertEquals(mArrayAdapter.getItem(3), list.get(3));
+ }
+
+ /**
+ * insert multiple items via addAll, notify data changed
+ * check count and content
+ */
+ @TestTargets({
+ @TestTargetNew(
+ level = TestLevel.COMPLETE,
+ method = "addAll",
+ args = {Object[].class}
+ )
+ })
+ public void testAddAllParams() {
+ mArrayAdapter.setNotifyOnChange(true);
+ final MockDataSetObserver mockDataSetObserver = new MockDataSetObserver();
+ mArrayAdapter.registerDataSetObserver(mockDataSetObserver);
+
+ mArrayAdapter.clear();
+ assertEquals(mArrayAdapter.getCount(), 0);
+
+ mArrayAdapter.addAll("this", "is", "a", "unit", "test");
+ assertEquals(mArrayAdapter.getCount(), 5);
+ assertEquals(mArrayAdapter.getItem(0), "this");
+ assertEquals(mArrayAdapter.getItem(1), "is");
+ assertEquals(mArrayAdapter.getItem(2), "a");
+ assertEquals(mArrayAdapter.getItem(3), "unit");
+ assertEquals(mArrayAdapter.getItem(4), "test");
+ }
+
private static class MockDataSetObserver extends DataSetObserver {
private int mCalledOnChangedCount;