Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: chrome/browser/search/instant_service_unittest.cc

Issue 272573004: Handle TemplateURLService load failure better, and make some test correctness fixes that will be ne… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase after revert / presubmit fixes. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/search/instant_service_observer.cc ('k') | chrome/browser/search/instant_unittest_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/instant_service_unittest.cc
diff --git a/chrome/browser/search/instant_service_unittest.cc b/chrome/browser/search/instant_service_unittest.cc
index 0e9135cbc24b4d64a626ce5a0bd9b384442e6ad0..760bb584f85ef257cdc459b1bf0507da85fc093f 100644
--- a/chrome/browser/search/instant_service_unittest.cc
+++ b/chrome/browser/search/instant_service_unittest.cc
@@ -29,7 +29,6 @@
class MockInstantServiceObserver : public InstantServiceObserver {
public:
MOCK_METHOD0(DefaultSearchProviderChanged, void());
- MOCK_METHOD0(GoogleURLUpdated, void());
MOCK_METHOD1(OmniboxStartMarginChanged, void(int));
};
@@ -58,24 +57,45 @@ class InstantServiceTest : public InstantUnitTestBase {
scoped_ptr<MockInstantServiceObserver> instant_service_observer_;
};
-TEST_F(InstantServiceTest, DispatchDefaultSearchProviderChanged) {
+class InstantServiceEnabledTest : public InstantServiceTest {
+ protected:
+ virtual void SetUp() OVERRIDE {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "EmbeddedSearch", "Group1 use_cacheable_ntp:1 prefetch_results:1"));
+ InstantServiceTest::SetUp();
+ }
+};
+
+TEST_F(InstantServiceEnabledTest, DispatchDefaultSearchProviderChanged) {
EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged())
.Times(1);
- const std::string& new_base_url = "https://bar.com/";
+ const std::string new_base_url = "https://bar.com/";
SetUserSelectedDefaultSearchProvider(new_base_url);
}
+TEST_F(InstantServiceTest, DontDispatchGoogleURLUpdatedForNonGoogleURLs) {
+ EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged())
+ .Times(1);
+ const std::string new_dsp_url = "https://bar.com/";
+ SetUserSelectedDefaultSearchProvider(new_dsp_url);
+ testing::Mock::VerifyAndClearExpectations(instant_service_observer_.get());
+
+ EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged())
+ .Times(0);
+ const std::string new_base_url = "https://www.google.es/";
+ NotifyGoogleBaseURLUpdate(new_base_url);
+}
+
TEST_F(InstantServiceTest, DispatchGoogleURLUpdated) {
- EXPECT_CALL(*instant_service_observer_.get(), GoogleURLUpdated()).Times(1);
+ EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged())
+ .Times(1);
- const std::string& new_base_url = "https://www.google.es/";
+ const std::string new_base_url = "https://www.google.es/";
NotifyGoogleBaseURLUpdate(new_base_url);
}
-TEST_F(InstantServiceTest, SendsSearchURLsToRenderer) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
- "Group1 use_cacheable_ntp:1"));
+TEST_F(InstantServiceEnabledTest, SendsSearchURLsToRenderer) {
scoped_ptr<content::MockRenderProcessHost> rph(
new content::MockRenderProcessHost(profile()));
rph->sink().ClearMessages();
@@ -102,10 +122,8 @@ TEST_F(InstantServiceTest, InstantSearchDisabled) {
GetInstantSearchPrerenderer());
}
-TEST_F(InstantServiceTest,
+TEST_F(InstantServiceEnabledTest,
ResetInstantSearchPrerenderer_DefaultProviderChanged) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 use_cacheable_ntp:1 prefetch_results:1"));
EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged())
.Times(2);
@@ -127,18 +145,15 @@ TEST_F(InstantServiceTest,
GetInstantSearchPrerenderer());
}
-TEST_F(InstantServiceTest, ResetInstantSearchPrerenderer_GoogleBaseURLUpdated) {
- ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 use_cacheable_ntp:1 prefetch_results:1"));
+TEST_F(InstantServiceEnabledTest,
+ ResetInstantSearchPrerenderer_GoogleBaseURLUpdated) {
EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged())
.Times(1);
- EXPECT_CALL(*instant_service_observer_.get(), GoogleURLUpdated()).Times(1);
- SetUserSelectedDefaultSearchProvider("https://google.com/");
InstantSearchPrerenderer* old_prerenderer = GetInstantSearchPrerenderer();
- EXPECT_NE(static_cast<InstantSearchPrerenderer*>(NULL), old_prerenderer);
+ EXPECT_TRUE(old_prerenderer != NULL);
- const std::string& new_base_url = "https://www.google.es/";
+ const std::string new_base_url = "https://www.google.es/";
NotifyGoogleBaseURLUpdate(new_base_url);
EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer());
}
« no previous file with comments | « chrome/browser/search/instant_service_observer.cc ('k') | chrome/browser/search/instant_unittest_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698