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

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

Issue 1622413002: Update user input event's engagement value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@first_nav_bonus
Patch Set: address nits Created 4 years, 11 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
« no previous file with comments | « chrome/browser/engagement/site_engagement_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_service.h" 5 #include "chrome/browser/engagement/site_engagement_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 } // namespace 100 } // namespace
101 101
102 class SiteEngagementScoreTest : public testing::Test { 102 class SiteEngagementScoreTest : public testing::Test {
103 public: 103 public:
104 SiteEngagementScoreTest() : score_(&test_clock_) {} 104 SiteEngagementScoreTest() : score_(&test_clock_) {}
105 105
106 void SetUp() override { 106 void SetUp() override {
107 testing::Test::SetUp(); 107 testing::Test::SetUp();
108 // Disable the first engagement bonus for tests. 108 // Disable the first engagement bonus for tests.
109 SiteEngagementScore::DisableFirstDailyEngagementBonusForTesting(); 109 SiteEngagementScore::SetParamValuesForTesting();
110 } 110 }
111 111
112 protected: 112 protected:
113 void VerifyScore(const SiteEngagementScore& score, 113 void VerifyScore(const SiteEngagementScore& score,
114 double expected_raw_score, 114 double expected_raw_score,
115 double expected_points_added_today, 115 double expected_points_added_today,
116 base::Time expected_last_engagement_time) { 116 base::Time expected_last_engagement_time) {
117 EXPECT_EQ(expected_raw_score, score.raw_score_); 117 EXPECT_EQ(expected_raw_score, score.raw_score_);
118 EXPECT_EQ(expected_points_added_today, score.points_added_today_); 118 EXPECT_EQ(expected_points_added_today, score.points_added_today_);
119 EXPECT_EQ(expected_last_engagement_time, score.last_engagement_time_); 119 EXPECT_EQ(expected_last_engagement_time, score.last_engagement_time_);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 449 }
450 450
451 class SiteEngagementServiceTest : public ChromeRenderViewHostTestHarness { 451 class SiteEngagementServiceTest : public ChromeRenderViewHostTestHarness {
452 public: 452 public:
453 void SetUp() override { 453 void SetUp() override {
454 ChromeRenderViewHostTestHarness::SetUp(); 454 ChromeRenderViewHostTestHarness::SetUp();
455 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 455 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
456 g_temp_history_dir = temp_dir_.path(); 456 g_temp_history_dir = temp_dir_.path();
457 HistoryServiceFactory::GetInstance()->SetTestingFactory( 457 HistoryServiceFactory::GetInstance()->SetTestingFactory(
458 profile(), &BuildTestHistoryService); 458 profile(), &BuildTestHistoryService);
459 SiteEngagementScore::DisableFirstDailyEngagementBonusForTesting(); 459 SiteEngagementScore::SetParamValuesForTesting();
460 } 460 }
461 461
462 void NavigateWithTransitionAndExpectHigherScore( 462 void NavigateWithTransitionAndExpectHigherScore(
463 SiteEngagementService* service, 463 SiteEngagementService* service,
464 const GURL& url, 464 const GURL& url,
465 ui::PageTransition transition) { 465 ui::PageTransition transition) {
466 double prev_score = service->GetScore(url); 466 double prev_score = service->GetScore(url);
467 controller().LoadURL(url, content::Referrer(), transition, std::string()); 467 controller().LoadURL(url, content::Referrer(), transition, std::string());
468 int pending_id = controller().GetPendingEntry()->GetUniqueID(); 468 int pending_id = controller().GetPendingEntry()->GetUniqueID();
469 content::WebContentsTester::For(web_contents()) 469 content::WebContentsTester::For(web_contents())
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 &task_tracker); 1126 &task_tracker);
1127 waiter.Wait(); 1127 waiter.Wait();
1128 1128
1129 // Only origin3 remains. 1129 // Only origin3 remains.
1130 EXPECT_EQ(0, engagement->GetScore(origin1)); 1130 EXPECT_EQ(0, engagement->GetScore(origin1));
1131 EXPECT_EQ(0, engagement->GetScore(origin2)); 1131 EXPECT_EQ(0, engagement->GetScore(origin2));
1132 EXPECT_EQ(5.0, engagement->GetScore(origin3)); 1132 EXPECT_EQ(5.0, engagement->GetScore(origin3));
1133 EXPECT_EQ(5.0, engagement->GetTotalEngagementPoints()); 1133 EXPECT_EQ(5.0, engagement->GetTotalEngagementPoints());
1134 } 1134 }
1135 } 1135 }
OLDNEW
« no previous file with comments | « chrome/browser/engagement/site_engagement_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698