summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/chrome_tests.gypi6
-rw-r--r--chrome/test/live_sync/bookmark_model_verifier.cc6
-rw-r--r--chrome/test/live_sync/live_sync_test.cc (renamed from chrome/test/live_sync/live_bookmarks_sync_test.cc)18
-rw-r--r--chrome/test/live_sync/live_sync_test.h (renamed from chrome/test/live_sync/live_bookmarks_sync_test.h)14
-rw-r--r--chrome/test/live_sync/single_client_live_bookmarks_sync_unittest.cc4
-rw-r--r--chrome/test/live_sync/single_client_live_preferences_sync_unittest.cc53
-rw-r--r--chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc20
-rw-r--r--chrome/test/live_sync/two_client_live_preferences_sync_test.cc87
8 files changed, 175 insertions, 33 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 4118beb..bc74913 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1685,12 +1685,14 @@
'test/in_process_browser_test.h',
'test/live_sync/bookmark_model_verifier.cc',
'test/live_sync/bookmark_model_verifier.h',
- 'test/live_sync/live_bookmarks_sync_test.cc',
- 'test/live_sync/live_bookmarks_sync_test.h',
+ 'test/live_sync/live_sync_test.cc',
+ 'test/live_sync/live_sync_test.h',
'test/live_sync/profile_sync_service_test_harness.cc',
'test/live_sync/profile_sync_service_test_harness.h',
'test/live_sync/single_client_live_bookmarks_sync_unittest.cc',
+ 'test/live_sync/single_client_live_preferences_sync_unittest.cc',
'test/live_sync/two_client_live_bookmarks_sync_test.cc',
+ 'test/live_sync/two_client_live_preferences_sync_test.cc',
'test/test_launcher/run_all_unittests.cc',
'test/test_notification_tracker.cc',
'test/test_notification_tracker.h',
diff --git a/chrome/test/live_sync/bookmark_model_verifier.cc b/chrome/test/live_sync/bookmark_model_verifier.cc
index a9a41a9..f997962 100644
--- a/chrome/test/live_sync/bookmark_model_verifier.cc
+++ b/chrome/test/live_sync/bookmark_model_verifier.cc
@@ -11,7 +11,7 @@
#include "base/rand_util.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
-#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
+#include "chrome/test/live_sync/live_sync_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -29,13 +29,13 @@ void BookmarkModelVerifier::ExpectBookmarkInfoMatch(
}
BookmarkModelVerifier::BookmarkModelVerifier() {
- verifier_profile_.reset(LiveBookmarksSyncTest::MakeProfile(L"verifier"));
+ verifier_profile_.reset(LiveSyncTest::MakeProfile(L"verifier"));
verifier_ = verifier_profile_->GetBookmarkModel();
}
BookmarkModelVerifier* BookmarkModelVerifier::Create() {
BookmarkModelVerifier* v = new BookmarkModelVerifier();
- LiveBookmarksSyncTest::BlockUntilLoaded(v->verifier_);
+ LiveSyncTest::BlockUntilLoaded(v->verifier_);
return v;
}
diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.cc b/chrome/test/live_sync/live_sync_test.cc
index d737280..8759106 100644
--- a/chrome/test/live_sync/live_bookmarks_sync_test.cc
+++ b/chrome/test/live_sync/live_sync_test.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
+#include "chrome/test/live_sync/live_sync_test.h"
#include <vector>
@@ -53,14 +53,14 @@ class BookmarkLoadObserver : public BookmarkModelObserver {
DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver);
};
-LiveBookmarksSyncTest::LiveBookmarksSyncTest() {
+LiveSyncTest::LiveSyncTest() {
}
-LiveBookmarksSyncTest::~LiveBookmarksSyncTest() {
+LiveSyncTest::~LiveSyncTest() {
}
// static
-void LiveBookmarksSyncTest::BlockUntilLoaded(BookmarkModel* m) {
+void LiveSyncTest::BlockUntilLoaded(BookmarkModel* m) {
if (m->IsLoaded())
return;
BookmarkLoadObserver observer;
@@ -71,8 +71,8 @@ void LiveBookmarksSyncTest::BlockUntilLoaded(BookmarkModel* m) {
}
// static
-const BookmarkNode* LiveBookmarksSyncTest::GetByUniqueURL(BookmarkModel* m,
- const GURL& url) {
+const BookmarkNode* LiveSyncTest::GetByUniqueURL(BookmarkModel* m,
+ const GURL& url) {
std::vector<const BookmarkNode*> nodes;
m->GetNodesByURL(url, &nodes);
EXPECT_EQ(1U, nodes.size());
@@ -80,14 +80,14 @@ const BookmarkNode* LiveBookmarksSyncTest::GetByUniqueURL(BookmarkModel* m,
}
// static
-Profile* LiveBookmarksSyncTest::MakeProfile(const std::wstring& name) {
+Profile* LiveSyncTest::MakeProfile(const std::wstring& name) {
FilePath path;
PathService::Get(chrome::DIR_USER_DATA, &path);
path.Append(FilePath::FromWStringHack(name));
return ProfileManager::CreateProfile(path);
}
-void LiveBookmarksSyncTest::SetUpInProcessBrowserTestFixture() {
+void LiveSyncTest::SetUpInProcessBrowserTestFixture() {
// We don't take a reference to |resolver|, but mock_host_resolver_override_
// does, so effectively assumes ownership.
net::RuleBasedHostResolverProc* resolver =
@@ -102,6 +102,6 @@ void LiveBookmarksSyncTest::SetUpInProcessBrowserTestFixture() {
new net::ScopedDefaultHostResolverProc(resolver));
}
-void LiveBookmarksSyncTest::TearDownInProcessBrowserTestFixture() {
+void LiveSyncTest::TearDownInProcessBrowserTestFixture() {
mock_host_resolver_override_.reset();
}
diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.h b/chrome/test/live_sync/live_sync_test.h
index 134e82f..43975f6 100644
--- a/chrome/test/live_sync/live_bookmarks_sync_test.h
+++ b/chrome/test/live_sync/live_sync_test.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
-#define CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
+#ifndef CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_
+#define CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_
#include <string>
@@ -28,10 +28,10 @@ extern const wchar_t kSyncPasswordForTest[];
// TODO(timsteele): This should be moved out of personalization_unit_tests into
// its own project that doesn't get run by default on the standard buildbot
// without a valid sync server set up.
-class LiveBookmarksSyncTest : public InProcessBrowserTest {
+class LiveSyncTest : public InProcessBrowserTest {
public:
- LiveBookmarksSyncTest();
- ~LiveBookmarksSyncTest();
+ LiveSyncTest();
+ ~LiveSyncTest();
virtual void SetUp() {
// At this point, the browser hasn't been launched, and no services are
@@ -78,7 +78,7 @@ class LiveBookmarksSyncTest : public InProcessBrowserTest {
// to override the default resolver while the test is active.
scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_;
- DISALLOW_COPY_AND_ASSIGN(LiveBookmarksSyncTest);
+ DISALLOW_COPY_AND_ASSIGN(LiveSyncTest);
};
-#endif // CHROME_TEST_LIVE_SYNC_LIVE_BOOKMARKS_SYNC_TEST_H_
+#endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_
diff --git a/chrome/test/live_sync/single_client_live_bookmarks_sync_unittest.cc b/chrome/test/live_sync/single_client_live_bookmarks_sync_unittest.cc
index 0ccacad..d578ea7 100644
--- a/chrome/test/live_sync/single_client_live_bookmarks_sync_unittest.cc
+++ b/chrome/test/live_sync/single_client_live_bookmarks_sync_unittest.cc
@@ -9,9 +9,9 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/test/live_sync/bookmark_model_verifier.h"
#include "chrome/test/live_sync/profile_sync_service_test_harness.h"
-#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
+#include "chrome/test/live_sync/live_sync_test.h"
-class SingleClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
+class SingleClientLiveBookmarksSyncTest : public LiveSyncTest {
public:
SingleClientLiveBookmarksSyncTest() { }
~SingleClientLiveBookmarksSyncTest() { }
diff --git a/chrome/test/live_sync/single_client_live_preferences_sync_unittest.cc b/chrome/test/live_sync/single_client_live_preferences_sync_unittest.cc
new file mode 100644
index 0000000..8e0da62
--- /dev/null
+++ b/chrome/test/live_sync/single_client_live_preferences_sync_unittest.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/pref_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/live_sync/profile_sync_service_test_harness.h"
+#include "chrome/test/live_sync/live_sync_test.h"
+
+class SingleClientLivePreferencesSyncTest : public LiveSyncTest {
+ public:
+ SingleClientLivePreferencesSyncTest() {
+ // This makes sure browser is visible and active while running test.
+ InProcessBrowserTest::set_show_window(true);
+ // Set the initial timeout value to 5 min.
+ InProcessBrowserTest::SetInitialTimeoutInMS(300000);
+ }
+ ~SingleClientLivePreferencesSyncTest() {}
+
+ void SetupSync() {
+ client_.reset(new ProfileSyncServiceTestHarness(
+ browser()->profile(), username_, password_));
+ EXPECT_TRUE(client_->SetupSync());
+ EXPECT_TRUE(client()->AwaitSyncCycleCompletion("Initial setup"));
+ }
+
+ ProfileSyncServiceTestHarness* client() { return client_.get(); }
+ ProfileSyncService* service() { return client_->service(); }
+
+ PrefService* prefs() { return browser()->profile()->GetPrefs(); }
+
+ private:
+ scoped_ptr<ProfileSyncServiceTestHarness> client_;
+
+ DISALLOW_COPY_AND_ASSIGN(SingleClientLivePreferencesSyncTest);
+};
+
+IN_PROC_BROWSER_TEST_F(SingleClientLivePreferencesSyncTest, Sanity) {
+ SetupSync();
+
+ PrefService* expected = LiveSyncTest::MakeProfile(L"verifier")->GetPrefs();
+ expected->SetBoolean(prefs::kHomePageIsNewTabPage, true);
+
+ prefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true);
+ ASSERT_TRUE(client()->AwaitSyncCycleCompletion("Pref updated"));
+
+ ASSERT_EQ(expected->GetBoolean(prefs::kHomePageIsNewTabPage),
+ prefs()->GetBoolean(prefs::kHomePageIsNewTabPage));
+}
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 c9109b4..e7b5904 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
@@ -14,7 +14,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/test/live_sync/bookmark_model_verifier.h"
#include "chrome/test/live_sync/profile_sync_service_test_harness.h"
-#include "chrome/test/live_sync/live_bookmarks_sync_test.h"
+#include "chrome/test/live_sync/live_sync_test.h"
#include "testing/gtest/include/gtest/gtest.h"
using std::string;
@@ -26,7 +26,7 @@ using std::wstring;
// F -- BookmarkFolder
// BM -- Bookmark
// L -- Level (Depth of bookmark folder)
-class TwoClientLiveBookmarksSyncTest : public LiveBookmarksSyncTest {
+class TwoClientLiveBookmarksSyncTest : public LiveSyncTest {
public:
TwoClientLiveBookmarksSyncTest() {
// This makes sure browser is visible and active while running test.
@@ -184,7 +184,7 @@ class LiveSyncTestPrePopulatedHistory1K
virtual void SetUp() {
PrePopulateHistory1K();
- LiveBookmarksSyncTest::SetUp();
+ LiveSyncTest::SetUp();
}
private:
@@ -200,7 +200,7 @@ class LiveSyncTestBasicHierarchy50BM
virtual void SetUp() {
FilePath file_name(FILE_PATH_LITERAL("bookmarks_50BM5F3L"));
PrePopulateBookmarksHierarchy(file_name);
- LiveBookmarksSyncTest::SetUp();
+ LiveSyncTest::SetUp();
}
private:
@@ -236,7 +236,7 @@ class LiveSyncTestComplexHierarchy800BM
virtual void SetUp() {
FilePath file_name(FILE_PATH_LITERAL("bookmarks_800BM32F8L"));
TwoClientLiveBookmarksSyncTest::PrePopulateBookmarksHierarchy(file_name);
- LiveBookmarksSyncTest::SetUp();
+ LiveSyncTest::SetUp();
}
private:
@@ -251,7 +251,7 @@ class LiveSyncTestHugeHierarchy5500BM
virtual void SetUp() {
FilePath file_name(FILE_PATH_LITERAL("bookmarks_5500BM125F25L"));
TwoClientLiveBookmarksSyncTest::PrePopulateBookmarksHierarchy(file_name);
- LiveBookmarksSyncTest::SetUp();
+ LiveSyncTest::SetUp();
}
virtual bool ShouldSetupSyncWithRace() {
return false;
@@ -271,7 +271,7 @@ class LiveSyncTestDefaultIEFavorites
const FilePath file_name(
FILE_PATH_LITERAL("bookmarks_default_IE_favorites"));
TwoClientLiveBookmarksSyncTest::PrePopulateBookmarksHierarchy(file_name);
- LiveBookmarksSyncTest::SetUp();
+ LiveSyncTest::SetUp();
}
private:
@@ -2355,7 +2355,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
set_profile2(MakeProfile(L"client2"));
BookmarkModel* model_one = browser()->profile()->GetBookmarkModel();
BookmarkModel* model_two = profile2()->GetBookmarkModel();
- LiveBookmarksSyncTest::BlockUntilLoaded(model_two);
+ LiveSyncTest::BlockUntilLoaded(model_two);
const BookmarkNode* bbn_one = model_one->GetBookmarkBarNode();
const BookmarkNode* bbn_two = model_two->GetBookmarkBarNode();
@@ -2424,7 +2424,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
set_profile2(MakeProfile(L"client2"));
BookmarkModel* model_one = browser()->profile()->GetBookmarkModel();
BookmarkModel* model_two = profile2()->GetBookmarkModel();
- LiveBookmarksSyncTest::BlockUntilLoaded(model_two);
+ LiveSyncTest::BlockUntilLoaded(model_two);
const BookmarkNode* bbn_one = model_one->GetBookmarkBarNode();
const BookmarkNode* bbn_two = model_two->GetBookmarkBarNode();
@@ -2481,7 +2481,7 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest,
set_profile2(MakeProfile(L"client2"));
BookmarkModel* model_one = browser()->profile()->GetBookmarkModel();
BookmarkModel* model_two = profile2()->GetBookmarkModel();
- LiveBookmarksSyncTest::BlockUntilLoaded(model_two);
+ LiveSyncTest::BlockUntilLoaded(model_two);
const BookmarkNode* bbn_one = model_one->GetBookmarkBarNode();
const BookmarkNode* bbn_two = model_two->GetBookmarkBarNode();
diff --git a/chrome/test/live_sync/two_client_live_preferences_sync_test.cc b/chrome/test/live_sync/two_client_live_preferences_sync_test.cc
new file mode 100644
index 0000000..2a587bc
--- /dev/null
+++ b/chrome/test/live_sync/two_client_live_preferences_sync_test.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/pref_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/live_sync/profile_sync_service_test_harness.h"
+#include "chrome/test/live_sync/live_sync_test.h"
+
+class TwoClientLivePreferencesSyncTest : public LiveSyncTest {
+ protected:
+ TwoClientLivePreferencesSyncTest() {
+ // This makes sure browser is visible and active while running test.
+ InProcessBrowserTest::set_show_window(true);
+ // Set the initial timeout value to 5 min.
+ InProcessBrowserTest::SetInitialTimeoutInMS(300000);
+ }
+ ~TwoClientLivePreferencesSyncTest() {}
+
+ void SetupSync() {
+ client1_.reset(new ProfileSyncServiceTestHarness(
+ browser()->profile(), username_, password_));
+ profile2_.reset(MakeProfile(L"client2"));
+ client2_.reset(new ProfileSyncServiceTestHarness(
+ profile2_.get(), username_, password_));
+ EXPECT_TRUE(client1_->SetupSync());
+ EXPECT_TRUE(client1_->AwaitSyncCycleCompletion("Initial setup 1"));
+ EXPECT_TRUE(client2_->SetupSync());
+ EXPECT_TRUE(client2_->AwaitSyncCycleCompletion("Initial setup 2"));
+ }
+
+ void Cleanup() {
+ client2_.reset();
+ profile2_.reset();
+ }
+
+ ProfileSyncServiceTestHarness* client1() { return client1_.get(); }
+ ProfileSyncServiceTestHarness* client2() { return client2_.get(); }
+
+ PrefService* prefs1() { return browser()->profile()->GetPrefs(); }
+ PrefService* prefs2() { return profile2_->GetPrefs(); }
+
+ private:
+ scoped_ptr<ProfileSyncServiceTestHarness> client1_;
+ scoped_ptr<ProfileSyncServiceTestHarness> client2_;
+ scoped_ptr<Profile> profile2_;
+
+ DISALLOW_COPY_AND_ASSIGN(TwoClientLivePreferencesSyncTest);
+};
+
+IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, Sanity) {
+ SetupSync();
+
+ EXPECT_EQ(false, prefs1()->GetBoolean(prefs::kHomePageIsNewTabPage));
+ EXPECT_EQ(false, prefs2()->GetBoolean(prefs::kHomePageIsNewTabPage));
+
+ PrefService* expected = LiveSyncTest::MakeProfile(L"verifier")->GetPrefs();
+ expected->SetBoolean(prefs::kHomePageIsNewTabPage, true);
+
+ prefs1()->SetBoolean(prefs::kHomePageIsNewTabPage, true);
+ EXPECT_TRUE(client2()->AwaitMutualSyncCycleCompletion(client1()));
+
+ EXPECT_EQ(expected->GetBoolean(prefs::kHomePageIsNewTabPage),
+ prefs1()->GetBoolean(prefs::kHomePageIsNewTabPage));
+ EXPECT_EQ(expected->GetBoolean(prefs::kHomePageIsNewTabPage),
+ prefs2()->GetBoolean(prefs::kHomePageIsNewTabPage));
+
+ Cleanup();
+}
+
+IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, Race) {
+ SetupSync();
+
+ prefs1()->SetString(prefs::kHomePage, L"http://www.google.com/1");
+ prefs2()->SetString(prefs::kHomePage, L"http://www.google.com/2");
+
+ EXPECT_TRUE(client2()->AwaitMutualSyncCycleCompletion(client1()));
+
+ EXPECT_EQ(prefs1()->GetString(prefs::kHomePage),
+ prefs2()->GetString(prefs::kHomePage));
+
+ Cleanup();
+}