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