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

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

Issue 2117373002: Cleanup: Change LogMostVisitedImpression|Navigation APIs to take an enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ntp_uma_cleanup
Patch Set: rebase Created 4 years, 5 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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <tuple> 10 #include <tuple>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 virtual ~MockSearchIPCRouterDelegate() {} 49 virtual ~MockSearchIPCRouterDelegate() {}
50 50
51 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant)); 51 MOCK_METHOD1(OnInstantSupportDetermined, void(bool supports_instant));
52 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state)); 52 MOCK_METHOD1(FocusOmnibox, void(OmniboxFocusState state));
53 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url)); 53 MOCK_METHOD1(OnDeleteMostVisitedItem, void(const GURL& url));
54 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url)); 54 MOCK_METHOD1(OnUndoMostVisitedDeletion, void(const GURL& url));
55 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void()); 55 MOCK_METHOD0(OnUndoAllMostVisitedDeletions, void());
56 MOCK_METHOD2(OnLogEvent, void(NTPLoggingEventType event, 56 MOCK_METHOD2(OnLogEvent, void(NTPLoggingEventType event,
57 base::TimeDelta time)); 57 base::TimeDelta time));
58 MOCK_METHOD2(OnLogMostVisitedImpression, 58 MOCK_METHOD2(OnLogMostVisitedImpression,
59 void(int position, const base::string16& provider)); 59 void(int position, NTPLoggingTileSource tile_source));
60 MOCK_METHOD2(OnLogMostVisitedNavigation, 60 MOCK_METHOD2(OnLogMostVisitedNavigation,
61 void(int position, const base::string16& provider)); 61 void(int position, NTPLoggingTileSource tile_source));
62 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&)); 62 MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&));
63 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity)); 63 MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity));
64 MOCK_METHOD0(OnHistorySyncCheck, void()); 64 MOCK_METHOD0(OnHistorySyncCheck, void());
65 }; 65 };
66 66
67 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy { 67 class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
68 public: 68 public:
69 virtual ~MockSearchIPCRouterPolicy() {} 69 virtual ~MockSearchIPCRouterPolicy() {}
70 70
71 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool)); 71 MOCK_METHOD1(ShouldProcessFocusOmnibox, bool(bool));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 OnMessageReceived(ChromeViewHostMsg_LogEvent( 302 OnMessageReceived(ChromeViewHostMsg_LogEvent(
303 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 303 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
304 NTP_MOUSEOVER, delta)); 304 NTP_MOUSEOVER, 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, base::ASCIIToUTF16("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));
315 315
316 content::WebContents* contents = web_contents(); 316 content::WebContents* contents = web_contents();
317 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedImpression( 317 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedImpression(
318 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 3, 318 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 3,
319 base::ASCIIToUTF16("Server"))); 319 NTPLoggingTileSource::SERVER));
320 } 320 }
321 321
322 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) { 322 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) {
323 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 323 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
324 SetupMockDelegateAndPolicy(); 324 SetupMockDelegateAndPolicy();
325 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 325 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
326 EXPECT_CALL(*mock_delegate(), 326 EXPECT_CALL(*mock_delegate(),
327 OnLogMostVisitedNavigation(3, base::ASCIIToUTF16("Server"))).Times(1); 327 OnLogMostVisitedNavigation(3, NTPLoggingTileSource::SERVER)).Times(1);
328 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 328 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
329 .WillOnce(testing::Return(true)); 329 .WillOnce(testing::Return(true));
330 330
331 content::WebContents* contents = web_contents(); 331 content::WebContents* contents = web_contents();
332 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedNavigation( 332 OnMessageReceived(ChromeViewHostMsg_LogMostVisitedNavigation(
333 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 3, 333 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 3,
334 base::ASCIIToUTF16("Server"))); 334 NTPLoggingTileSource::SERVER));
335 } 335 }
336 336
337 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) { 337 TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) {
338 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 338 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
339 SetupMockDelegateAndPolicy(); 339 SetupMockDelegateAndPolicy();
340 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 340 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
341 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com"); 341 const base::string16 test_identity = base::ASCIIToUTF16("foo@bar.com");
342 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1); 342 EXPECT_CALL(*mock_delegate(), OnChromeIdentityCheck(test_identity)).Times(1);
343 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1) 343 EXPECT_CALL(*policy, ShouldProcessChromeIdentityCheck()).Times(1)
344 .WillOnce(testing::Return(true)); 344 .WillOnce(testing::Return(true));
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
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