| 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 "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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 virtual ~MockSearchIPCRouterPolicy() {} | 69 virtual ~MockSearchIPCRouterPolicy() {} |
| 70 | 70 |
| 71 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool)); | 71 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool)); |
| 72 MOCK_METHOD0(ShouldProcessDeleteMostVisitedItem, bool()); | 72 MOCK_METHOD0(ShouldProcessDeleteMostVisitedItem, bool()); |
| 73 MOCK_METHOD0(ShouldProcessUndoMostVisitedDeletion, bool()); | 73 MOCK_METHOD0(ShouldProcessUndoMostVisitedDeletion, bool()); |
| 74 MOCK_METHOD0(ShouldProcessUndoAllMostVisitedDeletions, bool()); | 74 MOCK_METHOD0(ShouldProcessUndoAllMostVisitedDeletions, bool()); |
| 75 MOCK_METHOD0(ShouldProcessLogEvent, bool()); | 75 MOCK_METHOD0(ShouldProcessLogEvent, bool()); |
| 76 MOCK_METHOD1(ShouldProcessPasteIntoOmnibox, bool(bool)); | 76 MOCK_METHOD1(ShouldProcessPasteIntoOmnibox, bool(bool)); |
| 77 MOCK_METHOD0(ShouldProcessChromeIdentityCheck, bool()); | 77 MOCK_METHOD0(ShouldProcessChromeIdentityCheck, bool()); |
| 78 MOCK_METHOD0(ShouldProcessHistorySyncCheck, bool()); | 78 MOCK_METHOD0(ShouldProcessHistorySyncCheck, bool()); |
| 79 MOCK_METHOD0(ShouldSendSetPromoInformation, bool()); | |
| 80 MOCK_METHOD0(ShouldSendSetDisplayInstantResults, bool()); | 79 MOCK_METHOD0(ShouldSendSetDisplayInstantResults, bool()); |
| 81 MOCK_METHOD0(ShouldSendSetSuggestionToPrefetch, bool()); | 80 MOCK_METHOD0(ShouldSendSetSuggestionToPrefetch, bool()); |
| 82 MOCK_METHOD1(ShouldSendSetInputInProgress, bool(bool)); | 81 MOCK_METHOD1(ShouldSendSetInputInProgress, bool(bool)); |
| 83 MOCK_METHOD0(ShouldSendOmniboxFocusChanged, bool()); | 82 MOCK_METHOD0(ShouldSendOmniboxFocusChanged, bool()); |
| 84 MOCK_METHOD0(ShouldSendMostVisitedItems, bool()); | 83 MOCK_METHOD0(ShouldSendMostVisitedItems, bool()); |
| 85 MOCK_METHOD0(ShouldSendThemeBackgroundInfo, bool()); | 84 MOCK_METHOD0(ShouldSendThemeBackgroundInfo, bool()); |
| 86 MOCK_METHOD0(ShouldSubmitQuery, bool()); | 85 MOCK_METHOD0(ShouldSubmitQuery, bool()); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace | 88 } // namespace |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 EXPECT_TRUE(is_active_tab); | 546 EXPECT_TRUE(is_active_tab); |
| 548 | 547 |
| 549 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 548 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 550 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(1) | 549 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(1) |
| 551 .WillOnce(testing::Return(false)); | 550 .WillOnce(testing::Return(false)); |
| 552 | 551 |
| 553 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( | 552 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( |
| 554 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), text)); | 553 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), text)); |
| 555 } | 554 } |
| 556 | 555 |
| 557 TEST_F(SearchIPCRouterTest, SendSetPromoInformationMsg) { | |
| 558 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | |
| 559 SetupMockDelegateAndPolicy(); | |
| 560 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | |
| 561 EXPECT_CALL(*policy, ShouldSendSetPromoInformation()).Times(1) | |
| 562 .WillOnce(testing::Return(true)); | |
| 563 | |
| 564 GetSearchIPCRouter().SetPromoInformation(true); | |
| 565 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxPromoInformation::ID)); | |
| 566 } | |
| 567 | |
| 568 TEST_F(SearchIPCRouterTest, DoNotSendSetPromoInformationMsg) { | |
| 569 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | |
| 570 SetupMockDelegateAndPolicy(); | |
| 571 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | |
| 572 EXPECT_CALL(*policy, ShouldSendSetPromoInformation()).Times(1) | |
| 573 .WillOnce(testing::Return(false)); | |
| 574 | |
| 575 GetSearchIPCRouter().SetPromoInformation(false); | |
| 576 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxPromoInformation::ID)); | |
| 577 } | |
| 578 | |
| 579 TEST_F(SearchIPCRouterTest, | 556 TEST_F(SearchIPCRouterTest, |
| 580 SendSetDisplayInstantResultsMsg_EnableInstantOnResultsPage) { | 557 SendSetDisplayInstantResultsMsg_EnableInstantOnResultsPage) { |
| 581 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 558 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 582 "EmbeddedSearch", | 559 "EmbeddedSearch", |
| 583 "Group1 espv:42 query_extraction:1 prefetch_results_srp:1")); | 560 "Group1 espv:42 query_extraction:1 prefetch_results_srp:1")); |
| 584 NavigateAndCommitActiveTab(GURL("https://foo.com/url?espv&bar=abc")); | 561 NavigateAndCommitActiveTab(GURL("https://foo.com/url?espv&bar=abc")); |
| 585 | 562 |
| 586 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults message param is | 563 // Make sure ChromeViewMsg_SearchBoxSetDisplayInstantResults message param is |
| 587 // set to true if the underlying page is a results page and | 564 // set to true if the underlying page is a results page and |
| 588 // "prefetch_results_srp" flag is enabled via field trials. | 565 // "prefetch_results_srp" flag is enabled via field trials. |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 | 761 |
| 785 // Construct a series of synthetic messages for each valid IPC message type, | 762 // Construct a series of synthetic messages for each valid IPC message type, |
| 786 // ensuring the router ignores them all. | 763 // ensuring the router ignores them all. |
| 787 for (int i = 0; i < LastIPCMsgStart; ++i) { | 764 for (int i = 0; i < LastIPCMsgStart; ++i) { |
| 788 const int message_id = i << 16; | 765 const int message_id = i << 16; |
| 789 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); | 766 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); |
| 790 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); | 767 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); |
| 791 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; | 768 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; |
| 792 } | 769 } |
| 793 } | 770 } |
| OLD | NEW |