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

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

Issue 2429523002: Cleanup desktop NTP metrics recording (Closed)
Patch Set: . Created 4 years, 2 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_TILE, delta)).Times(1); 262 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta))
263 .Times(1);
263 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 264 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
264 .WillOnce(testing::Return(true)); 265 .WillOnce(testing::Return(true));
265 266
266 content::WebContents* contents = web_contents(); 267 content::WebContents* contents = web_contents();
267 OnMessageReceived(ChromeViewHostMsg_LogEvent( 268 OnMessageReceived(ChromeViewHostMsg_LogEvent(
268 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 269 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
269 NTP_TILE, delta)); 270 NTP_CLIENT_SIDE_SUGGESTION, delta));
270 } 271 }
271 272
272 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) { 273 TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) {
273 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); 274 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
274 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); 275 NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
275 SetupMockDelegateAndPolicy(); 276 SetupMockDelegateAndPolicy();
276 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 277 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
277 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(0); 278 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta))
279 .Times(0);
278 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 280 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
279 .WillOnce(testing::Return(false)); 281 .WillOnce(testing::Return(false));
280 282
281 content::WebContents* contents = web_contents(); 283 content::WebContents* contents = web_contents();
282 OnMessageReceived(ChromeViewHostMsg_LogEvent( 284 OnMessageReceived(ChromeViewHostMsg_LogEvent(
283 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 285 contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
284 NTP_TILE, delta)); 286 NTP_CLIENT_SIDE_SUGGESTION, delta));
285 } 287 }
286 288
287 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) { 289 TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
288 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 290 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
289 SetupMockDelegateAndPolicy(); 291 SetupMockDelegateAndPolicy();
290 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); 292 MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
291 EXPECT_CALL(*mock_delegate(), 293 EXPECT_CALL(*mock_delegate(),
292 OnLogMostVisitedImpression(3, NTPLoggingTileSource::SERVER)).Times(1); 294 OnLogMostVisitedImpression(3, NTPLoggingTileSource::SERVER)).Times(1);
293 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1) 295 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(1)
294 .WillOnce(testing::Return(true)); 296 .WillOnce(testing::Return(true));
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0); 481 EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0);
480 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions( 482 OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
481 contents->GetRoutingID(), page_seq_no)); 483 contents->GetRoutingID(), page_seq_no));
482 484
483 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0); 485 EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0);
484 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0); 486 EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0);
485 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox( 487 OnMessageReceived(ChromeViewHostMsg_FocusOmnibox(
486 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE)); 488 contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE));
487 489
488 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123); 490 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(123);
489 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_TILE, delta)).Times(0); 491 EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_CLIENT_SIDE_SUGGESTION, delta))
492 .Times(0);
490 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0); 493 EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0);
491 OnMessageReceived(ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), 494 OnMessageReceived(
492 page_seq_no, 495 ChromeViewHostMsg_LogEvent(contents->GetRoutingID(), page_seq_no,
493 NTP_TILE, delta)); 496 NTP_CLIENT_SIDE_SUGGESTION, delta));
494 497
495 base::string16 text; 498 base::string16 text;
496 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0); 499 EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0);
497 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0); 500 EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0);
498 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown( 501 OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown(
499 contents->GetRoutingID(), page_seq_no, text)); 502 contents->GetRoutingID(), page_seq_no, text));
500 } 503 }
501 504
502 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) { 505 TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) {
503 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); 506 NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 698
696 // 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,
697 // ensuring the router ignores them all. 700 // ensuring the router ignores them all.
698 for (int i = 0; i < LastIPCMsgStart; ++i) { 701 for (int i = 0; i < LastIPCMsgStart; ++i) {
699 const int message_id = i << 16; 702 const int message_id = i << 16;
700 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i); 703 ASSERT_EQ(IPC_MESSAGE_ID_CLASS(message_id), i);
701 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW); 704 IPC::Message msg(routing_id, message_id, IPC::Message::PRIORITY_LOW);
702 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i; 705 EXPECT_FALSE(OnSpuriousMessageReceived(msg)) << i;
703 } 706 }
704 } 707 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/most_visited_util.js ('k') | chrome/browser/ui/webui/ntp/ntp_user_data_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698