| 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" |
| 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/search/instant_service.h" | 12 #include "chrome/browser/search/instant_service.h" |
| 12 #include "chrome/browser/search/instant_service_observer.h" | 13 #include "chrome/browser/search/instant_service_observer.h" |
| 13 #include "chrome/browser/search/instant_unittest_base.h" | 14 #include "chrome/browser/search/instant_unittest_base.h" |
| 14 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
| 15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/host_desktop.h" | 18 #include "chrome/browser/ui/host_desktop.h" |
| 18 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 19 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 19 #include "chrome/common/render_messages.h" | 20 #include "chrome/common/render_messages.h" |
| 20 #include "components/variations/entropy_provider.h" | 21 #include "components/variations/entropy_provider.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 GetInstantSearchPrerenderer()); | 122 GetInstantSearchPrerenderer()); |
| 122 } | 123 } |
| 123 | 124 |
| 124 TEST_F(InstantServiceEnabledTest, | 125 TEST_F(InstantServiceEnabledTest, |
| 125 ResetInstantSearchPrerenderer_DefaultProviderChanged) { | 126 ResetInstantSearchPrerenderer_DefaultProviderChanged) { |
| 126 EXPECT_CALL(*instant_service_observer_.get(), | 127 EXPECT_CALL(*instant_service_observer_.get(), |
| 127 DefaultSearchProviderChanged(false)).Times(2); | 128 DefaultSearchProviderChanged(false)).Times(2); |
| 128 | 129 |
| 129 // Set a default search provider that doesn't support Instant. | 130 // Set a default search provider that doesn't support Instant. |
| 130 TemplateURLData data; | 131 TemplateURLData data; |
| 132 data.SetShortName(base::ASCIIToUTF16("foobar.com")); |
| 131 data.SetURL("https://foobar.com/url?bar={searchTerms}"); | 133 data.SetURL("https://foobar.com/url?bar={searchTerms}"); |
| 132 TemplateURL* template_url = new TemplateURL(data); | 134 TemplateURL* template_url = new TemplateURL(data); |
| 133 // Takes ownership of |template_url|. | 135 // Takes ownership of |template_url|. |
| 134 template_url_service_->Add(template_url); | 136 template_url_service_->Add(template_url); |
| 135 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); | 137 template_url_service_->SetUserSelectedDefaultSearchProvider(template_url); |
| 136 | 138 |
| 137 EXPECT_EQ(static_cast<InstantSearchPrerenderer*>(NULL), | 139 EXPECT_EQ(static_cast<InstantSearchPrerenderer*>(NULL), |
| 138 GetInstantSearchPrerenderer()); | 140 GetInstantSearchPrerenderer()); |
| 139 | 141 |
| 140 // Set a default search provider that supports Instant and make sure | 142 // Set a default search provider that supports Instant and make sure |
| (...skipping 15 matching lines...) Expand all Loading... |
| 156 NotifyGoogleBaseURLUpdate(new_base_url); | 158 NotifyGoogleBaseURLUpdate(new_base_url); |
| 157 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); | 159 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); |
| 158 } | 160 } |
| 159 | 161 |
| 160 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) { | 162 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) { |
| 161 int new_start_margin = 92; | 163 int new_start_margin = 92; |
| 162 EXPECT_CALL(*instant_service_observer_.get(), | 164 EXPECT_CALL(*instant_service_observer_.get(), |
| 163 OmniboxStartMarginChanged(new_start_margin)).Times(1); | 165 OmniboxStartMarginChanged(new_start_margin)).Times(1); |
| 164 UpdateOmniboxStartMargin(new_start_margin); | 166 UpdateOmniboxStartMargin(new_start_margin); |
| 165 } | 167 } |
| OLD | NEW |