summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 18:47:49 +0000
committerstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 18:47:49 +0000
commitc83995c4bf72ffbeed8007be4b4311bd256e415f (patch)
treee5c533a0a92239175a826a1ed4b8d2a3e3df0b6e
parent3f0855c54a2c4bb6694b378c08b3ba9e8ad0d6ee (diff)
downloadchromium_src-c83995c4bf72ffbeed8007be4b4311bd256e415f.zip
chromium_src-c83995c4bf72ffbeed8007be4b4311bd256e415f.tar.gz
chromium_src-c83995c4bf72ffbeed8007be4b4311bd256e415f.tar.bz2
Add TwoClient tests for search engines data type, covering all P0 test cases. Updated SingleClient tests with new helper.
BUG=None TEST=Ensure all sync integration tests pass. Review URL: http://codereview.chromium.org/8035005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102983 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/sync/test/integration/search_engines_helper.cc44
-rw-r--r--chrome/browser/sync/test/integration/search_engines_helper.h17
-rw-r--r--chrome/browser/sync/test/integration/single_client_search_engines_sync_test.cc6
-rw-r--r--chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc121
-rw-r--r--chrome/chrome_tests.gypi1
5 files changed, 185 insertions, 4 deletions
diff --git a/chrome/browser/sync/test/integration/search_engines_helper.cc b/chrome/browser/sync/test/integration/search_engines_helper.cc
index 45a49d6..95a9fc7 100644
--- a/chrome/browser/sync/test/integration/search_engines_helper.cc
+++ b/chrome/browser/sync/test/integration/search_engines_helper.cc
@@ -170,4 +170,48 @@ TemplateURL* CreateTestTemplateURL(int seed) {
return turl;
}
+void AddSearchEngine(int profile, int seed) {
+ GetServiceForProfile(profile)->Add(CreateTestTemplateURL(seed));
+ if (test()->use_verifier())
+ GetVerifierService()->Add(CreateTestTemplateURL(seed));
+}
+
+void EditSearchEngine(int profile,
+ const std::string& keyword,
+ const std::string& short_name,
+ const std::string& new_keyword,
+ const std::string& url) {
+ const TemplateURL* turl = GetServiceForProfile(profile)->
+ GetTemplateURLForKeyword(ASCIIToUTF16(keyword));
+ EXPECT_TRUE(turl);
+ GetServiceForProfile(profile)->ResetTemplateURL(turl,
+ ASCIIToUTF16(short_name),
+ ASCIIToUTF16(new_keyword),
+ url);
+ // Make sure we do the same on the verifier.
+ if (test()->use_verifier()) {
+ const TemplateURL* verifier_turl =
+ GetVerifierService()->GetTemplateURLForKeyword(ASCIIToUTF16(keyword));
+ EXPECT_TRUE(verifier_turl);
+ GetVerifierService()->ResetTemplateURL(verifier_turl,
+ ASCIIToUTF16(short_name),
+ ASCIIToUTF16(new_keyword),
+ url);
+ }
+}
+
+void DeleteSearchEngine(int profile, const std::string& keyword) {
+ const TemplateURL* turl = GetServiceForProfile(profile)->
+ GetTemplateURLForKeyword(ASCIIToUTF16(keyword));
+ EXPECT_TRUE(turl);
+ GetServiceForProfile(profile)->Remove(turl);
+ // Make sure we do the same on the verifier.
+ if (test()->use_verifier()) {
+ const TemplateURL* verifier_turl =
+ GetVerifierService()->GetTemplateURLForKeyword(ASCIIToUTF16(keyword));
+ EXPECT_TRUE(verifier_turl);
+ GetVerifierService()->Remove(verifier_turl);
+ }
+}
+
} // namespace search_engines_helper
diff --git a/chrome/browser/sync/test/integration/search_engines_helper.h b/chrome/browser/sync/test/integration/search_engines_helper.h
index dc620b6..75acc4b 100644
--- a/chrome/browser/sync/test/integration/search_engines_helper.h
+++ b/chrome/browser/sync/test/integration/search_engines_helper.h
@@ -44,6 +44,23 @@ bool AllServicesMatch();
// the returned TemplateURL*.
TemplateURL* CreateTestTemplateURL(int seed);
+// Add a search engine based on a seed to the service at index |profile| and the
+// verifier if it is used.
+void AddSearchEngine(int profile, int seed);
+
+// Retrieves a search engine from the service at index |profile| with original
+// keyword |keyword| and changes its user-visible fields. Does the same to the
+// verifier, if it is used.
+void EditSearchEngine(int profile,
+ const std::string& keyword,
+ const std::string& short_name,
+ const std::string& new_keyword,
+ const std::string& url);
+
+// Deletes a search engine from the service at index |profile| with original
+// keyword |keyword|. Does the same to the verifier, if it is used.
+void DeleteSearchEngine(int profile, const std::string& keyword);
+
} // namespace search_engines_helper
#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_
diff --git a/chrome/browser/sync/test/integration/single_client_search_engines_sync_test.cc b/chrome/browser/sync/test/integration/single_client_search_engines_sync_test.cc
index 1351a53..ef56143 100644
--- a/chrome/browser/sync/test/integration/single_client_search_engines_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_search_engines_sync_test.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/sync/test/integration/search_engines_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
+using search_engines_helper::AddSearchEngine;
using search_engines_helper::CreateTestTemplateURL;
using search_engines_helper::GetServiceForProfile;
using search_engines_helper::GetVerifierService;
@@ -25,10 +26,7 @@ IN_PROC_BROWSER_TEST_F(SingleClientSearchEnginesSyncTest, Sanity) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(ServiceMatchesVerifier(0));
- // TODO(stevet): Write a helper that adds a new search engine entry to both
- // the verifier and a particular profile.
- GetServiceForProfile(0)->Add(CreateTestTemplateURL(0));
- GetVerifierService()->Add(CreateTestTemplateURL(0));
+ AddSearchEngine(0, 0);
ASSERT_TRUE(GetClient(0)->AwaitSyncCycleCompletion(
"Waiting for search engines to update."));
diff --git a/chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc b/chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc
new file mode 100644
index 0000000..b0db01f
--- /dev/null
+++ b/chrome/browser/sync/test/integration/two_client_search_engines_sync_test.cc
@@ -0,0 +1,121 @@
+// Copyright (c) 2011 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/utf_string_conversions.h"
+#include "chrome/browser/search_engines/template_url.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/sync/profile_sync_service_harness.h"
+#include "chrome/browser/sync/test/integration/search_engines_helper.h"
+#include "chrome/browser/sync/test/integration/sync_test.h"
+
+using search_engines_helper::AddSearchEngine;
+using search_engines_helper::AllServicesMatch;
+using search_engines_helper::CreateTestTemplateURL;
+using search_engines_helper::DeleteSearchEngine;
+using search_engines_helper::EditSearchEngine;
+using search_engines_helper::GetServiceForProfile;
+using search_engines_helper::GetVerifierService;
+using search_engines_helper::ServiceMatchesVerifier;
+
+class TwoClientSearchEnginesSyncTest : public SyncTest {
+ public:
+ TwoClientSearchEnginesSyncTest() : SyncTest(TWO_CLIENT) {}
+ virtual ~TwoClientSearchEnginesSyncTest() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TwoClientSearchEnginesSyncTest);
+};
+
+// TCM ID - 8898628.
+IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, Add) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AllServicesMatch());
+
+ AddSearchEngine(0, 0);
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+}
+
+// TCM ID - 8912240.
+IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, AddMultiple) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AllServicesMatch());
+
+ // Add a few entries.
+ for (int i = 0; i < 3; ++i) {
+ AddSearchEngine(0, i);
+ }
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+}
+
+// TCM ID - 9004201.
+IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, UpdateKeyword) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AllServicesMatch());
+
+ AddSearchEngine(0, 0);
+
+ // Change the keyword.
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+
+ EditSearchEngine(0, "test0", "newkeyword", "test0", "http://www.test0.com/");
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+}
+
+// TCM ID - 8894859.
+IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, UpdateUrl) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AllServicesMatch());
+
+ AddSearchEngine(0, 0);
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+
+ // Change the URL.
+ EditSearchEngine(0, "test0", "test0", "test0",
+ "http://www.wikipedia.org/q=%s");
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+}
+
+// TCM ID - 8898660.
+IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, Delete) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ ASSERT_TRUE(AllServicesMatch());
+
+ AddSearchEngine(0, 0);
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+
+ DeleteSearchEngine(0, "test0");
+
+ ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ ASSERT_TRUE(AllServicesMatch());
+}
+
+// TCM ID - 8906436.
+IN_PROC_BROWSER_TEST_F(TwoClientSearchEnginesSyncTest, DisableSync) {
+ ASSERT_TRUE(SetupSync());
+ ASSERT_TRUE(AllServicesMatch());
+
+ ASSERT_TRUE(GetClient(1)->DisableSyncForAllDatatypes());
+ AddSearchEngine(0, 0);
+ ASSERT_TRUE(
+ GetClient(0)->AwaitSyncCycleCompletion("Added a search engine."));
+ ASSERT_TRUE(ServiceMatchesVerifier(0));
+ ASSERT_FALSE(ServiceMatchesVerifier(1));
+
+ ASSERT_TRUE(GetClient(1)->EnableSyncForAllDatatypes());
+ ASSERT_TRUE(AwaitQuiescence());
+ ASSERT_TRUE(AllServicesMatch());
+}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 77e53aa..210c514 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -3158,6 +3158,7 @@
'browser/sync/test/integration/two_client_extensions_sync_test.cc',
'browser/sync/test/integration/two_client_passwords_sync_test.cc',
'browser/sync/test/integration/two_client_preferences_sync_test.cc',
+ 'browser/sync/test/integration/two_client_search_engines_sync_test.cc',
'browser/sync/test/integration/two_client_sessions_sync_test.cc',
'browser/sync/test/integration/two_client_themes_sync_test.cc',
'browser/sync/test/integration/two_client_typed_urls_sync_test.cc',