| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 EXPECT_EQ(browser()->tab_strip_model()->active_index(), | 272 EXPECT_EQ(browser()->tab_strip_model()->active_index(), |
| 273 browser()->tab_strip_model()->GetIndexOfWebContents(contents)); | 273 browser()->tab_strip_model()->GetIndexOfWebContents(contents)); |
| 274 EXPECT_TRUE(IsActiveTab(contents)); | 274 EXPECT_TRUE(IsActiveTab(contents)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) { | 277 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) { |
| 278 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); | 278 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); |
| 279 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 279 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 280 SetupMockDelegateAndPolicy(); | 280 SetupMockDelegateAndPolicy(); |
| 281 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 281 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 282 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER, delta)).Times(1); | 282 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(1); |
| 283 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) | 283 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) |
| 284 .WillOnce(testing::Return(true)); | 284 .WillOnce(testing::Return(true)); |
| 285 | 285 |
| 286 content::WebContents* contents = web_contents(); | 286 content::WebContents* contents = web_contents(); |
| 287 OnMessageReceived(ChromeViewHostMsg_LogEvent( | 287 OnMessageReceived(ChromeViewHostMsg_LogEvent( |
| 288 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), | 288 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), |
| 289 NTP_MOUSEOVER, delta)); | 289 NTP_TILE, delta)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { | 292 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { |
| 293 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); | 293 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); |
| 294 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); | 294 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); |
| 295 SetupMockDelegateAndPolicy(); | 295 SetupMockDelegateAndPolicy(); |
| 296 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 296 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 297 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER, delta)).Times(0); | 297 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(0); |
| 298 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) | 298 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) |
| 299 .WillOnce(testing::Return(false)); | 299 .WillOnce(testing::Return(false)); |
| 300 | 300 |
| 301 content::WebContents* contents = web_contents(); | 301 content::WebContents* contents = web_contents(); |
| 302 OnMessageReceived(ChromeViewHostMsg_LogEvent( | 302 OnMessageReceived(ChromeViewHostMsg_LogEvent( |
| 303 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), | 303 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), |
| 304 NTP_MOUSEOVER, delta)); | 304 NTP_TILE, delta)); |
| 305 } | 305 } |
| 306 | 306 |
| 307 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { | 307 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { |
| 308 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 308 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| 309 SetupMockDelegateAndPolicy(); | 309 SetupMockDelegateAndPolicy(); |
| 310 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); | 310 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); |
| 311 EXPECT_CALL(*mock_delegate(), | 311 EXPECT_CALL(*mock_delegate(), |
| 312 OnLogMostVisitedImpression(3, NTPLoggingTileSource::SERVER)).Times(1); | 312 OnLogMostVisitedImpression(3, NTPLoggingTileSource::SERVER)).Times(1); |
| 313 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) | 313 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) |
| 314 .WillOnce(testing::Return(true)); | 314 .WillOnce(testing::Return(true)); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0); | 499 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0); |
| 500 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( | 500 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( |
| 501 contents->GetRoutingID(), page_seq_no)); | 501 contents->GetRoutingID(), page_seq_no)); |
| 502 | 502 |
| 503 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); | 503 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); |
| 504 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0); | 504 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0); |
| 505 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox( | 505 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox( |
| 506 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE)); | 506 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE)); |
| 507 | 507 |
| 508 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); | 508 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); |
| 509 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER, delta)).Times(0); | 509 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(0); |
| 510 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); | 510 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); |
| 511 OnMessageReceived(ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), | 511 OnMessageReceived(ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), |
| 512 page_seq_no, | 512 page_seq_no, |
| 513 NTP_MOUSEOVER, delta)); | 513 NTP_TILE, delta)); |
| 514 | 514 |
| 515 base::string16 text; | 515 base::string16 text; |
| 516 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); | 516 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); |
| 517 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0); | 517 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0); |
| 518 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( | 518 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( |
| 519 contents->GetRoutingID(), page_seq_no, text)); | 519 contents->GetRoutingID(), page_seq_no, text)); |
| 520 } | 520 } |
| 521 | 521 |
| 522 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) { | 522 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) { |
| 523 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); | 523 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 | 784 |
| 785 // Construct a series of synthetic messages for each valid IPC message type, | 785 // Construct a series of synthetic messages for each valid IPC message type, |
| 786 // ensuring the router ignores them all. | 786 // ensuring the router ignores them all. |
| 787 for (int i = 0; i < LastIPCMsgStart; ++i) { | 787 for (int i = 0; i < LastIPCMsgStart; ++i) { |
| 788 const int message_id = i << 16; | 788 const int message_id = i << 16; |
| 789 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); | 789 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); |
| 790 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); | 790 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); |
| 791 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; | 791 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; |
| 792 } | 792 } |
| 793 } | 793 } |
| OLD | NEW |