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

Side by Side Diff: chrome/browser/ui/search/search_ipc_router_unittest.cc

Issue 24940002: Send ChromeViewMsg_SearchBoxSetSuggestionToPrefetch IPC message from SearchIPCRouter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 2 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 | Annotate | Revision Log
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 "chrome/browser/ui/search/search_ipc_router.h" 5 #include "chrome/browser/ui/search/search_ipc_router.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 23 matching lines...) Expand all
34 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); 34 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant));
35 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search)); 35 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search));
36 }; 36 };
37 37
38 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy { 38 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
39 public: 39 public:
40 virtual ~MockSearchIPCRouterPolicy() {} 40 virtual ~MockSearchIPCRouterPolicy() {}
41 41
42 MOCK_METHOD0(ShouldProcessSetVoiceSearchSupport, bool()); 42 MOCK_METHOD0(ShouldProcessSetVoiceSearchSupport, bool());
43 MOCK_METHOD0(ShouldSendSetDisplayInstantResults, bool()); 43 MOCK_METHOD0(ShouldSendSetDisplayInstantResults, bool());
44 MOCK_METHOD0(ShouldSendSetSuggestionToPrefetch, bool());
44 MOCK_METHOD0(ShouldSendMostVisitedItems, bool()); 45 MOCK_METHOD0(ShouldSendMostVisitedItems, bool());
45 MOCK_METHOD0(ShouldSendThemeBackgroundInfo, bool()); 46 MOCK_METHOD0(ShouldSendThemeBackgroundInfo, bool());
46 }; 47 };
47 48
48 } // namespace 49 } // namespace
49 50
50 class SearchIPCRouterTest : public ChromeRenderViewHostTestHarness { 51 class SearchIPCRouterTest : public ChromeRenderViewHostTestHarness {
51 public: 52 public:
52 virtual void SetUp() { 53 virtual void SetUp() {
53 CommandLine::ForCurrentProcess()->AppendSwitch( 54 CommandLine::ForCurrentProcess()->AppendSwitch(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 MockSearchIPCRouterPolicy* policy = 155 MockSearchIPCRouterPolicy* policy =
155 GetSearchIPCRouterPolicy(web_contents()); 156 GetSearchIPCRouterPolicy(web_contents());
156 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) 157 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1)
157 .WillOnce(testing::Return(false)); 158 .WillOnce(testing::Return(false));
158 159
159 GetSearchTabHelper(web_contents())->ipc_router().SetDisplayInstantResults(); 160 GetSearchTabHelper(web_contents())->ipc_router().SetDisplayInstantResults();
160 ASSERT_FALSE(MessageWasSent( 161 ASSERT_FALSE(MessageWasSent(
161 ChromeViewMsg_SearchBoxSetDisplayInstantResults::ID)); 162 ChromeViewMsg_SearchBoxSetDisplayInstantResults::ID));
162 } 163 }
163 164
165 TEST_F(SearchIPCRouterTest, SendSetSuggestionToPrefetch) {
166 NavigateAndCommit(GURL("chrome-search://foo/bar"));
167 process()->sink().ClearMessages();
168
169 SetupMockDelegateAndPolicy(web_contents());
170 MockSearchIPCRouterPolicy* policy =
171 GetSearchIPCRouterPolicy(web_contents());
172 EXPECT_CALL(*policy, ShouldSendSetSuggestionToPrefetch()).Times(1)
173 .WillOnce(testing::Return(true));
174
175 GetSearchTabHelper(web_contents())->SetSuggestionToPrefetch(
176 InstantSuggestion());
177 ASSERT_TRUE(MessageWasSent(
178 ChromeViewMsg_SearchBoxSetSuggestionToPrefetch::ID));
179 }
180
181 TEST_F(SearchIPCRouterTest, DoNotSendSetSuggestionToPrefetch) {
182 NavigateAndCommit(GURL("chrome-search://foo/bar"));
183 process()->sink().ClearMessages();
184
185 SetupMockDelegateAndPolicy(web_contents());
186 MockSearchIPCRouterPolicy* policy =
187 GetSearchIPCRouterPolicy(web_contents());
188 EXPECT_CALL(*policy, ShouldSendSetSuggestionToPrefetch()).Times(1)
189 .WillOnce(testing::Return(false));
190
191 GetSearchTabHelper(web_contents())->SetSuggestionToPrefetch(
192 InstantSuggestion());
193 ASSERT_FALSE(MessageWasSent(
194 ChromeViewMsg_SearchBoxSetSuggestionToPrefetch::ID));
195 }
196
164 TEST_F(SearchIPCRouterTest, SendMostVisitedItemsMsg) { 197 TEST_F(SearchIPCRouterTest, SendMostVisitedItemsMsg) {
165 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); 198 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
166 process()->sink().ClearMessages(); 199 process()->sink().ClearMessages();
167 200
168 SetupMockDelegateAndPolicy(web_contents()); 201 SetupMockDelegateAndPolicy(web_contents());
169 MockSearchIPCRouterPolicy* policy = 202 MockSearchIPCRouterPolicy* policy =
170 GetSearchIPCRouterPolicy(web_contents()); 203 GetSearchIPCRouterPolicy(web_contents());
171 EXPECT_CALL(*policy, ShouldSendMostVisitedItems()).Times(1) 204 EXPECT_CALL(*policy, ShouldSendMostVisitedItems()).Times(1)
172 .WillOnce(testing::Return(true)); 205 .WillOnce(testing::Return(true));
173 206
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 SetupMockDelegateAndPolicy(web_contents()); 248 SetupMockDelegateAndPolicy(web_contents());
216 MockSearchIPCRouterPolicy* policy = 249 MockSearchIPCRouterPolicy* policy =
217 GetSearchIPCRouterPolicy(web_contents()); 250 GetSearchIPCRouterPolicy(web_contents());
218 EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo()).Times(1) 251 EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo()).Times(1)
219 .WillOnce(testing::Return(false)); 252 .WillOnce(testing::Return(false));
220 253
221 GetSearchTabHelper(web_contents())->ipc_router().SendThemeBackgroundInfo( 254 GetSearchTabHelper(web_contents())->ipc_router().SendThemeBackgroundInfo(
222 ThemeBackgroundInfo()); 255 ThemeBackgroundInfo());
223 ASSERT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxThemeChanged::ID)); 256 ASSERT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxThemeChanged::ID));
224 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698