diff options
author | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-25 02:22:00 +0000 |
---|---|---|
committer | zea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-25 02:22:00 +0000 |
commit | f875d728dc277777d57f210a903261cc2d3fa4f0 (patch) | |
tree | 9482f3726650c5d89c44e126e8ba51405d1b354d | |
parent | 5ee4304713457b8293454c34be8b1f9f929b8453 (diff) | |
download | chromium_src-f875d728dc277777d57f210a903261cc2d3fa4f0.zip chromium_src-f875d728dc277777d57f210a903261cc2d3fa4f0.tar.gz chromium_src-f875d728dc277777d57f210a903261cc2d3fa4f0.tar.bz2 |
[Sync] Add bookmark and preference encryption integration tests.
BUG=59242
TEST=sync integration tests
Review URL: http://codereview.chromium.org/7251005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90478 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 171 insertions, 0 deletions
diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.cc b/chrome/test/live_sync/live_bookmarks_sync_test.cc index 3dd4a50..c4dc623 100644 --- a/chrome/test/live_sync/live_bookmarks_sync_test.cc +++ b/chrome/test/live_sync/live_bookmarks_sync_test.cc @@ -7,6 +7,7 @@ #include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/sync/profile_sync_service_harness.h" #include "chrome/test/ui_test_utils.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/codec/png_codec.h" @@ -49,6 +50,14 @@ void LiveBookmarksSyncTest::DisableVerifier() { verifier_helper_->set_use_verifier_model(false); } +bool LiveBookmarksSyncTest::EnableEncryption(int index) { + return GetClient(index)->EnableEncryptionForType(syncable::BOOKMARKS); +} + +bool LiveBookmarksSyncTest::IsEncrypted(int index) { + return GetClient(index)->IsTypeEncrypted(syncable::BOOKMARKS); +} + const BookmarkNode* LiveBookmarksSyncTest::AddURL(int profile, const std::wstring& title, const GURL& url) { diff --git a/chrome/test/live_sync/live_bookmarks_sync_test.h b/chrome/test/live_sync/live_bookmarks_sync_test.h index 0cac26a..9ed22da 100644 --- a/chrome/test/live_sync/live_bookmarks_sync_test.h +++ b/chrome/test/live_sync/live_bookmarks_sync_test.h @@ -42,6 +42,12 @@ class LiveBookmarksSyncTest : public LiveSyncTest { // be reflected in the verifier model. void DisableVerifier(); + // Encrypt Bookmarks datatype. + bool EnableEncryption(int index); + + // Check if Bookmarks are encrypted. + bool IsEncrypted(int index); + // Adds a URL with address |url| and title |title| to the bookmark bar of // profile |profile|. Returns a pointer to the node that was added. const BookmarkNode* AddURL(int profile, diff --git a/chrome/test/live_sync/live_preferences_sync_test.cc b/chrome/test/live_sync/live_preferences_sync_test.cc index 2e8faf3..5a00cd5 100644 --- a/chrome/test/live_sync/live_preferences_sync_test.cc +++ b/chrome/test/live_sync/live_preferences_sync_test.cc @@ -8,6 +8,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/sync/profile_sync_service_harness.h" LivePreferencesSyncTest::LivePreferencesSyncTest(TestType test_type) : LiveSyncTest(test_type), @@ -200,3 +201,11 @@ bool LivePreferencesSyncTest::ListPrefMatches(const char* pref_name) { void LivePreferencesSyncTest::DisableVerifier() { use_verifier_prefs_ = false; } + +bool LivePreferencesSyncTest::EnableEncryption(int index) { + return GetClient(index)->EnableEncryptionForType(syncable::PREFERENCES); +} + +bool LivePreferencesSyncTest::IsEncrypted(int index) { + return GetClient(index)->IsTypeEncrypted(syncable::PREFERENCES); +} diff --git a/chrome/test/live_sync/live_preferences_sync_test.h b/chrome/test/live_sync/live_preferences_sync_test.h index 8476a92..e961aeb 100644 --- a/chrome/test/live_sync/live_preferences_sync_test.h +++ b/chrome/test/live_sync/live_preferences_sync_test.h @@ -100,6 +100,12 @@ class LivePreferencesSyncTest : public LiveSyncTest { // longer be reflected in the verifier profile. void DisableVerifier(); + // Encrypt Preferences datatype. + bool EnableEncryption(int index); + + // Check if Preferences are encrypted. + bool IsEncrypted(int index); + private: // Indicates whether preference operations should also update the verifier // profile's PrefService or not. 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 51097da..a79cd00 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 @@ -1638,3 +1638,76 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, ASSERT_TRUE(AllModelsMatch()); ASSERT_FALSE(ContainsDuplicateBookmarks(0)); } + +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, + SingleClientEnabledEncryption) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(AllModelsMatchVerifier()); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, + SingleClientEnabledEncryptionAndChanged) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(AllModelsMatchVerifier()); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, + BothClientsEnabledEncryption) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(EnableEncryption(1)); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(AllModelsMatchVerifier()); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, + SingleClientEnabledEncryptionBothChanged) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); + ASSERT_TRUE(AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(AllModelsMatchVerifier()); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLiveBookmarksSyncTest, + SingleClientEnabledEncryptionAndChangedMultipleTimes) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL(0, IndexedURLTitle(0), GURL(IndexedURL(0))) != NULL); + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(AllModelsMatchVerifier()); + + ASSERT_TRUE(AddURL(0, IndexedURLTitle(1), GURL(IndexedURL(1))) != NULL); + ASSERT_TRUE(AddFolder(0, IndexedFolderName(0)) != NULL); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(AllModelsMatchVerifier()); +} 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 index 86be274..2cc0a34 100644 --- a/chrome/test/live_sync/two_client_live_preferences_sync_test.cc +++ b/chrome/test/live_sync/two_client_live_preferences_sync_test.cc @@ -522,3 +522,71 @@ IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, kEnableScreenLock) { ASSERT_TRUE(BooleanPrefMatches(prefs::kEnableScreenLock)); } #endif // OS_CHROMEOS + +IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, + SingleClientEnabledEncryption) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, + SingleClientEnabledEncryptionAndChanged) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage)); + + ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage); + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage)); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, + BothClientsEnabledEncryption) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(EnableEncryption(1)); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, + SingleClientEnabledEncryptionBothChanged) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage)); + ASSERT_TRUE(StringPrefMatches(prefs::kHomePage)); + + ASSERT_TRUE(EnableEncryption(0)); + ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage); + ChangeStringPref(1, prefs::kHomePage, "http://www.google.com/1"); + ASSERT_TRUE(AwaitQuiescence()); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage)); + ASSERT_TRUE(StringPrefMatches(prefs::kHomePage)); +} + +IN_PROC_BROWSER_TEST_F(TwoClientLivePreferencesSyncTest, + SingleClientEnabledEncryptionAndChangedMultipleTimes) { + ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; + ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage)); + + ChangeBooleanPref(0, prefs::kHomePageIsNewTabPage); + ASSERT_TRUE(EnableEncryption(0)); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(IsEncrypted(0)); + ASSERT_TRUE(IsEncrypted(1)); + ASSERT_TRUE(BooleanPrefMatches(prefs::kHomePageIsNewTabPage)); + + ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); + ChangeBooleanPref(0, prefs::kShowHomeButton); + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); + ASSERT_TRUE(BooleanPrefMatches(prefs::kShowHomeButton)); +} |