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

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

Issue 2796643002: NTP: Record TileType metrics also on desktop (Closed)
Patch Set: review Created 3 years, 8 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 "chrome/browser/ui/search/search_ipc_router.h" 5 #include "chrome/browser/ui/search/search_ipc_router.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <tuple> 10 #include <tuple>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 public: 52 public:
53 virtual ~MockSearchIPCRouterDelegate() {} 53 virtual ~MockSearchIPCRouterDelegate() {}
54 54
55 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); 55 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant));
56 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state)); 56 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state));
57 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url)); 57 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url));
58 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url)); 58 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url));
59 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void()); 59 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void());
60 MOCK_METHOD2(OnLogEvent, void(NTPLoggingEventType event, 60 MOCK_METHOD2(OnLogEvent, void(NTPLoggingEventType event,
61 base::TimeDelta time)); 61 base::TimeDelta time));
62 MOCK_METHOD2(OnLogMostVisitedImpression, 62 MOCK_METHOD3(OnLogMostVisitedImpression,
63 void(int position, ntp_tiles::TileSource tile_source)); 63 void(int position,
64 MOCK_METHOD2(OnLogMostVisitedNavigation, 64 ntp_tiles::TileSource tile_source,
65 void(int position, ntp_tiles::TileSource tile_source)); 65 ntp_tiles::TileVisualType tile_type));
66 MOCK_METHOD3(OnLogMostVisitedNavigation,
67 void(int position,
68 ntp_tiles::TileSource tile_source,
69 ntp_tiles::TileVisualType tile_type));
66 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&)); 70 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&));
67 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity)); 71 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity));
68 MOCK_METHOD0(OnHistorySyncCheck, void()); 72 MOCK_METHOD0(OnHistorySyncCheck, void());
69 }; 73 };
70 74
71 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy { 75 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
72 public: 76 public:
73 virtual ~MockSearchIPCRouterPolicy() {} 77 virtual ~MockSearchIPCRouterPolicy() {}
74 78
75 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool)); 79 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 189
186 TEST_F(SearchIPCRouterTest, ProcessFocusOmniboxMsg) { 190 TEST_F(SearchIPCRouterTest, ProcessFocusOmniboxMsg) {
187 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 191 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
188 SetupMockDelegateAndPolicy(); 192 SetupMockDelegateAndPolicy();
189 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 193 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
190 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(1); 194 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(1);
191 195
192 content::WebContents* contents = web_contents(); 196 content::WebContents* contents = web_contents();
193 bool is_active_tab = IsActiveTab(contents); 197 bool is_active_tab = IsActiveTab(contents);
194 EXPECT_TRUE(is_active_tab); 198 EXPECT_TRUE(is_active_tab);
195 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(1) 199 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab))
196 .WillOnce(testing::Return(true)); 200 .Times(1)
201 .WillOnce(Return(true));
197 202
198 GetSearchIPCRouter().FocusOmnibox(GetSearchIPCRouterSeqNo(), 203 GetSearchIPCRouter().FocusOmnibox(GetSearchIPCRouterSeqNo(),
199 OMNIBOX_FOCUS_VISIBLE); 204 OMNIBOX_FOCUS_VISIBLE);
200 } 205 }
201 206
202 TEST_F(SearchIPCRouterTest, IgnoreFocusOmniboxMsg) { 207 TEST_F(SearchIPCRouterTest, IgnoreFocusOmniboxMsg) {
203 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 208 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
204 SetupMockDelegateAndPolicy(); 209 SetupMockDelegateAndPolicy();
205 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 210 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
206 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); 211 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0);
207 212
208 content::WebContents* contents = web_contents(); 213 content::WebContents* contents = web_contents();
209 bool is_active_tab = IsActiveTab(contents); 214 bool is_active_tab = IsActiveTab(contents);
210 EXPECT_TRUE(is_active_tab); 215 EXPECT_TRUE(is_active_tab);
211 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(1) 216 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab))
212 .WillOnce(testing::Return(false)); 217 .Times(1)
218 .WillOnce(Return(false));
213 219
214 GetSearchIPCRouter().FocusOmnibox(GetSearchIPCRouterSeqNo(), 220 GetSearchIPCRouter().FocusOmnibox(GetSearchIPCRouterSeqNo(),
215 OMNIBOX_FOCUS_VISIBLE); 221 OMNIBOX_FOCUS_VISIBLE);
216 } 222 }
217 223
218 TEST_F(SearchIPCRouterTest, HandleTabChangedEvents) { 224 TEST_F(SearchIPCRouterTest, HandleTabChangedEvents) {
219 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 225 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
220 content::WebContents* contents = web_contents(); 226 content::WebContents* contents = web_contents();
221 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents(contents)); 227 EXPECT_EQ(0, browser()->tab_strip_model()->GetIndexOfWebContents(contents));
222 EXPECT_TRUE(IsActiveTab(contents)); 228 EXPECT_TRUE(IsActiveTab(contents));
(...skipping 12 matching lines...) Expand all
235 EXPECT_TRUE(IsActiveTab(contents)); 241 EXPECT_TRUE(IsActiveTab(contents));
236 } 242 }
237 243
238 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) { 244 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) {
239 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); 245 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
240 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 246 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
241 SetupMockDelegateAndPolicy(); 247 SetupMockDelegateAndPolicy();
242 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 248 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
243 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta)) 249 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta))
244 .Times(1); 250 .Times(1);
245 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 251 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1).WillOnce(Return(true));
246 .WillOnce(testing::Return(true));
247 252
248 GetSearchIPCRouter().LogEvent(GetSearchIPCRouterSeqNo(), NTP_ALL_TILES_LOADED, 253 GetSearchIPCRouter().LogEvent(GetSearchIPCRouterSeqNo(), NTP_ALL_TILES_LOADED,
249 delta); 254 delta);
250 } 255 }
251 256
252 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { 257 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) {
253 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); 258 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
254 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 259 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
255 SetupMockDelegateAndPolicy(); 260 SetupMockDelegateAndPolicy();
256 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 261 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
257 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta)) 262 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta))
258 .Times(0); 263 .Times(0);
259 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 264 EXPECT_CALL(*policy, ShouldProcessLogEvent())
260 .WillOnce(testing::Return(false)); 265 .Times(1)
266 .WillOnce(Return(false));
261 267
262 GetSearchIPCRouter().LogEvent(GetSearchIPCRouterSeqNo(), NTP_ALL_TILES_LOADED, 268 GetSearchIPCRouter().LogEvent(GetSearchIPCRouterSeqNo(), NTP_ALL_TILES_LOADED,
263 delta); 269 delta);
264 } 270 }
265 271
266 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { 272 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
267 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 273 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
268 SetupMockDelegateAndPolicy(); 274 SetupMockDelegateAndPolicy();
269 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 275 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
270 EXPECT_CALL( 276 EXPECT_CALL(
271 *mock_delegate(), 277 *mock_delegate(),
272 OnLogMostVisitedImpression(3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE)) 278 OnLogMostVisitedImpression(3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE,
279 ntp_tiles::TileVisualType::THUMBNAIL))
273 .Times(1); 280 .Times(1);
274 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 281 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1).WillOnce(Return(true));
275 .WillOnce(testing::Return(true));
276 282
277 GetSearchIPCRouter().LogMostVisitedImpression( 283 GetSearchIPCRouter().LogMostVisitedImpression(
278 GetSearchIPCRouterSeqNo(), 3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE); 284 GetSearchIPCRouterSeqNo(), 3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE,
285 ntp_tiles::TileVisualType::THUMBNAIL);
279 } 286 }
280 287
281 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) { 288 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) {
282 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 289 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
283 SetupMockDelegateAndPolicy(); 290 SetupMockDelegateAndPolicy();
284 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 291 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
285 EXPECT_CALL( 292 EXPECT_CALL(
286 *mock_delegate(), 293 *mock_delegate(),
287 OnLogMostVisitedNavigation(3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE)) 294 OnLogMostVisitedNavigation(3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE,
295 ntp_tiles::TileVisualType::THUMBNAIL))
288 .Times(1); 296 .Times(1);
289 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 297 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1).WillOnce(Return(true));
290 .WillOnce(testing::Return(true));
291 298
292 GetSearchIPCRouter().LogMostVisitedNavigation( 299 GetSearchIPCRouter().LogMostVisitedNavigation(
293 GetSearchIPCRouterSeqNo(), 3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE); 300 GetSearchIPCRouterSeqNo(), 3, ntp_tiles::TileSource::SUGGESTIONS_SERVICE,
301 ntp_tiles::TileVisualType::THUMBNAIL);
294 } 302 }
295 303
296 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) { 304 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) {
297 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 305 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
298 SetupMockDelegateAndPolicy(); 306 SetupMockDelegateAndPolicy();
299 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 307 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
300 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); 308 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com");
301 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1); 309 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1);
302 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1) 310 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck())
303 .WillOnce(testing::Return(true)); 311 .Times(1)
312 .WillOnce(Return(true));
304 313
305 GetSearchIPCRouter().ChromeIdentityCheck(GetSearchIPCRouterSeqNo(), 314 GetSearchIPCRouter().ChromeIdentityCheck(GetSearchIPCRouterSeqNo(),
306 test_identity); 315 test_identity);
307 } 316 }
308 317
309 TEST_F(SearchIPCRouterTest, IgnoreChromeIdentityCheckMsg) { 318 TEST_F(SearchIPCRouterTest, IgnoreChromeIdentityCheckMsg) {
310 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 319 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
311 SetupMockDelegateAndPolicy(); 320 SetupMockDelegateAndPolicy();
312 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 321 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
313 322
314 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); 323 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com");
315 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(0); 324 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(0);
316 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1) 325 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck())
317 .WillOnce(testing::Return(false)); 326 .Times(1)
327 .WillOnce(Return(false));
318 328
319 GetSearchIPCRouter().ChromeIdentityCheck(GetSearchIPCRouterSeqNo(), 329 GetSearchIPCRouter().ChromeIdentityCheck(GetSearchIPCRouterSeqNo(),
320 test_identity); 330 test_identity);
321 } 331 }
322 332
323 TEST_F(SearchIPCRouterTest, ProcessHistorySyncCheckMsg) { 333 TEST_F(SearchIPCRouterTest, ProcessHistorySyncCheckMsg) {
324 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 334 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
325 SetupMockDelegateAndPolicy(); 335 SetupMockDelegateAndPolicy();
326 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 336 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
327 EXPECT_CALL(*mock_delegate(), OnHistorySyncCheck()).Times(1); 337 EXPECT_CALL(*mock_delegate(), OnHistorySyncCheck()).Times(1);
328 EXPECT_CALL(*policy, ShouldProcessHistorySyncCheck()).Times(1) 338 EXPECT_CALL(*policy, ShouldProcessHistorySyncCheck())
329 .WillOnce(testing::Return(true)); 339 .Times(1)
340 .WillOnce(Return(true));
330 341
331 GetSearchIPCRouter().HistorySyncCheck(GetSearchIPCRouterSeqNo()); 342 GetSearchIPCRouter().HistorySyncCheck(GetSearchIPCRouterSeqNo());
332 } 343 }
333 344
334 TEST_F(SearchIPCRouterTest, IgnoreHistorySyncCheckMsg) { 345 TEST_F(SearchIPCRouterTest, IgnoreHistorySyncCheckMsg) {
335 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 346 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
336 SetupMockDelegateAndPolicy(); 347 SetupMockDelegateAndPolicy();
337 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 348 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
338 349
339 EXPECT_CALL(*mock_delegate(), OnHistorySyncCheck()).Times(0); 350 EXPECT_CALL(*mock_delegate(), OnHistorySyncCheck()).Times(0);
340 EXPECT_CALL(*policy, ShouldProcessHistorySyncCheck()).Times(1) 351 EXPECT_CALL(*policy, ShouldProcessHistorySyncCheck())
341 .WillOnce(testing::Return(false)); 352 .Times(1)
353 .WillOnce(Return(false));
342 354
343 GetSearchIPCRouter().HistorySyncCheck(GetSearchIPCRouterSeqNo()); 355 GetSearchIPCRouter().HistorySyncCheck(GetSearchIPCRouterSeqNo());
344 } 356 }
345 357
346 TEST_F(SearchIPCRouterTest, ProcessDeleteMostVisitedItemMsg) { 358 TEST_F(SearchIPCRouterTest, ProcessDeleteMostVisitedItemMsg) {
347 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 359 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
348 SetupMockDelegateAndPolicy(); 360 SetupMockDelegateAndPolicy();
349 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 361 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
350 GURL item_url("www.foo.com"); 362 GURL item_url("www.foo.com");
351 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(1); 363 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(1);
352 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(1) 364 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem())
353 .WillOnce(testing::Return(true)); 365 .Times(1)
366 .WillOnce(Return(true));
354 367
355 GetSearchIPCRouter().DeleteMostVisitedItem(GetSearchIPCRouterSeqNo(), 368 GetSearchIPCRouter().DeleteMostVisitedItem(GetSearchIPCRouterSeqNo(),
356 item_url); 369 item_url);
357 } 370 }
358 371
359 TEST_F(SearchIPCRouterTest, IgnoreDeleteMostVisitedItemMsg) { 372 TEST_F(SearchIPCRouterTest, IgnoreDeleteMostVisitedItemMsg) {
360 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 373 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
361 SetupMockDelegateAndPolicy(); 374 SetupMockDelegateAndPolicy();
362 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 375 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
363 GURL item_url("www.foo.com"); 376 GURL item_url("www.foo.com");
364 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(0); 377 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(0);
365 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(1) 378 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem())
366 .WillOnce(testing::Return(false)); 379 .Times(1)
380 .WillOnce(Return(false));
367 381
368 GetSearchIPCRouter().DeleteMostVisitedItem(GetSearchIPCRouterSeqNo(), 382 GetSearchIPCRouter().DeleteMostVisitedItem(GetSearchIPCRouterSeqNo(),
369 item_url); 383 item_url);
370 } 384 }
371 385
372 TEST_F(SearchIPCRouterTest, ProcessUndoMostVisitedDeletionMsg) { 386 TEST_F(SearchIPCRouterTest, ProcessUndoMostVisitedDeletionMsg) {
373 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 387 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
374 SetupMockDelegateAndPolicy(); 388 SetupMockDelegateAndPolicy();
375 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 389 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
376 GURL item_url("www.foo.com"); 390 GURL item_url("www.foo.com");
377 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(1); 391 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(1);
378 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(1) 392 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion())
379 .WillOnce(testing::Return(true)); 393 .Times(1)
394 .WillOnce(Return(true));
380 395
381 GetSearchIPCRouter().UndoMostVisitedDeletion(GetSearchIPCRouterSeqNo(), 396 GetSearchIPCRouter().UndoMostVisitedDeletion(GetSearchIPCRouterSeqNo(),
382 item_url); 397 item_url);
383 } 398 }
384 399
385 TEST_F(SearchIPCRouterTest, IgnoreUndoMostVisitedDeletionMsg) { 400 TEST_F(SearchIPCRouterTest, IgnoreUndoMostVisitedDeletionMsg) {
386 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 401 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
387 SetupMockDelegateAndPolicy(); 402 SetupMockDelegateAndPolicy();
388 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 403 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
389 GURL item_url("www.foo.com"); 404 GURL item_url("www.foo.com");
390 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(0); 405 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(0);
391 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(1) 406 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion())
392 .WillOnce(testing::Return(false)); 407 .Times(1)
408 .WillOnce(Return(false));
393 409
394 GetSearchIPCRouter().UndoMostVisitedDeletion(GetSearchIPCRouterSeqNo(), 410 GetSearchIPCRouter().UndoMostVisitedDeletion(GetSearchIPCRouterSeqNo(),
395 item_url); 411 item_url);
396 } 412 }
397 413
398 TEST_F(SearchIPCRouterTest, ProcessUndoAllMostVisitedDeletionsMsg) { 414 TEST_F(SearchIPCRouterTest, ProcessUndoAllMostVisitedDeletionsMsg) {
399 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 415 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
400 SetupMockDelegateAndPolicy(); 416 SetupMockDelegateAndPolicy();
401 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 417 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
402 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(1); 418 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(1);
403 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(1) 419 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions())
404 .WillOnce(testing::Return(true)); 420 .Times(1)
421 .WillOnce(Return(true));
405 422
406 GetSearchIPCRouter().UndoAllMostVisitedDeletions(GetSearchIPCRouterSeqNo()); 423 GetSearchIPCRouter().UndoAllMostVisitedDeletions(GetSearchIPCRouterSeqNo());
407 } 424 }
408 425
409 TEST_F(SearchIPCRouterTest, IgnoreUndoAllMostVisitedDeletionsMsg) { 426 TEST_F(SearchIPCRouterTest, IgnoreUndoAllMostVisitedDeletionsMsg) {
410 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 427 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
411 SetupMockDelegateAndPolicy(); 428 SetupMockDelegateAndPolicy();
412 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 429 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
413 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0); 430 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0);
414 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(1) 431 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions())
415 .WillOnce(testing::Return(false)); 432 .Times(1)
433 .WillOnce(Return(false));
416 434
417 GetSearchIPCRouter().UndoAllMostVisitedDeletions(GetSearchIPCRouterSeqNo()); 435 GetSearchIPCRouter().UndoAllMostVisitedDeletions(GetSearchIPCRouterSeqNo());
418 } 436 }
419 437
420 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) { 438 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) {
421 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 439 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
422 SetupMockDelegateAndPolicy(); 440 SetupMockDelegateAndPolicy();
423 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 441 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
424 442
425 content::WebContents* contents = web_contents(); 443 content::WebContents* contents = web_contents();
426 bool is_active_tab = IsActiveTab(contents); 444 bool is_active_tab = IsActiveTab(contents);
427 EXPECT_TRUE(is_active_tab); 445 EXPECT_TRUE(is_active_tab);
428 446
429 base::string16 text; 447 base::string16 text;
430 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(1); 448 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(1);
431 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(1) 449 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab))
432 .WillOnce(testing::Return(true)); 450 .Times(1)
451 .WillOnce(Return(true));
433 GetSearchIPCRouter().PasteAndOpenDropdown(GetSearchIPCRouterSeqNo(), text); 452 GetSearchIPCRouter().PasteAndOpenDropdown(GetSearchIPCRouterSeqNo(), text);
434 } 453 }
435 454
436 TEST_F(SearchIPCRouterTest, IgnorePasteAndOpenDropdownMsg) { 455 TEST_F(SearchIPCRouterTest, IgnorePasteAndOpenDropdownMsg) {
437 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 456 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
438 SetupMockDelegateAndPolicy(); 457 SetupMockDelegateAndPolicy();
439 base::string16 text; 458 base::string16 text;
440 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); 459 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0);
441 460
442 content::WebContents* contents = web_contents(); 461 content::WebContents* contents = web_contents();
443 bool is_active_tab = IsActiveTab(contents); 462 bool is_active_tab = IsActiveTab(contents);
444 EXPECT_TRUE(is_active_tab); 463 EXPECT_TRUE(is_active_tab);
445 464
446 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 465 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
447 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(1) 466 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab))
448 .WillOnce(testing::Return(false)); 467 .Times(1)
468 .WillOnce(Return(false));
449 469
450 GetSearchIPCRouter().PasteAndOpenDropdown(GetSearchIPCRouterSeqNo(), text); 470 GetSearchIPCRouter().PasteAndOpenDropdown(GetSearchIPCRouterSeqNo(), text);
451 } 471 }
452 472
453 TEST_F(SearchIPCRouterTest, SendSetSuggestionToPrefetch) { 473 TEST_F(SearchIPCRouterTest, SendSetSuggestionToPrefetch) {
454 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 474 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
455 SetupMockDelegateAndPolicy(); 475 SetupMockDelegateAndPolicy();
456 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 476 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
457 EXPECT_CALL(*policy, ShouldSendSetSuggestionToPrefetch()).Times(1) 477 EXPECT_CALL(*policy, ShouldSendSetSuggestionToPrefetch())
458 .WillOnce(testing::Return(true)); 478 .Times(1)
479 .WillOnce(Return(true));
459 480
460 content::WebContents* contents = web_contents(); 481 content::WebContents* contents = web_contents();
461 EXPECT_CALL(*mock_search_box(), SetSuggestionToPrefetch(_)); 482 EXPECT_CALL(*mock_search_box(), SetSuggestionToPrefetch(_));
462 GetSearchTabHelper(contents)->SetSuggestionToPrefetch(InstantSuggestion()); 483 GetSearchTabHelper(contents)->SetSuggestionToPrefetch(InstantSuggestion());
463 } 484 }
464 485
465 TEST_F(SearchIPCRouterTest, DoNotSendSetSuggestionToPrefetch) { 486 TEST_F(SearchIPCRouterTest, DoNotSendSetSuggestionToPrefetch) {
466 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 487 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
467 SetupMockDelegateAndPolicy(); 488 SetupMockDelegateAndPolicy();
468 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 489 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
469 EXPECT_CALL(*policy, ShouldSendSetSuggestionToPrefetch()).Times(1) 490 EXPECT_CALL(*policy, ShouldSendSetSuggestionToPrefetch())
470 .WillOnce(testing::Return(false)); 491 .Times(1)
492 .WillOnce(Return(false));
471 493
472 content::WebContents* contents = web_contents(); 494 content::WebContents* contents = web_contents();
473 EXPECT_CALL(*mock_search_box(), SetSuggestionToPrefetch(_)).Times(0); 495 EXPECT_CALL(*mock_search_box(), SetSuggestionToPrefetch(_)).Times(0);
474 GetSearchTabHelper(contents)->SetSuggestionToPrefetch(InstantSuggestion()); 496 GetSearchTabHelper(contents)->SetSuggestionToPrefetch(InstantSuggestion());
475 } 497 }
476 498
477 TEST_F(SearchIPCRouterTest, SendOmniboxFocusChange) { 499 TEST_F(SearchIPCRouterTest, SendOmniboxFocusChange) {
478 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 500 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
479 SetupMockDelegateAndPolicy(); 501 SetupMockDelegateAndPolicy();
480 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 502 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
481 EXPECT_CALL(*policy, ShouldSendOmniboxFocusChanged()).Times(1) 503 EXPECT_CALL(*policy, ShouldSendOmniboxFocusChanged())
482 .WillOnce(testing::Return(true)); 504 .Times(1)
505 .WillOnce(Return(true));
483 506
484 EXPECT_CALL(*mock_search_box(), FocusChanged(_, _)); 507 EXPECT_CALL(*mock_search_box(), FocusChanged(_, _));
485 GetSearchIPCRouter().OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, 508 GetSearchIPCRouter().OmniboxFocusChanged(OMNIBOX_FOCUS_NONE,
486 OMNIBOX_FOCUS_CHANGE_EXPLICIT); 509 OMNIBOX_FOCUS_CHANGE_EXPLICIT);
487 } 510 }
488 511
489 TEST_F(SearchIPCRouterTest, DoNotSendOmniboxFocusChange) { 512 TEST_F(SearchIPCRouterTest, DoNotSendOmniboxFocusChange) {
490 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 513 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
491 SetupMockDelegateAndPolicy(); 514 SetupMockDelegateAndPolicy();
492 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 515 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
493 EXPECT_CALL(*policy, ShouldSendOmniboxFocusChanged()).Times(1) 516 EXPECT_CALL(*policy, ShouldSendOmniboxFocusChanged())
494 .WillOnce(testing::Return(false)); 517 .Times(1)
518 .WillOnce(Return(false));
495 519
496 EXPECT_CALL(*mock_search_box(), FocusChanged(_, _)).Times(0); 520 EXPECT_CALL(*mock_search_box(), FocusChanged(_, _)).Times(0);
497 GetSearchIPCRouter().OmniboxFocusChanged(OMNIBOX_FOCUS_NONE, 521 GetSearchIPCRouter().OmniboxFocusChanged(OMNIBOX_FOCUS_NONE,
498 OMNIBOX_FOCUS_CHANGE_EXPLICIT); 522 OMNIBOX_FOCUS_CHANGE_EXPLICIT);
499 } 523 }
500 524
501 TEST_F(SearchIPCRouterTest, SendSetInputInProgress) { 525 TEST_F(SearchIPCRouterTest, SendSetInputInProgress) {
502 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 526 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
503 SetupMockDelegateAndPolicy(); 527 SetupMockDelegateAndPolicy();
504 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 528 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
505 EXPECT_CALL(*policy, ShouldSendSetInputInProgress(true)).Times(1) 529 EXPECT_CALL(*policy, ShouldSendSetInputInProgress(true))
506 .WillOnce(testing::Return(true)); 530 .Times(1)
531 .WillOnce(Return(true));
507 532
508 EXPECT_CALL(*mock_search_box(), SetInputInProgress(_)); 533 EXPECT_CALL(*mock_search_box(), SetInputInProgress(_));
509 GetSearchIPCRouter().SetInputInProgress(true); 534 GetSearchIPCRouter().SetInputInProgress(true);
510 } 535 }
511 536
512 TEST_F(SearchIPCRouterTest, DoNotSendSetInputInProgress) { 537 TEST_F(SearchIPCRouterTest, DoNotSendSetInputInProgress) {
513 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 538 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
514 SetupMockDelegateAndPolicy(); 539 SetupMockDelegateAndPolicy();
515 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 540 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
516 EXPECT_CALL(*policy, ShouldSendSetInputInProgress(true)).Times(1) 541 EXPECT_CALL(*policy, ShouldSendSetInputInProgress(true))
517 .WillOnce(testing::Return(false)); 542 .Times(1)
543 .WillOnce(Return(false));
518 544
519 EXPECT_CALL(*mock_search_box(), SetInputInProgress(_)).Times(0); 545 EXPECT_CALL(*mock_search_box(), SetInputInProgress(_)).Times(0);
520 GetSearchIPCRouter().SetInputInProgress(true); 546 GetSearchIPCRouter().SetInputInProgress(true);
521 } 547 }
522 548
523 TEST_F(SearchIPCRouterTest, SendMostVisitedItemsMsg) { 549 TEST_F(SearchIPCRouterTest, SendMostVisitedItemsMsg) {
524 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 550 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
525 SetupMockDelegateAndPolicy(); 551 SetupMockDelegateAndPolicy();
526 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 552 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
527 EXPECT_CALL(*policy, ShouldSendMostVisitedItems()).Times(1) 553 EXPECT_CALL(*policy, ShouldSendMostVisitedItems())
528 .WillOnce(testing::Return(true)); 554 .Times(1)
555 .WillOnce(Return(true));
529 556
530 EXPECT_CALL(*mock_search_box(), MostVisitedChanged(_)); 557 EXPECT_CALL(*mock_search_box(), MostVisitedChanged(_));
531 GetSearchIPCRouter().SendMostVisitedItems( 558 GetSearchIPCRouter().SendMostVisitedItems(
532 std::vector<InstantMostVisitedItem>()); 559 std::vector<InstantMostVisitedItem>());
533 } 560 }
534 561
535 TEST_F(SearchIPCRouterTest, DoNotSendMostVisitedItemsMsg) { 562 TEST_F(SearchIPCRouterTest, DoNotSendMostVisitedItemsMsg) {
536 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 563 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
537 SetupMockDelegateAndPolicy(); 564 SetupMockDelegateAndPolicy();
538 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 565 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
539 EXPECT_CALL(*policy, ShouldSendMostVisitedItems()).Times(1) 566 EXPECT_CALL(*policy, ShouldSendMostVisitedItems())
540 .WillOnce(testing::Return(false)); 567 .Times(1)
568 .WillOnce(Return(false));
541 569
542 EXPECT_CALL(*mock_search_box(), MostVisitedChanged(_)).Times(0); 570 EXPECT_CALL(*mock_search_box(), MostVisitedChanged(_)).Times(0);
543 GetSearchIPCRouter().SendMostVisitedItems( 571 GetSearchIPCRouter().SendMostVisitedItems(
544 std::vector<InstantMostVisitedItem>()); 572 std::vector<InstantMostVisitedItem>());
545 } 573 }
546 574
547 TEST_F(SearchIPCRouterTest, SendThemeBackgroundInfoMsg) { 575 TEST_F(SearchIPCRouterTest, SendThemeBackgroundInfoMsg) {
548 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 576 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
549 SetupMockDelegateAndPolicy(); 577 SetupMockDelegateAndPolicy();
550 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 578 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
551 EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo()).Times(1) 579 EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo())
552 .WillOnce(testing::Return(true)); 580 .Times(1)
581 .WillOnce(Return(true));
553 582
554 EXPECT_CALL(*mock_search_box(), ThemeChanged(_)); 583 EXPECT_CALL(*mock_search_box(), ThemeChanged(_));
555 GetSearchIPCRouter().SendThemeBackgroundInfo(ThemeBackgroundInfo()); 584 GetSearchIPCRouter().SendThemeBackgroundInfo(ThemeBackgroundInfo());
556 } 585 }
557 586
558 TEST_F(SearchIPCRouterTest, DoNotSendThemeBackgroundInfoMsg) { 587 TEST_F(SearchIPCRouterTest, DoNotSendThemeBackgroundInfoMsg) {
559 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 588 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
560 SetupMockDelegateAndPolicy(); 589 SetupMockDelegateAndPolicy();
561 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 590 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
562 EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo()).Times(1) 591 EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo())
563 .WillOnce(testing::Return(false)); 592 .Times(1)
593 .WillOnce(Return(false));
564 594
565 EXPECT_CALL(*mock_search_box(), ThemeChanged(_)).Times(0); 595 EXPECT_CALL(*mock_search_box(), ThemeChanged(_)).Times(0);
566 GetSearchIPCRouter().SendThemeBackgroundInfo(ThemeBackgroundInfo()); 596 GetSearchIPCRouter().SendThemeBackgroundInfo(ThemeBackgroundInfo());
567 } 597 }
568 598
569 TEST_F(SearchIPCRouterTest, SendSubmitMsg) { 599 TEST_F(SearchIPCRouterTest, SendSubmitMsg) {
570 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 600 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
571 SetupMockDelegateAndPolicy(); 601 SetupMockDelegateAndPolicy();
572 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 602 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
573 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1) 603 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1).WillOnce(Return(true));
574 .WillOnce(testing::Return(true));
575 604
576 EXPECT_CALL(*mock_search_box(), Submit(_, _)); 605 EXPECT_CALL(*mock_search_box(), Submit(_, _));
577 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams()); 606 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams());
578 } 607 }
579 608
580 TEST_F(SearchIPCRouterTest, DoNotSendSubmitMsg) { 609 TEST_F(SearchIPCRouterTest, DoNotSendSubmitMsg) {
581 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 610 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
582 SetupMockDelegateAndPolicy(); 611 SetupMockDelegateAndPolicy();
583 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 612 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
584 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1) 613 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1).WillOnce(Return(false));
585 .WillOnce(testing::Return(false));
586 614
587 EXPECT_CALL(*mock_search_box(), Submit(_, _)).Times(0); 615 EXPECT_CALL(*mock_search_box(), Submit(_, _)).Times(0);
588 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams()); 616 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams());
589 } 617 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698