am 0cfbb02f: Merge "Fix BuildVersionTest" into gingerbread
* commit '0cfbb02f2424f2425457afd0b2528dd819272364':
Fix BuildVersionTest
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/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/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;