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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" | 9 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" |
10 #include "chrome/browser/ui/search/search_tab_helper.h" | 10 #include "chrome/browser/ui/search/search_tab_helper.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 return search_tab_helper->ipc_router().policy_for_testing(); | 34 return search_tab_helper->ipc_router().policy_for_testing(); |
35 } | 35 } |
36 | 36 |
37 void SetIncognitoProfile() { | 37 void SetIncognitoProfile() { |
38 SearchIPCRouterPolicyImpl* policy = | 38 SearchIPCRouterPolicyImpl* policy = |
39 static_cast<SearchIPCRouterPolicyImpl*>(GetSearchIPCRouterPolicy()); | 39 static_cast<SearchIPCRouterPolicyImpl*>(GetSearchIPCRouterPolicy()); |
40 policy->set_is_incognito(true); | 40 policy->set_is_incognito(true); |
41 } | 41 } |
42 }; | 42 }; |
43 | 43 |
| 44 TEST_F(SearchIPCRouterPolicyTest, ProcessVoiceSearchSupportMsg) { |
| 45 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 46 EXPECT_TRUE(GetSearchIPCRouterPolicy()-> |
| 47 ShouldProcessSetVoiceSearchSupport()); |
| 48 } |
| 49 |
44 TEST_F(SearchIPCRouterPolicyTest, ProcessFocusOmnibox) { | 50 TEST_F(SearchIPCRouterPolicyTest, ProcessFocusOmnibox) { |
45 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 51 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
46 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldProcessFocusOmnibox(true)); | 52 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldProcessFocusOmnibox(true)); |
47 } | 53 } |
48 | 54 |
49 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessFocusOmnibox) { | 55 TEST_F(SearchIPCRouterPolicyTest, DoNotProcessFocusOmnibox) { |
50 // Process message only if the underlying page is an InstantNTP. | 56 // Process message only if the underlying page is an InstantNTP. |
51 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 57 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
52 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessFocusOmnibox(true)); | 58 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldProcessFocusOmnibox(true)); |
53 } | 59 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 EXPECT_FALSE(router_policy->ShouldSendOmniboxFocusChanged()); | 198 EXPECT_FALSE(router_policy->ShouldSendOmniboxFocusChanged()); |
193 } | 199 } |
194 | 200 |
195 TEST_F(SearchIPCRouterPolicyTest, | 201 TEST_F(SearchIPCRouterPolicyTest, |
196 AppropriateMessagesSentToIncognitoPages) { | 202 AppropriateMessagesSentToIncognitoPages) { |
197 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 203 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
198 SetIncognitoProfile(); | 204 SetIncognitoProfile(); |
199 | 205 |
200 SearchIPCRouter::Policy* router_policy = GetSearchIPCRouterPolicy(); | 206 SearchIPCRouter::Policy* router_policy = GetSearchIPCRouterPolicy(); |
201 EXPECT_TRUE(router_policy->ShouldSubmitQuery()); | 207 EXPECT_TRUE(router_policy->ShouldSubmitQuery()); |
| 208 EXPECT_TRUE(router_policy->ShouldSendToggleVoiceSearch()); |
202 EXPECT_TRUE(router_policy->ShouldSendSetOmniboxStartMargin()); | 209 EXPECT_TRUE(router_policy->ShouldSendSetOmniboxStartMargin()); |
203 } | 210 } |
204 | 211 |
205 TEST_F(SearchIPCRouterPolicyTest, SendMostVisitedItems) { | 212 TEST_F(SearchIPCRouterPolicyTest, SendMostVisitedItems) { |
206 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 213 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
207 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSendMostVisitedItems()); | 214 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSendMostVisitedItems()); |
208 } | 215 } |
209 | 216 |
210 TEST_F(SearchIPCRouterPolicyTest, DoNotSendMostVisitedItems) { | 217 TEST_F(SearchIPCRouterPolicyTest, DoNotSendMostVisitedItems) { |
211 // Send most visited items only if the current tab is an Instant NTP. | 218 // Send most visited items only if the current tab is an Instant NTP. |
(...skipping 10 matching lines...) Expand all Loading... |
222 // Send theme background information only if the current tab is an | 229 // Send theme background information only if the current tab is an |
223 // Instant NTP. | 230 // Instant NTP. |
224 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 231 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
225 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldSendThemeBackgroundInfo()); | 232 EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldSendThemeBackgroundInfo()); |
226 } | 233 } |
227 | 234 |
228 TEST_F(SearchIPCRouterPolicyTest, SubmitQuery) { | 235 TEST_F(SearchIPCRouterPolicyTest, SubmitQuery) { |
229 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 236 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
230 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSubmitQuery()); | 237 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSubmitQuery()); |
231 } | 238 } |
| 239 |
| 240 TEST_F(SearchIPCRouterPolicyTest, SendToggleVoiceSearch) { |
| 241 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 242 EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSendToggleVoiceSearch()); |
| 243 } |
OLD | NEW |