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

Side by Side Diff: chrome/browser/engagement/site_engagement_helper_unittest.cc

Issue 2042243004: Construct the site engagement helper with a site engagement service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use committed not visible URL Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/engagement/site_engagement_helper.h" 5 #include "chrome/browser/engagement/site_engagement_helper.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "base/timer/mock_timer.h" 9 #include "base/timer/mock_timer.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/engagement/site_engagement_score.h" 11 #include "chrome/browser/engagement/site_engagement_score.h"
12 #include "chrome/browser/engagement/site_engagement_service.h" 12 #include "chrome/browser/engagement/site_engagement_service.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
16 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/page_navigator.h" 17 #include "content/public/browser/page_navigator.h"
18 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
19 #include "content/public/test/web_contents_tester.h" 19 #include "content/public/test/web_contents_tester.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 class SiteEngagementHelperTest : public ChromeRenderViewHostTestHarness { 22 class SiteEngagementHelperTest : public ChromeRenderViewHostTestHarness {
23 public: 23 public:
24 void SetUp() override { 24 void SetUp() override {
25 ChromeRenderViewHostTestHarness::SetUp(); 25 ChromeRenderViewHostTestHarness::SetUp();
26 SiteEngagementScore::SetParamValuesForTesting(); 26 SiteEngagementScore::SetParamValuesForTesting();
27 } 27 }
28 28
29 SiteEngagementService::Helper* GetHelper(content::WebContents* web_contents) { 29 SiteEngagementService::Helper* GetHelper(content::WebContents* web_contents) {
30 SiteEngagementService::Helper::CreateForWebContents(web_contents); 30 SiteEngagementService* service = SiteEngagementService::Get(profile());
31 SiteEngagementService::Helper::CreateForWebContents(web_contents, service);
31 SiteEngagementService::Helper* helper = 32 SiteEngagementService::Helper* helper =
32 SiteEngagementService::Helper::FromWebContents(web_contents); 33 SiteEngagementService::Helper::FromWebContents(web_contents);
33 34
34 DCHECK(helper); 35 DCHECK(helper);
35 return helper; 36 return helper;
36 } 37 }
37 38
38 void TrackingStarted(SiteEngagementService::Helper* helper) { 39 void TrackingStarted(SiteEngagementService::Helper* helper) {
39 helper->input_tracker_.TrackingStarted(); 40 helper->input_tracker_.TrackingStarted();
40 helper->media_tracker_.TrackingStarted(); 41 helper->media_tracker_.TrackingStarted();
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // When the timer fires, callbacks are added. 570 // When the timer fires, callbacks are added.
570 input_tracker_timer->Fire(); 571 input_tracker_timer->Fire();
571 EXPECT_FALSE(input_tracker_timer->IsRunning()); 572 EXPECT_FALSE(input_tracker_timer->IsRunning());
572 EXPECT_TRUE(IsTrackingInput(helper)); 573 EXPECT_TRUE(IsTrackingInput(helper));
573 574
574 // Navigation should start the initial delay timer again. 575 // Navigation should start the initial delay timer again.
575 Navigate(url1); 576 Navigate(url1);
576 EXPECT_TRUE(input_tracker_timer->IsRunning()); 577 EXPECT_TRUE(input_tracker_timer->IsRunning());
577 EXPECT_FALSE(IsTrackingInput(helper)); 578 EXPECT_FALSE(IsTrackingInput(helper));
578 } 579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698