diff options
author | John Reck <jreck@google.com> | 2011-08-09 11:27:50 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-08-09 11:27:50 -0700 |
commit | 37d9f2f4c540131453b692d6cb17468637dcef9e (patch) | |
tree | b39fd9190f97e53a7086c90d69eb51e7a7026ff3 | |
parent | e94de5ea927be9fad644c3ff7f9c7719ec4174af (diff) | |
parent | db78cd054b0344e67a18dc9e1d1a154d3814dc77 (diff) | |
download | packages_apps_Browser-37d9f2f4c540131453b692d6cb17468637dcef9e.zip packages_apps_Browser-37d9f2f4c540131453b692d6cb17468637dcef9e.tar.gz packages_apps_Browser-37d9f2f4c540131453b692d6cb17468637dcef9e.tar.bz2 |
Merge "Tests fixup"
3 files changed, 25 insertions, 3 deletions
diff --git a/src/com/android/browser/provider/BrowserProvider.java b/src/com/android/browser/provider/BrowserProvider.java index fabf57e..b55b84a 100644 --- a/src/com/android/browser/provider/BrowserProvider.java +++ b/src/com/android/browser/provider/BrowserProvider.java @@ -251,7 +251,7 @@ public class BrowserProvider extends ContentProvider { public DatabaseHelper(Context context) { super(context, sDatabaseName, null, DATABASE_VERSION); - mContext = context.getApplicationContext(); + mContext = context; } @Override diff --git a/tests/src/com/android/browser/tests/utils/BP2TestCaseHelper.java b/tests/src/com/android/browser/tests/utils/BP2TestCaseHelper.java index 18c1c10..e341c6a 100644 --- a/tests/src/com/android/browser/tests/utils/BP2TestCaseHelper.java +++ b/tests/src/com/android/browser/tests/utils/BP2TestCaseHelper.java @@ -18,6 +18,9 @@ package com.android.browser.tests.utils; import com.android.browser.provider.BrowserProvider2; +import java.io.File; +import java.io.FilenameFilter; + import android.content.ContentValues; import android.database.ContentObserver; import android.net.Uri; @@ -208,4 +211,22 @@ public abstract class BP2TestCaseHelper extends ProviderTestCase3<BrowserProvide perfIdeallyUntriggered(mBookmarksObserver, mWidgetObserver); return updated; } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + // Delete the test databases so that subsequent runs have a clean slate + File f = getMockContext().getDatabasePath("test"); + File dir = f.getParentFile(); + File testFiles[] = dir.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String filename) { + return filename.startsWith(ProviderTestCase3.FILENAME_PREFIX); + } + }); + for (File testFile : testFiles) { + testFile.delete(); + } + } } diff --git a/tests/src/com/android/browser/tests/utils/ProviderTestCase3.java b/tests/src/com/android/browser/tests/utils/ProviderTestCase3.java index 536163a..75bc052 100644 --- a/tests/src/com/android/browser/tests/utils/ProviderTestCase3.java +++ b/tests/src/com/android/browser/tests/utils/ProviderTestCase3.java @@ -35,6 +35,8 @@ import java.io.File; */ public abstract class ProviderTestCase3<T extends ContentProvider> extends AndroidTestCase { + public static final String FILENAME_PREFIX = "test."; + Class<T> mProviderClass; String[] mProviderAuthority; @@ -112,13 +114,12 @@ public abstract class ProviderTestCase3<T extends ContentProvider> extends Andro super.setUp(); mResolver = new MockContentResolver2(); - final String filenamePrefix = "test."; RenamingDelegatingContext targetContextWrapper = new RenamingDelegatingContext( new MockContext2(), // The context that most methods are //delegated to getContext(), // The context that file methods are delegated to - filenamePrefix); + FILENAME_PREFIX); // The default IsolatedContext has a mock AccountManager that doesn't // work for us, so override getSystemService to always return null mProviderContext = new IsolatedContext(mResolver, targetContextWrapper) { |