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 <tuple> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
14 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #include "base/tuple.h" | |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/search/search.h" | 18 #include "chrome/browser/search/search.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
20 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" | 20 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" |
21 #include "chrome/browser/ui/search/search_tab_helper.h" | 21 #include "chrome/browser/ui/search/search_tab_helper.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/instant_types.h" | 24 #include "chrome/common/instant_types.h" |
25 #include "chrome/common/ntp_logging_events.h" | 25 #include "chrome/common/ntp_logging_events.h" |
26 #include "chrome/common/render_messages.h" | 26 #include "chrome/common/render_messages.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 void VerifyDisplayInstantResultsMsg(bool expected_param_value) { | 152 void VerifyDisplayInstantResultsMsg(bool expected_param_value) { |
153 SetupMockDelegateAndPolicy(); | 153 SetupMockDelegateAndPolicy(); |
154 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 154 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
155 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) | 155 EXPECT_CALL(*policy, ShouldSendSetDisplayInstantResults()).Times(1) |
156 .WillOnce(testing::Return(true)); | 156 .WillOnce(testing::Return(true)); |
157 | 157 |
158 GetSearchIPCRouter().SetDisplayInstantResults(); | 158 GetSearchIPCRouter().SetDisplayInstantResults(); |
159 const IPC::Message* message = process()->sink().GetFirstMessageMatching( | 159 const IPC::Message* message = process()->sink().GetFirstMessageMatching( |
160 ChromeViewMsg_SearchBoxSetDisplayInstantResults::ID); | 160 ChromeViewMsg_SearchBoxSetDisplayInstantResults::ID); |
161 EXPECT_NE(static_cast<const IPC::Message*>(NULL), message); | 161 EXPECT_NE(static_cast<const IPC::Message*>(NULL), message); |
162 base::Tuple<bool> display_instant_results_param; | 162 std::tuple<bool> display_instant_results_param; |
163 ChromeViewMsg_SearchBoxSetDisplayInstantResults::Read( | 163 ChromeViewMsg_SearchBoxSetDisplayInstantResults::Read( |
164 message, &display_instant_results_param); | 164 message, &display_instant_results_param); |
165 EXPECT_EQ(expected_param_value, | 165 EXPECT_EQ(expected_param_value, |
166 base::get<0>(display_instant_results_param)); | 166 std::get<0>(display_instant_results_param)); |
167 } | 167 } |
168 | 168 |
169 MockSearchIPCRouterDelegate* mock_delegate() { return &delegate_; } | 169 MockSearchIPCRouterDelegate* mock_delegate() { return &delegate_; } |
170 | 170 |
171 MockSearchIPCRouterPolicy* GetSearchIPCRouterPolicy() { | 171 MockSearchIPCRouterPolicy* GetSearchIPCRouterPolicy() { |
172 content::WebContents* contents = web_contents(); | 172 content::WebContents* contents = web_contents(); |
173 EXPECT_NE(static_cast<content::WebContents*>(NULL), contents); | 173 EXPECT_NE(static_cast<content::WebContents*>(NULL), contents); |
174 SearchTabHelper* search_tab_helper = GetSearchTabHelper(contents); | 174 SearchTabHelper* search_tab_helper = GetSearchTabHelper(contents); |
175 EXPECT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); | 175 EXPECT_NE(static_cast<SearchTabHelper*>(NULL), search_tab_helper); |
176 return static_cast<MockSearchIPCRouterPolicy*>( | 176 return static_cast<MockSearchIPCRouterPolicy*>( |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 | 830 |
831 // Construct a series of synthetic messages for each valid IPC message type, | 831 // Construct a series of synthetic messages for each valid IPC message type, |
832 // ensuring the router ignores them all. | 832 // ensuring the router ignores them all. |
833 for (int i = 0; i < LastIPCMsgStart; ++i) { | 833 for (int i = 0; i < LastIPCMsgStart; ++i) { |
834 const int message_id = i << 16; | 834 const int message_id = i << 16; |
835 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); | 835 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); |
836 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); | 836 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); |
837 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; | 837 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; |
838 } | 838 } |
839 } | 839 } |
OLD | NEW |