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 <memory> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 EXPECT_EQ(browser()->tab_strip_model()->active_index(), | 252 EXPECT_EQ(browser()->tab_strip_model()->active_index(), |
253 browser()->tab_strip_model()->GetIndexOfWebContents(contents)); | 253 browser()->tab_strip_model()->GetIndexOfWebContents(contents)); |
254 EXPECT_TRUE(IsActiveTab(contents)); | 254 EXPECT_TRUE(IsActiveTab(contents)); |
255 } | 255 } |
256 | 256 |
257 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) { | 257 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) { |
258 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); | 258 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); |
259 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 259 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
260 SetupMockDelegateAndPolicy(); | 260 SetupMockDelegateAndPolicy(); |
261 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 261 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
262 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta)) | 262 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta)) |
263 .Times(1); | 263 .Times(1); |
264 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) | 264 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) |
265 .WillOnce(testing::Return(true)); | 265 .WillOnce(testing::Return(true)); |
266 | 266 |
267 content::WebContents* contents = web_contents(); | 267 content::WebContents* contents = web_contents(); |
268 OnMessageReceived(ChromeViewHostMsg_LogEvent( | 268 OnMessageReceived(ChromeViewHostMsg_LogEvent( |
269 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), | 269 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), |
270 NTP_CLIENT_SIDE_SUGGESTION, delta)); | 270 NTP_ALL_TILES_LOADED, delta)); |
271 } | 271 } |
272 | 272 |
273 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { | 273 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { |
274 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); | 274 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); |
275 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 275 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
276 SetupMockDelegateAndPolicy(); | 276 SetupMockDelegateAndPolicy(); |
277 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 277 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
278 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta)) | 278 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta)) |
279 .Times(0); | 279 .Times(0); |
280 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) | 280 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) |
281 .WillOnce(testing::Return(false)); | 281 .WillOnce(testing::Return(false)); |
282 | 282 |
283 content::WebContents* contents = web_contents(); | 283 content::WebContents* contents = web_contents(); |
284 OnMessageReceived(ChromeViewHostMsg_LogEvent( | 284 OnMessageReceived(ChromeViewHostMsg_LogEvent( |
285 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), | 285 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), |
286 NTP_CLIENT_SIDE_SUGGESTION, delta)); | 286 NTP_ALL_TILES_LOADED, delta)); |
287 } | 287 } |
288 | 288 |
289 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { | 289 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { |
290 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 290 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
291 SetupMockDelegateAndPolicy(); | 291 SetupMockDelegateAndPolicy(); |
292 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 292 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
293 EXPECT_CALL(*mock_delegate(), | 293 EXPECT_CALL(*mock_delegate(), |
294 OnLogMostVisitedImpression(3, NTPLoggingTileSource::SERVER)).Times(1); | 294 OnLogMostVisitedImpression(3, NTPLoggingTileSource::SERVER)).Times(1); |
295 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) | 295 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) |
296 .WillOnce(testing::Return(true)); | 296 .WillOnce(testing::Return(true)); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0); | 481 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0); |
482 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( | 482 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( |
483 contents->GetRoutingID(), page_seq_no)); | 483 contents->GetRoutingID(), page_seq_no)); |
484 | 484 |
485 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); | 485 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); |
486 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0); | 486 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0); |
487 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox( | 487 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox( |
488 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE)); | 488 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE)); |
489 | 489 |
490 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); | 490 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); |
491 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta)) | 491 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_ALL_TILES_LOADED, delta)) |
492 .Times(0); | 492 .Times(0); |
493 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); | 493 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); |
494 OnMessageReceived( | 494 OnMessageReceived( |
495 ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), page_seq_no, | 495 ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), page_seq_no, |
496 NTP_CLIENT_SIDE_SUGGESTION, delta)); | 496 NTP_ALL_TILES_LOADED, delta)); |
497 | 497 |
498 base::string16 text; | 498 base::string16 text; |
499 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); | 499 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); |
500 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0); | 500 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0); |
501 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( | 501 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( |
502 contents->GetRoutingID(), page_seq_no, text)); | 502 contents->GetRoutingID(), page_seq_no, text)); |
503 } | 503 } |
504 | 504 |
505 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) { | 505 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) { |
506 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 506 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 698 |
699 // Construct a series of synthetic messages for each valid IPC message type, | 699 // Construct a series of synthetic messages for each valid IPC message type, |
700 // ensuring the router ignores them all. | 700 // ensuring the router ignores them all. |
701 for (int i = 0; i < LastIPCMsgStart; ++i) { | 701 for (int i = 0; i < LastIPCMsgStart; ++i) { |
702 const int message_id = i << 16; | 702 const int message_id = i << 16; |
703 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); | 703 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); |
704 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); | 704 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); |
705 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; | 705 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; |
706 } | 706 } |
707 } | 707 } |
OLD | NEW |