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 <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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return SearchTabHelper::FromWebContents(web_contents); | 133 return SearchTabHelper::FromWebContents(web_contents); |
134 } | 134 } |
135 | 135 |
136 void SetupMockDelegateAndPolicy() { | 136 void SetupMockDelegateAndPolicy() { |
137 content::WebContents* contents = web_contents(); | 137 content::WebContents* contents = web_contents(); |
138 ASSERT_NE(static_cast<content::WebContents*>(NULL), contents); | 138 ASSERT_NE(static_cast<content::WebContents*>(NULL), contents); |
139 SearchTabHelper* search_tab_helper = GetSearchTabHelper(contents); | 139 SearchTabHelper* search_tab_helper = GetSearchTabHelper(contents); |
140 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); | 140 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); |
141 search_tab_helper->ipc_router().set_delegate_for_testing(mock_delegate()); | 141 search_tab_helper->ipc_router().set_delegate_for_testing(mock_delegate()); |
142 search_tab_helper->ipc_router().set_policy_for_testing( | 142 search_tab_helper->ipc_router().set_policy_for_testing( |
143 make_scoped_ptr(new MockSearchIPCRouterPolicy) | 143 make_scoped_ptr(new MockSearchIPCRouterPolicy)); |
144 .PassAs<SearchIPCRouter::Policy>()); | |
145 } | 144 } |
146 | 145 |
147 bool MessageWasSent(uint32 id) { | 146 bool MessageWasSent(uint32 id) { |
148 return process()->sink().GetFirstMessageMatching(id) != NULL; | 147 return process()->sink().GetFirstMessageMatching(id) != NULL; |
149 } | 148 } |
150 | 149 |
151 void VerifyDisplayInstantResultsMsg(bool expected_param_value) { | 150 void VerifyDisplayInstantResultsMsg(bool expected_param_value) { |
152 SetupMockDelegateAndPolicy(); | 151 SetupMockDelegateAndPolicy(); |
153 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 152 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
154 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) | 153 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 903 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
905 SetupMockDelegateAndPolicy(); | 904 SetupMockDelegateAndPolicy(); |
906 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 905 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
907 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) | 906 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) |
908 .WillOnce(testing::Return(false)); | 907 .WillOnce(testing::Return(false)); |
909 | 908 |
910 process()->sink().ClearMessages(); | 909 process()->sink().ClearMessages(); |
911 GetSearchIPCRouter().ToggleVoiceSearch(); | 910 GetSearchIPCRouter().ToggleVoiceSearch(); |
912 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); | 911 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); |
913 } | 912 } |
OLD | NEW |