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 <tuple> | 10 #include <tuple> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/ptr_util.h" |
14 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/search/search.h" | 19 #include "chrome/browser/search/search.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 20 #include "chrome/browser/search_engines/template_url_service_factory.h" |
20 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" | 21 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" |
21 #include "chrome/browser/ui/search/search_tab_helper.h" | 22 #include "chrome/browser/ui/search/search_tab_helper.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return SearchTabHelper::FromWebContents(web_contents); | 136 return SearchTabHelper::FromWebContents(web_contents); |
136 } | 137 } |
137 | 138 |
138 void SetupMockDelegateAndPolicy() { | 139 void SetupMockDelegateAndPolicy() { |
139 content::WebContents* contents = web_contents(); | 140 content::WebContents* contents = web_contents(); |
140 ASSERT_NE(static_cast<content::WebContents*>(NULL), contents); | 141 ASSERT_NE(static_cast<content::WebContents*>(NULL), contents); |
141 SearchTabHelper* search_tab_helper = GetSearchTabHelper(contents); | 142 SearchTabHelper* search_tab_helper = GetSearchTabHelper(contents); |
142 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); | 143 ASSERT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); |
143 search_tab_helper->ipc_router().set_delegate_for_testing(mock_delegate()); | 144 search_tab_helper->ipc_router().set_delegate_for_testing(mock_delegate()); |
144 search_tab_helper->ipc_router().set_policy_for_testing( | 145 search_tab_helper->ipc_router().set_policy_for_testing( |
145 make_scoped_ptr(new MockSearchIPCRouterPolicy)); | 146 base::WrapUnique(new MockSearchIPCRouterPolicy)); |
146 } | 147 } |
147 | 148 |
148 bool MessageWasSent(uint32_t id) { | 149 bool MessageWasSent(uint32_t id) { |
149 return process()->sink().GetFirstMessageMatching(id) != NULL; | 150 return process()->sink().GetFirstMessageMatching(id) != NULL; |
150 } | 151 } |
151 | 152 |
152 void VerifyDisplayInstantResultsMsg(bool expected_param_value) { | 153 void VerifyDisplayInstantResultsMsg(bool expected_param_value) { |
153 SetupMockDelegateAndPolicy(); | 154 SetupMockDelegateAndPolicy(); |
154 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 155 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
155 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) | 156 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 | 831 |
831 // Construct a series of synthetic messages for each valid IPC message type, | 832 // Construct a series of synthetic messages for each valid IPC message type, |
832 // ensuring the router ignores them all. | 833 // ensuring the router ignores them all. |
833 for (int i = 0; i < LastIPCMsgStart; ++i) { | 834 for (int i = 0; i < LastIPCMsgStart; ++i) { |
834 const int message_id = i << 16; | 835 const int message_id = i << 16; |
835 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); | 836 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); |
836 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); | 837 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); |
837 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; | 838 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; |
838 } | 839 } |
839 } | 840 } |
OLD | NEW |