diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-23 17:11:26 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-23 17:11:26 +0000 |
commit | 5c5de8c2e01750b642250c678d1cea09b057d051 (patch) | |
tree | 167db812b6955c2701a9725257601d97146c1116 /chrome/test/live_sync | |
parent | e5709adccae0cfa3856d16cb3a5d908e51cbf346 (diff) | |
download | chromium_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/test/live_sync')
-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 |
3 files changed, 36 insertions, 14 deletions
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())); |