diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-01-12 12:04:22 -0800 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-01-12 14:37:57 -0800 |
commit | 5a05c23f3d6a1a895bf5917aacd8bd9a5302ba00 (patch) | |
tree | 004b84d6921a0c8732d64401d73ea499b98c77aa /core/tests | |
parent | 38e90751a25606459a9e571aa1b6c992d4c64151 (diff) | |
download | frameworks_base-5a05c23f3d6a1a895bf5917aacd8bd9a5302ba00.zip frameworks_base-5a05c23f3d6a1a895bf5917aacd8bd9a5302ba00.tar.gz frameworks_base-5a05c23f3d6a1a895bf5917aacd8bd9a5302ba00.tar.bz2 |
Clean up database tests a little bit.
Change-Id: Ib05c699bf59187cb51627b5f352c2a15ad2c28bb
Diffstat (limited to 'core/tests')
8 files changed, 41 insertions, 63 deletions
diff --git a/core/tests/coretests/src/android/database/CursorWindowTest.java b/core/tests/coretests/src/android/database/CursorWindowTest.java index 8c8081c..075f5b7 100644 --- a/core/tests/coretests/src/android/database/CursorWindowTest.java +++ b/core/tests/coretests/src/android/database/CursorWindowTest.java @@ -35,15 +35,45 @@ public class CursorWindowTest extends TestCase implements PerformanceTestCase { } @SmallTest - public void testValuesLocalWindow() { - doTestValues(new CursorWindow(true)); + public void testConstructor_WithName() { + CursorWindow window = new CursorWindow("MyWindow"); + assertEquals("MyWindow", window.getName()); + assertEquals(0, window.getStartPosition()); + window.close(); } - + + @SmallTest + public void testConstructorWithEmptyName() { + CursorWindow window = new CursorWindow(""); + assertEquals("<unnamed>", window.getName()); + assertEquals(0, window.getStartPosition()); + window.close(); + } + @SmallTest - public void testValuesRemoteWindow() { - doTestValues(new CursorWindow(false)); + public void testConstructorWithNullName() { + CursorWindow window = new CursorWindow(null); + assertEquals("<unnamed>", window.getName()); + assertEquals(0, window.getStartPosition()); + window.close(); } - + + @SmallTest + public void testDeprecatedConstructor() { + @SuppressWarnings("deprecation") + CursorWindow window = new CursorWindow(true /*this argument is ignored*/); + assertEquals("<unnamed>", window.getName()); + assertEquals(0, window.getStartPosition()); + window.close(); + } + + @SmallTest + public void testValues() { + CursorWindow window = new CursorWindow("MyWindow"); + doTestValues(window); + window.close(); + } + private void doTestValues(CursorWindow window) { assertTrue(window.setNumColumns(7)); assertTrue(window.allocRow()); diff --git a/core/tests/coretests/src/android/database/DatabaseCursorTest.java b/core/tests/coretests/src/android/database/DatabaseCursorTest.java index 179338d..36f0f4b 100644 --- a/core/tests/coretests/src/android/database/DatabaseCursorTest.java +++ b/core/tests/coretests/src/android/database/DatabaseCursorTest.java @@ -16,7 +16,6 @@ package android.database; -import dalvik.annotation.BrokenTest; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; @@ -27,13 +26,11 @@ import android.database.sqlite.SQLiteCursor; import android.database.sqlite.SQLiteCursorDriver; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQuery; -import android.database.sqlite.SQLiteStatement; import android.os.Looper; import android.test.AndroidTestCase; import android.test.PerformanceTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.Suppress; import android.util.Log; import java.io.File; diff --git a/core/tests/coretests/src/android/database/DatabaseErrorHandlerTest.java b/core/tests/coretests/src/android/database/DatabaseErrorHandlerTest.java index 1cfd960..91c7687 100644 --- a/core/tests/coretests/src/android/database/DatabaseErrorHandlerTest.java +++ b/core/tests/coretests/src/android/database/DatabaseErrorHandlerTest.java @@ -21,7 +21,6 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDiskIOException; import android.database.sqlite.SQLiteException; import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.Suppress; import android.util.Log; import java.io.BufferedWriter; diff --git a/core/tests/coretests/src/android/database/DatabaseGeneralTest.java b/core/tests/coretests/src/android/database/DatabaseGeneralTest.java index 6786700..c7cb43d 100644 --- a/core/tests/coretests/src/android/database/DatabaseGeneralTest.java +++ b/core/tests/coretests/src/android/database/DatabaseGeneralTest.java @@ -410,40 +410,6 @@ public class DatabaseGeneralTest extends AndroidTestCase implements PerformanceT } } - private class ChangeObserver extends ContentObserver { - private int mCursorNotificationCount = 0; - private int mNotificationCount = 0; - - public int getCursorNotificationCount() { - return mCursorNotificationCount; - } - - public int getNotificationCount() { - return mNotificationCount; - } - - public ChangeObserver(boolean cursor) { - super(new Handler()); - mCursor = cursor; - } - - @Override - public boolean deliverSelfNotifications() { - return true; - } - - @Override - public void onChange(boolean selfChange) { - if (mCursor) { - mCursorNotificationCount++; - } else { - mNotificationCount++; - } - } - - boolean mCursor; - } - @MediumTest public void testSelectionArgs() throws Exception { mDatabase.execSQL("CREATE TABLE test (_id INTEGER PRIMARY KEY, data TEXT);"); diff --git a/core/tests/coretests/src/android/database/DatabaseLockTest.java b/core/tests/coretests/src/android/database/DatabaseLockTest.java index f7a9f8a..8d3cf5a 100644 --- a/core/tests/coretests/src/android/database/DatabaseLockTest.java +++ b/core/tests/coretests/src/android/database/DatabaseLockTest.java @@ -16,18 +16,13 @@ package android.database; -import android.app.Activity; -import android.content.Context; import android.database.sqlite.SQLiteDatabase; -import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.Suppress; import android.util.Log; import java.io.File; import java.util.concurrent.atomic.AtomicInteger; import android.test.AndroidTestCase; -import junit.framework.TestCase; - /* * This is a series of unit tests for database locks. * @@ -104,9 +99,9 @@ public class DatabaseLockTest extends AndroidTestCase { public void run() { for (int i = 0; i < NUM_ITERATIONS; i++) { mDatabase.beginTransaction(); - int val = mCounter.incrementAndGet(); + mCounter.incrementAndGet(); try { - Thread.currentThread().sleep(SLEEP_TIME); + Thread.sleep(SLEEP_TIME); } catch (InterruptedException e) { // ignore } @@ -124,7 +119,6 @@ public class DatabaseLockTest extends AndroidTestCase { @Suppress public void testLockLatency() { startDatabaseLatencyThread(); - int previous = 0; long sumTime = 0; long maxTime = 0; for (int i = 0; i < NUM_ITERATIONS; i++) { @@ -137,7 +131,7 @@ public class DatabaseLockTest extends AndroidTestCase { } sumTime += elapsedTime; try { - Thread.currentThread().sleep(SLEEP_TIME); + Thread.sleep(SLEEP_TIME); } catch (InterruptedException e) { // ignore } @@ -164,7 +158,7 @@ public class DatabaseLockTest extends AndroidTestCase { { mDatabase.beginTransaction(); try { - Thread.currentThread().sleep(SLEEP_TIME); + Thread.sleep(SLEEP_TIME); } catch (InterruptedException e) { // ignore } diff --git a/core/tests/coretests/src/android/database/DatabasePerformanceTests.java b/core/tests/coretests/src/android/database/DatabasePerformanceTests.java index b8ebcc4..d0e739b 100644 --- a/core/tests/coretests/src/android/database/DatabasePerformanceTests.java +++ b/core/tests/coretests/src/android/database/DatabasePerformanceTests.java @@ -35,6 +35,7 @@ import java.util.Random; * */ +@SuppressWarnings("deprecation") public class DatabasePerformanceTests { public static String[] children() { diff --git a/core/tests/coretests/src/android/database/DatabaseStatementTest.java b/core/tests/coretests/src/android/database/DatabaseStatementTest.java index 71dc3ae..512d5cd 100644 --- a/core/tests/coretests/src/android/database/DatabaseStatementTest.java +++ b/core/tests/coretests/src/android/database/DatabaseStatementTest.java @@ -25,8 +25,6 @@ import android.database.sqlite.SQLiteStatement; import android.test.AndroidTestCase; import android.test.PerformanceTestCase; import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; -import junit.framework.TestCase; import java.io.File; diff --git a/core/tests/coretests/src/android/database/NewDatabasePerformanceTests.java b/core/tests/coretests/src/android/database/NewDatabasePerformanceTests.java index 0dca90b..f4487d9 100644 --- a/core/tests/coretests/src/android/database/NewDatabasePerformanceTests.java +++ b/core/tests/coretests/src/android/database/NewDatabasePerformanceTests.java @@ -20,7 +20,6 @@ import android.content.ContentValues; import android.database.sqlite.SQLiteDatabase; import android.test.PerformanceTestCase; -import junit.framework.Assert; import junit.framework.TestCase; import java.io.File; @@ -493,8 +492,6 @@ public class NewDatabasePerformanceTests { private static final int SIZE = 1 * kMultiplier; private static final String[] COLUMNS = {"b"}; - private String[] where = new String[SIZE]; - @Override public void setUp() { super.setUp(); @@ -526,8 +523,6 @@ public class NewDatabasePerformanceTests { private static final int SIZE = 1 * kMultiplier; private static final String[] COLUMNS = {"c"}; - private String[] where = new String[SIZE]; - @Override public void setUp() { super.setUp(); @@ -661,7 +656,6 @@ public class NewDatabasePerformanceTests { public static class DeleteIndexed1000 extends PerformanceBase { private static final int SIZE = 10 * kMultiplier; - private static final String[] COLUMNS = {"c"}; @Override public void setUp() { @@ -693,7 +687,6 @@ public class NewDatabasePerformanceTests { public static class Delete1000 extends PerformanceBase { private static final int SIZE = 10 * kMultiplier; - private static final String[] COLUMNS = {"c"}; @Override public void setUp() { |