Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1037)

Side by Side Diff: chrome/browser/ui/search/search_ipc_router_unittest.cc

Issue 1006753003: Add time from navigation_start to NTP LogEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 public: 45 public:
46 virtual ~MockSearchIPCRouterDelegate() {} 46 virtual ~MockSearchIPCRouterDelegate() {}
47 47
48 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); 48 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant));
49 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search)); 49 MOCK_METHOD1(OnSetVoiceSearchSupport, void(bool supports_voice_search));
50 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state)); 50 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state));
51 MOCK_METHOD3(NavigateToURL, void(const GURL&, WindowOpenDisposition, bool)); 51 MOCK_METHOD3(NavigateToURL, void(const GURL&, WindowOpenDisposition, bool));
52 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url)); 52 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url));
53 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url)); 53 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url));
54 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void()); 54 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void());
55 MOCK_METHOD1(OnLogEvent, void(NTPLoggingEventType event)); 55 MOCK_METHOD2(OnLogEvent, void(NTPLoggingEventType event,
56 base::TimeDelta time));
56 MOCK_METHOD2(OnLogMostVisitedImpression, 57 MOCK_METHOD2(OnLogMostVisitedImpression,
57 void(int position, const base::string16& provider)); 58 void(int position, const base::string16& provider));
58 MOCK_METHOD2(OnLogMostVisitedNavigation, 59 MOCK_METHOD2(OnLogMostVisitedNavigation,
59 void(int position, const base::string16& provider)); 60 void(int position, const base::string16& provider));
60 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&)); 61 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&));
61 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity)); 62 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity));
62 MOCK_METHOD0(OnHistorySyncCheck, void()); 63 MOCK_METHOD0(OnHistorySyncCheck, void());
63 }; 64 };
64 65
65 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy { 66 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 336 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
336 EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(1) 337 EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(1)
337 .WillOnce(testing::Return(false)); 338 .WillOnce(testing::Return(false));
338 339
339 OnMessageReceived(ChromeViewHostMsg_SearchBoxNavigate( 340 OnMessageReceived(ChromeViewHostMsg_SearchBoxNavigate(
340 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), destination_url, 341 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), destination_url,
341 CURRENT_TAB, true)); 342 CURRENT_TAB, true));
342 } 343 }
343 344
344 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) { 345 TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) {
346 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
345 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 347 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
346 SetupMockDelegateAndPolicy(); 348 SetupMockDelegateAndPolicy();
347 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 349 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
348 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER)).Times(1); 350 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER, delta)).Times(1);
349 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 351 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
350 .WillOnce(testing::Return(true)); 352 .WillOnce(testing::Return(true));
351 353
352 content::WebContents* contents = web_contents(); 354 content::WebContents* contents = web_contents();
353 OnMessageReceived(ChromeViewHostMsg_LogEvent( 355 OnMessageReceived(ChromeViewHostMsg_LogEvent(
354 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), NTP_MOUSEOVER)); 356 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
357 NTP_MOUSEOVER, delta));
355 } 358 }
356 359
357 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { 360 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) {
361 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
358 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 362 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
359 SetupMockDelegateAndPolicy(); 363 SetupMockDelegateAndPolicy();
360 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 364 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
361 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER)).Times(0); 365 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER, delta)).Times(0);
362 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 366 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
363 .WillOnce(testing::Return(false)); 367 .WillOnce(testing::Return(false));
364 368
365 content::WebContents* contents = web_contents(); 369 content::WebContents* contents = web_contents();
366 OnMessageReceived(ChromeViewHostMsg_LogEvent( 370 OnMessageReceived(ChromeViewHostMsg_LogEvent(
367 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), NTP_MOUSEOVER)); 371 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
372 NTP_MOUSEOVER, delta));
368 } 373 }
369 374
370 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { 375 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
371 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 376 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
372 SetupMockDelegateAndPolicy(); 377 SetupMockDelegateAndPolicy();
373 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 378 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
374 EXPECT_CALL(*mock_delegate(), 379 EXPECT_CALL(*mock_delegate(),
375 OnLogMostVisitedImpression(3, base::ASCIIToUTF16("Server"))).Times(1); 380 OnLogMostVisitedImpression(3, base::ASCIIToUTF16("Server"))).Times(1);
376 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 381 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
377 .WillOnce(testing::Return(true)); 382 .WillOnce(testing::Return(true));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0); 572 EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0);
568 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0); 573 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0);
569 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( 574 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
570 contents->GetRoutingID(), page_seq_no)); 575 contents->GetRoutingID(), page_seq_no));
571 576
572 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); 577 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0);
573 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0); 578 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0);
574 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox( 579 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox(
575 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE)); 580 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE));
576 581
577 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER)).Times(0); 582 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
583 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER, delta)).Times(0);
578 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); 584 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0);
579 OnMessageReceived(ChromeViewHostMsg_LogEvent( 585 OnMessageReceived(ChromeViewHostMsg_LogEvent(contents->GetRoutingID(),
580 contents->GetRoutingID(), page_seq_no, NTP_MOUSEOVER)); 586 page_seq_no,
587 NTP_MOUSEOVER, delta));
581 588
582 base::string16 text; 589 base::string16 text;
583 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); 590 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0);
584 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0); 591 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0);
585 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( 592 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown(
586 contents->GetRoutingID(), page_seq_no, text)); 593 contents->GetRoutingID(), page_seq_no, text));
587 } 594 }
588 595
589 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) { 596 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) {
590 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 597 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 906
900 // Construct a series of synthetic messages for each valid IPC message type, 907 // Construct a series of synthetic messages for each valid IPC message type,
901 // ensuring the router ignores them all. 908 // ensuring the router ignores them all.
902 for (int i = 0; i < LastIPCMsgStart; ++i) { 909 for (int i = 0; i < LastIPCMsgStart; ++i) {
903 const int message_id = i << 16; 910 const int message_id = i << 16;
904 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); 911 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i);
905 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); 912 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW);
906 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; 913 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i;
907 } 914 }
908 } 915 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router.cc ('k') | chrome/browser/ui/search/search_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698