diff options
-rw-r--r-- | chrome/test/in_process_browser_test.cc | 3 | ||||
-rw-r--r-- | chrome/test/in_process_browser_test.h | 13 | ||||
-rw-r--r-- | chrome/test/live_sync/live_bookmarks_sync_test.cc | 14 | ||||
-rw-r--r-- | chrome/test/live_sync/live_bookmarks_sync_test.h | 8 | ||||
-rw-r--r-- | chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc | 28 |
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())); |