summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 17:11:26 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 17:11:26 +0000
commit5c5de8c2e01750b642250c678d1cea09b057d051 (patch)
tree167db812b6955c2701a9725257601d97146c1116 /chrome
parente5709adccae0cfa3856d16cb3a5d908e51cbf346 (diff)
downloadchromium_src-5c5de8c2e01750b642250c678d1cea09b057d051.zip
chromium_src-5c5de8c2e01750b642250c678d1cea09b057d051.tar.gz
chromium_src-5c5de8c2e01750b642250c678d1cea09b057d051.tar.bz2
Add SetUpTestFixtureTest/TearDownTestFixtureTest methods to InProcessBrowserTest that let tests do
what is normally done by overriding SetUp/TearDown methods. This special method is needed because of the way SetUp winds up at the bottom of the stack that invokes your test fixture methods. Make the LiveBookmarksSyncTest class allow direct lookup for google.com domain as part of setup, which these tests need to access GAIA and sync servers. Review URL: http://codereview.chromium.org/214047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/test/in_process_browser_test.cc3
-rw-r--r--chrome/test/in_process_browser_test.h13
-rw-r--r--chrome/test/live_sync/live_bookmarks_sync_test.cc14
-rw-r--r--chrome/test/live_sync/live_bookmarks_sync_test.h8
-rw-r--r--chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc28
5 files changed, 52 insertions, 14 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 74dfe5c..89f128a 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -141,7 +141,10 @@ void InProcessBrowserTest::SetUp() {
net::ScopedDefaultHostResolverProc scoped_host_resolver_proc(
host_resolver_.get());
+
+ SetUpInProcessBrowserTestFixture();
BrowserMain(params);
+ TearDownInProcessBrowserTestFixture();
}
void InProcessBrowserTest::TearDown() {
diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h
index 053dce1..2f519b7 100644
--- a/chrome/test/in_process_browser_test.h
+++ b/chrome/test/in_process_browser_test.h
@@ -64,6 +64,19 @@ class InProcessBrowserTest : public testing::Test {
// Override this rather than TestBody.
virtual void RunTestOnMainThread() = 0;
+ // We need these special methods because InProcessBrowserTest::SetUp is the
+ // bottom of the stack that winds up calling your test method, so it is not
+ // always an option to do what you want by overriding it and calling the
+ // superclass version.
+ //
+ // Override this for things you would normally override SetUp for. It will be
+ // called before your individual test fixture method is run, but after most
+ // of the overhead initialization has occured.
+ virtual void SetUpInProcessBrowserTestFixture() {}
+
+ // Override this for things you would normally override TearDown for.
+ virtual void TearDownInProcessBrowserTestFixture() {}
+
// Override this to add command line flags specific to your test.
virtual void SetUpCommandLine(CommandLine* command_line) {}
diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.cc b/chrome/test/live_sync/live_bookmarks_sync_test.cc
index 3737cc3..51fc2cd 100644
--- a/chrome/test/live_sync/live_bookmarks_sync_test.cc
+++ b/chrome/test/live_sync/live_bookmarks_sync_test.cc
@@ -82,4 +82,18 @@ Profile* LiveBookmarksSyncTest::MakeProfile(const string16& name) {
return ProfileManager::CreateProfile(path, name, L"", L"");
}
+void LiveBookmarksSyncTest::SetUpInProcessBrowserTestFixture() {
+ // We don't take a reference to |resolver|, but mock_host_resolver_override_
+ // does, so effectively assumes ownership.
+ net::RuleBasedHostResolverProc* resolver =
+ new net::RuleBasedHostResolverProc(host_resolver());
+ resolver->AllowDirectLookup("*.google.com");
+ mock_host_resolver_override_.reset(
+ new net::ScopedDefaultHostResolverProc(resolver));
+}
+
+void LiveBookmarksSyncTest::TearDownInProcessBrowserTestFixture() {
+ mock_host_resolver_override_.reset();
+}
+
#endif // CHROME_PERSONALIZATION
diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.h b/chrome/test/live_sync/live_bookmarks_sync_test.h
index 316ffd7..3ea534a 100644
--- a/chrome/test/live_sync/live_bookmarks_sync_test.h
+++ b/chrome/test/live_sync/live_bookmarks_sync_test.h
@@ -69,7 +69,15 @@ class LiveBookmarksSyncTest : public InProcessBrowserTest {
std::string username_;
std::string password_;
+ virtual void SetUpInProcessBrowserTestFixture();
+ virtual void TearDownInProcessBrowserTestFixture();
+
private:
+ // LiveBookmarksSyncTests need to make live DNS requests for access to
+ // GAIA and sync server URLs under google.com. We use a scoped version
+ // to override the default resolver while the test is active.
+ scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_;
+
DISALLOW_COPY_AND_ASSIGN(LiveBookmarksSyncTest);
};
diff --git a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc
index 690738e..7cc1ab9 100644
--- a/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc
+++ b/chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc
@@ -954,21 +954,21 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
int random_int = base::RandInt(1, 100);
// To create randomness in order, 40% of time add bookmarks
if (random_int > 60) {
- string16 title(L"BB - TestBookmark");
- string16 url(L"http://www.nofaviconurl");
- string16 index_str = IntToString16(index);
- title.append(index_str);
- url.append(index_str);
- url.append(L".com");
- const BookmarkNode* nofavicon_bm = verifier->AddURL(model_one, bbn_one,
- index, title, GURL(url));
+ string16 title(L"BB - TestBookmark");
+ string16 url(L"http://www.nofaviconurl");
+ string16 index_str = IntToString16(index);
+ title.append(index_str);
+ url.append(index_str);
+ url.append(L".com");
+ const BookmarkNode* nofavicon_bm = verifier->AddURL(model_one, bbn_one,
+ index, title, GURL(url));
} else {
- // Remaining % of time - Add Bookmark folders
- string16 title(L"BB - TestBMFolder");
- string16 index_str = IntToString16(index);
- title.append(index_str);
- const BookmarkNode* bm_folder = verifier->AddGroup(model_one, bbn_one,
- index, title);
+ // Remaining % of time - Add Bookmark folders
+ string16 title(L"BB - TestBMFolder");
+ string16 index_str = IntToString16(index);
+ title.append(index_str);
+ const BookmarkNode* bm_folder = verifier->AddGroup(model_one, bbn_one,
+ index, title);
}
}
ASSERT_TRUE(client1()->AwaitMutualSyncCycleCompletion(client2()));