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

Side by Side Diff: chrome/browser/search/instant_service_unittest.cc

Issue 1543203002: Remove a variety of no-longer-used query params. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 11 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 unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
24 #include "content/public/test/mock_render_process_host.h" 24 #include "content/public/test/mock_render_process_host.h"
25 #include "ipc/ipc_message.h" 25 #include "ipc/ipc_message.h"
26 #include "ipc/ipc_test_sink.h" 26 #include "ipc/ipc_test_sink.h"
27 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
28 #include "url/gurl.h" 28 #include "url/gurl.h"
29 29
30 class MockInstantServiceObserver : public InstantServiceObserver { 30 class MockInstantServiceObserver : public InstantServiceObserver {
31 public: 31 public:
32 MOCK_METHOD1(DefaultSearchProviderChanged, void(bool)); 32 MOCK_METHOD1(DefaultSearchProviderChanged, void(bool));
33 MOCK_METHOD1(OmniboxStartMarginChanged, void(int));
34 }; 33 };
35 34
36 class InstantServiceTest : public InstantUnitTestBase { 35 class InstantServiceTest : public InstantUnitTestBase {
37 protected: 36 protected:
38 void SetUp() override { 37 void SetUp() override {
39 InstantUnitTestBase::SetUp(); 38 InstantUnitTestBase::SetUp();
40 39
41 instant_service_observer_.reset(new MockInstantServiceObserver()); 40 instant_service_observer_.reset(new MockInstantServiceObserver());
42 instant_service_->AddObserver(instant_service_observer_.get()); 41 instant_service_->AddObserver(instant_service_observer_.get());
43 } 42 }
44 43
45 void TearDown() override { 44 void TearDown() override {
46 instant_service_->RemoveObserver(instant_service_observer_.get()); 45 instant_service_->RemoveObserver(instant_service_observer_.get());
47 InstantUnitTestBase::TearDown(); 46 InstantUnitTestBase::TearDown();
48 } 47 }
49 48
50 InstantSearchPrerenderer* GetInstantSearchPrerenderer() { 49 InstantSearchPrerenderer* GetInstantSearchPrerenderer() {
51 return instant_service_->instant_search_prerenderer(); 50 return instant_service_->instant_search_prerenderer();
52 } 51 }
53 52
54 void UpdateOmniboxStartMargin(int start_margin) {
55 instant_service_->OnOmniboxStartMarginChanged(start_margin);
56 }
57
58 scoped_ptr<MockInstantServiceObserver> instant_service_observer_; 53 scoped_ptr<MockInstantServiceObserver> instant_service_observer_;
59 }; 54 };
60 55
61 class InstantServiceEnabledTest : public InstantServiceTest { 56 class InstantServiceEnabledTest : public InstantServiceTest {
62 protected: 57 protected:
63 void SetUp() override { 58 void SetUp() override {
64 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 59 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
65 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); 60 "EmbeddedSearch", "Group1 use_cacheable_ntp:1"));
66 InstantServiceTest::SetUp(); 61 InstantServiceTest::SetUp();
67 } 62 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DefaultSearchProviderChanged(true)).Times(1); 147 DefaultSearchProviderChanged(true)).Times(1);
153 148
154 InstantSearchPrerenderer* old_prerenderer = GetInstantSearchPrerenderer(); 149 InstantSearchPrerenderer* old_prerenderer = GetInstantSearchPrerenderer();
155 EXPECT_TRUE(old_prerenderer != NULL); 150 EXPECT_TRUE(old_prerenderer != NULL);
156 151
157 const std::string new_base_url = "https://www.google.es/"; 152 const std::string new_base_url = "https://www.google.es/";
158 NotifyGoogleBaseURLUpdate(new_base_url); 153 NotifyGoogleBaseURLUpdate(new_base_url);
159 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); 154 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer());
160 } 155 }
161 156
162 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) {
163 int new_start_margin = 92;
164 EXPECT_CALL(*instant_service_observer_.get(),
165 OmniboxStartMarginChanged(new_start_margin)).Times(1);
166 UpdateOmniboxStartMargin(new_start_margin);
167 }
168
169 TEST_F(InstantServiceTest, GetSuggestionFromServiceSide) { 157 TEST_F(InstantServiceTest, GetSuggestionFromServiceSide) {
170 auto profile = suggestions::SuggestionsProfile(); 158 auto profile = suggestions::SuggestionsProfile();
171 profile.add_suggestions(); 159 profile.add_suggestions();
172 160
173 instant_service_->OnSuggestionsAvailable(profile); 161 instant_service_->OnSuggestionsAvailable(profile);
174 162
175 auto items = instant_service_->suggestions_items_; 163 auto items = instant_service_->suggestions_items_;
176 ASSERT_EQ(1, (int)items.size()); 164 ASSERT_EQ(1, (int)items.size());
177 ASSERT_TRUE(items[0].is_server_side_suggestion); 165 ASSERT_TRUE(items[0].is_server_side_suggestion);
178 } 166 }
179 167
180 TEST_F(InstantServiceTest, GetSuggestionFromClientSide) { 168 TEST_F(InstantServiceTest, GetSuggestionFromClientSide) {
181 history::MostVisitedURLList url_list; 169 history::MostVisitedURLList url_list;
182 url_list.push_back(history::MostVisitedURL()); 170 url_list.push_back(history::MostVisitedURL());
183 171
184 instant_service_->OnMostVisitedItemsReceived(url_list); 172 instant_service_->OnMostVisitedItemsReceived(url_list);
185 173
186 auto items = instant_service_->most_visited_items_; 174 auto items = instant_service_->most_visited_items_;
187 ASSERT_EQ(1, (int)items.size()); 175 ASSERT_EQ(1, (int)items.size());
188 ASSERT_FALSE(items[0].is_server_side_suggestion); 176 ASSERT_FALSE(items[0].is_server_side_suggestion);
189 } 177 }
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_service_observer.cc ('k') | chrome/browser/search/instant_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698