| 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 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 } | 864 } |
| 865 | 865 |
| 866 TEST_F(SearchIPCRouterTest, SendSubmitMsg) { | 866 TEST_F(SearchIPCRouterTest, SendSubmitMsg) { |
| 867 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 867 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 868 SetupMockDelegateAndPolicy(); | 868 SetupMockDelegateAndPolicy(); |
| 869 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 869 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 870 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1) | 870 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1) |
| 871 .WillOnce(testing::Return(true)); | 871 .WillOnce(testing::Return(true)); |
| 872 | 872 |
| 873 process()->sink().ClearMessages(); | 873 process()->sink().ClearMessages(); |
| 874 GetSearchIPCRouter().Submit(base::string16()); | 874 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams()); |
| 875 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxSubmit::ID)); | 875 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxSubmit::ID)); |
| 876 } | 876 } |
| 877 | 877 |
| 878 TEST_F(SearchIPCRouterTest, DoNotSendSubmitMsg) { | 878 TEST_F(SearchIPCRouterTest, DoNotSendSubmitMsg) { |
| 879 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 879 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 880 SetupMockDelegateAndPolicy(); | 880 SetupMockDelegateAndPolicy(); |
| 881 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 881 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 882 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1) | 882 EXPECT_CALL(*policy, ShouldSubmitQuery()).Times(1) |
| 883 .WillOnce(testing::Return(false)); | 883 .WillOnce(testing::Return(false)); |
| 884 | 884 |
| 885 process()->sink().ClearMessages(); | 885 process()->sink().ClearMessages(); |
| 886 GetSearchIPCRouter().Submit(base::string16()); | 886 GetSearchIPCRouter().Submit(base::string16(), EmbeddedSearchRequestParams()); |
| 887 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxSubmit::ID)); | 887 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxSubmit::ID)); |
| 888 } | 888 } |
| 889 | 889 |
| 890 TEST_F(SearchIPCRouterTest, SendToggleVoiceSearch) { | 890 TEST_F(SearchIPCRouterTest, SendToggleVoiceSearch) { |
| 891 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 891 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 892 SetupMockDelegateAndPolicy(); | 892 SetupMockDelegateAndPolicy(); |
| 893 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 893 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 894 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) | 894 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) |
| 895 .WillOnce(testing::Return(true)); | 895 .WillOnce(testing::Return(true)); |
| 896 | 896 |
| 897 process()->sink().ClearMessages(); | 897 process()->sink().ClearMessages(); |
| 898 GetSearchIPCRouter().ToggleVoiceSearch(); | 898 GetSearchIPCRouter().ToggleVoiceSearch(); |
| 899 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); | 899 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); |
| 900 } | 900 } |
| 901 | 901 |
| 902 TEST_F(SearchIPCRouterTest, DoNotSendToggleVoiceSearch) { | 902 TEST_F(SearchIPCRouterTest, DoNotSendToggleVoiceSearch) { |
| 903 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 903 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 904 SetupMockDelegateAndPolicy(); | 904 SetupMockDelegateAndPolicy(); |
| 905 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 905 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 906 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) | 906 EXPECT_CALL(*policy, ShouldSendToggleVoiceSearch()).Times(1) |
| 907 .WillOnce(testing::Return(false)); | 907 .WillOnce(testing::Return(false)); |
| 908 | 908 |
| 909 process()->sink().ClearMessages(); | 909 process()->sink().ClearMessages(); |
| 910 GetSearchIPCRouter().ToggleVoiceSearch(); | 910 GetSearchIPCRouter().ToggleVoiceSearch(); |
| 911 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); | 911 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); |
| 912 } | 912 } |
| OLD | NEW |