| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 instant_service_->OnOmniboxStartMarginChanged(start_margin); | 54 instant_service_->OnOmniboxStartMarginChanged(start_margin); |
| 55 } | 55 } |
| 56 | 56 |
| 57 scoped_ptr<MockInstantServiceObserver> instant_service_observer_; | 57 scoped_ptr<MockInstantServiceObserver> instant_service_observer_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class InstantServiceEnabledTest : public InstantServiceTest { | 60 class InstantServiceEnabledTest : public InstantServiceTest { |
| 61 protected: | 61 protected: |
| 62 virtual void SetUp() OVERRIDE { | 62 virtual void SetUp() OVERRIDE { |
| 63 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 63 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 64 "EmbeddedSearch", "Group1 use_cacheable_ntp:1 prefetch_results:1")); | 64 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); |
| 65 InstantServiceTest::SetUp(); | 65 InstantServiceTest::SetUp(); |
| 66 } | 66 } |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 TEST_F(InstantServiceEnabledTest, DispatchDefaultSearchProviderChanged) { | 69 TEST_F(InstantServiceEnabledTest, DispatchDefaultSearchProviderChanged) { |
| 70 EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged()) | 70 EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged()) |
| 71 .Times(1); | 71 .Times(1); |
| 72 | 72 |
| 73 const std::string new_base_url = "https://bar.com/"; | 73 const std::string new_base_url = "https://bar.com/"; |
| 74 SetUserSelectedDefaultSearchProvider(new_base_url); | 74 SetUserSelectedDefaultSearchProvider(new_base_url); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ChromeViewMsg_SetSearchURLs::Param params; | 109 ChromeViewMsg_SetSearchURLs::Param params; |
| 110 ChromeViewMsg_SetSearchURLs::Read(msg, ¶ms); | 110 ChromeViewMsg_SetSearchURLs::Read(msg, ¶ms); |
| 111 std::vector<GURL> search_urls = params.a; | 111 std::vector<GURL> search_urls = params.a; |
| 112 GURL new_tab_page_url = params.b; | 112 GURL new_tab_page_url = params.b; |
| 113 EXPECT_EQ(2U, search_urls.size()); | 113 EXPECT_EQ(2U, search_urls.size()); |
| 114 EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec()); | 114 EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec()); |
| 115 EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec()); | 115 EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec()); |
| 116 EXPECT_EQ("https://www.google.com/newtab", new_tab_page_url.spec()); | 116 EXPECT_EQ("https://www.google.com/newtab", new_tab_page_url.spec()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 TEST_F(InstantServiceTest, InstantSearchDisabled) { | 119 TEST_F(InstantServiceTest, InstantSearchEnabled) { |
| 120 // 'prefetch_results' flag is not enabled in field trials. Make sure | 120 EXPECT_NE(static_cast<InstantSearchPrerenderer*>(NULL), |
| 121 // InstantSearchPrerenderer is not initialized. | |
| 122 EXPECT_EQ(static_cast<InstantSearchPrerenderer*>(NULL), | |
| 123 GetInstantSearchPrerenderer()); | 121 GetInstantSearchPrerenderer()); |
| 124 } | 122 } |
| 125 | 123 |
| 126 TEST_F(InstantServiceEnabledTest, | 124 TEST_F(InstantServiceEnabledTest, |
| 127 ResetInstantSearchPrerenderer_DefaultProviderChanged) { | 125 ResetInstantSearchPrerenderer_DefaultProviderChanged) { |
| 128 EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged()) | 126 EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged()) |
| 129 .Times(2); | 127 .Times(2); |
| 130 | 128 |
| 131 // Set a default search provider that doesn't support Instant. | 129 // Set a default search provider that doesn't support Instant. |
| 132 TemplateURLData data; | 130 TemplateURLData data; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 158 NotifyGoogleBaseURLUpdate(new_base_url); | 156 NotifyGoogleBaseURLUpdate(new_base_url); |
| 159 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); | 157 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); |
| 160 } | 158 } |
| 161 | 159 |
| 162 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) { | 160 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) { |
| 163 int new_start_margin = 92; | 161 int new_start_margin = 92; |
| 164 EXPECT_CALL(*instant_service_observer_.get(), | 162 EXPECT_CALL(*instant_service_observer_.get(), |
| 165 OmniboxStartMarginChanged(new_start_margin)).Times(1); | 163 OmniboxStartMarginChanged(new_start_margin)).Times(1); |
| 166 UpdateOmniboxStartMargin(new_start_margin); | 164 UpdateOmniboxStartMargin(new_start_margin); |
| 167 } | 165 } |
| OLD | NEW |