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

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

Issue 2685863002: NTP: Rename mojo methods, fixing a TODO (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router.cc ('k') | chrome/common/instant.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 362
363 TEST_F(SearchIPCRouterTest, ProcessDeleteMostVisitedItemMsg) { 363 TEST_F(SearchIPCRouterTest, ProcessDeleteMostVisitedItemMsg) {
364 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 364 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
365 SetupMockDelegateAndPolicy(); 365 SetupMockDelegateAndPolicy();
366 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 366 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
367 GURL item_url("www.foo.com"); 367 GURL item_url("www.foo.com");
368 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(1); 368 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(1);
369 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(1) 369 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(1)
370 .WillOnce(testing::Return(true)); 370 .WillOnce(testing::Return(true));
371 371
372 GetSearchIPCRouter().SearchBoxDeleteMostVisitedItem(GetSearchIPCRouterSeqNo(), 372 GetSearchIPCRouter().DeleteMostVisitedItem(GetSearchIPCRouterSeqNo(),
373 item_url); 373 item_url);
374 } 374 }
375 375
376 TEST_F(SearchIPCRouterTest, IgnoreDeleteMostVisitedItemMsg) { 376 TEST_F(SearchIPCRouterTest, IgnoreDeleteMostVisitedItemMsg) {
377 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 377 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
378 SetupMockDelegateAndPolicy(); 378 SetupMockDelegateAndPolicy();
379 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 379 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
380 GURL item_url("www.foo.com"); 380 GURL item_url("www.foo.com");
381 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(0); 381 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(0);
382 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(1) 382 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(1)
383 .WillOnce(testing::Return(false)); 383 .WillOnce(testing::Return(false));
384 384
385 GetSearchIPCRouter().SearchBoxDeleteMostVisitedItem(GetSearchIPCRouterSeqNo(), 385 GetSearchIPCRouter().DeleteMostVisitedItem(GetSearchIPCRouterSeqNo(),
386 item_url); 386 item_url);
387 } 387 }
388 388
389 TEST_F(SearchIPCRouterTest, ProcessUndoMostVisitedDeletionMsg) { 389 TEST_F(SearchIPCRouterTest, ProcessUndoMostVisitedDeletionMsg) {
390 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 390 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
391 SetupMockDelegateAndPolicy(); 391 SetupMockDelegateAndPolicy();
392 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 392 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
393 GURL item_url("www.foo.com"); 393 GURL item_url("www.foo.com");
394 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(1); 394 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(1);
395 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(1) 395 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(1)
396 .WillOnce(testing::Return(true)); 396 .WillOnce(testing::Return(true));
397 397
398 GetSearchIPCRouter().SearchBoxUndoMostVisitedDeletion( 398 GetSearchIPCRouter().UndoMostVisitedDeletion(GetSearchIPCRouterSeqNo(),
399 GetSearchIPCRouterSeqNo(), item_url); 399 item_url);
400 } 400 }
401 401
402 TEST_F(SearchIPCRouterTest, IgnoreUndoMostVisitedDeletionMsg) { 402 TEST_F(SearchIPCRouterTest, IgnoreUndoMostVisitedDeletionMsg) {
403 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 403 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
404 SetupMockDelegateAndPolicy(); 404 SetupMockDelegateAndPolicy();
405 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 405 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
406 GURL item_url("www.foo.com"); 406 GURL item_url("www.foo.com");
407 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(0); 407 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(0);
408 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(1) 408 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(1)
409 .WillOnce(testing::Return(false)); 409 .WillOnce(testing::Return(false));
410 410
411 GetSearchIPCRouter().SearchBoxUndoMostVisitedDeletion( 411 GetSearchIPCRouter().UndoMostVisitedDeletion(GetSearchIPCRouterSeqNo(),
412 GetSearchIPCRouterSeqNo(), item_url); 412 item_url);
413 } 413 }
414 414
415 TEST_F(SearchIPCRouterTest, ProcessUndoAllMostVisitedDeletionsMsg) { 415 TEST_F(SearchIPCRouterTest, ProcessUndoAllMostVisitedDeletionsMsg) {
416 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 416 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
417 SetupMockDelegateAndPolicy(); 417 SetupMockDelegateAndPolicy();
418 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 418 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
419 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(1); 419 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(1);
420 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(1) 420 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(1)
421 .WillOnce(testing::Return(true)); 421 .WillOnce(testing::Return(true));
422 422
423 GetSearchIPCRouter().SearchBoxUndoAllMostVisitedDeletions( 423 GetSearchIPCRouter().UndoAllMostVisitedDeletions(GetSearchIPCRouterSeqNo());
424 GetSearchIPCRouterSeqNo());
425 } 424 }
426 425
427 TEST_F(SearchIPCRouterTest, IgnoreUndoAllMostVisitedDeletionsMsg) { 426 TEST_F(SearchIPCRouterTest, IgnoreUndoAllMostVisitedDeletionsMsg) {
428 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 427 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
429 SetupMockDelegateAndPolicy(); 428 SetupMockDelegateAndPolicy();
430 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 429 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
431 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0); 430 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0);
432 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(1) 431 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(1)
433 .WillOnce(testing::Return(false)); 432 .WillOnce(testing::Return(false));
434 433
435 GetSearchIPCRouter().SearchBoxUndoAllMostVisitedDeletions( 434 GetSearchIPCRouter().UndoAllMostVisitedDeletions(GetSearchIPCRouterSeqNo());
436 GetSearchIPCRouterSeqNo());
437 } 435 }
438 436
439 TEST_F(SearchIPCRouterTest, IgnoreMessageIfThePageIsNotActive) { 437 TEST_F(SearchIPCRouterTest, IgnoreMessageIfThePageIsNotActive) {
440 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 438 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
441 SetupMockDelegateAndPolicy(); 439 SetupMockDelegateAndPolicy();
442 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 440 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
443 int page_seq_no = GetSearchIPCRouterSeqNo(); 441 int page_seq_no = GetSearchIPCRouterSeqNo();
444 442
445 content::WebContents* contents = web_contents(); 443 content::WebContents* contents = web_contents();
446 bool is_active_tab = IsActiveTab(contents); 444 bool is_active_tab = IsActiveTab(contents);
447 GURL item_url("www.foo.com"); 445 GURL item_url("www.foo.com");
448 446
449 // Navigate away from the NTP. Afterwards, all messages should be ignored. 447 // Navigate away from the NTP. Afterwards, all messages should be ignored.
450 NavigateAndCommitActiveTab(item_url); 448 NavigateAndCommitActiveTab(item_url);
451 449
452 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(0); 450 EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(0);
453 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(0); 451 EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(0);
454 GetSearchIPCRouter().SearchBoxDeleteMostVisitedItem(page_seq_no, item_url); 452 GetSearchIPCRouter().DeleteMostVisitedItem(page_seq_no, item_url);
455 453
456 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(0); 454 EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(0);
457 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(0); 455 EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(0);
458 GetSearchIPCRouter().SearchBoxUndoMostVisitedDeletion(page_seq_no, item_url); 456 GetSearchIPCRouter().UndoMostVisitedDeletion(page_seq_no, item_url);
459 457
460 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0); 458 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0);
461 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0); 459 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0);
462 GetSearchIPCRouter().SearchBoxUndoAllMostVisitedDeletions(page_seq_no); 460 GetSearchIPCRouter().UndoAllMostVisitedDeletions(page_seq_no);
463 461
464 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); 462 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0);
465 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0); 463 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0);
466 GetSearchIPCRouter().FocusOmnibox(page_seq_no, OMNIBOX_FOCUS_VISIBLE); 464 GetSearchIPCRouter().FocusOmnibox(page_seq_no, OMNIBOX_FOCUS_VISIBLE);
467 465
468 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); 466 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
469 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta)) 467 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta))
470 .Times(0); 468 .Times(0);
471 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); 469 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0);
472 GetSearchIPCRouter().LogEvent(page_seq_no, NTP_ALL_TILES_LOADED, delta); 470 GetSearchIPCRouter().LogEvent(page_seq_no, NTP_ALL_TILES_LOADED, delta);
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 TEST_F(SearchIPCRouterTest, DoNotSendSubmitMsg) { 638 TEST_F(SearchIPCRouterTest, DoNotSendSubmitMsg) {
641 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 639 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
642 SetupMockDelegateAndPolicy(); 640 SetupMockDelegateAndPolicy();
643 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 641 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
644 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1) 642 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1)
645 .WillOnce(testing::Return(false)); 643 .WillOnce(testing::Return(false));
646 644
647 EXPECT_CALL(*mock_search_box(), Submit(_, _)).Times(0); 645 EXPECT_CALL(*mock_search_box(), Submit(_, _)).Times(0);
648 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams()); 646 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams());
649 } 647 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router.cc ('k') | chrome/common/instant.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698