| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_score.h" | 5 #include "chrome/browser/engagement/site_engagement_score.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/test/simple_test_clock.h" | 10 #include "base/test/simple_test_clock.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 base::Time::Exploded exploded_reference_time; | 26 base::Time::Exploded exploded_reference_time; |
| 27 exploded_reference_time.year = 2015; | 27 exploded_reference_time.year = 2015; |
| 28 exploded_reference_time.month = 1; | 28 exploded_reference_time.month = 1; |
| 29 exploded_reference_time.day_of_month = 30; | 29 exploded_reference_time.day_of_month = 30; |
| 30 exploded_reference_time.day_of_week = 5; | 30 exploded_reference_time.day_of_week = 5; |
| 31 exploded_reference_time.hour = 11; | 31 exploded_reference_time.hour = 11; |
| 32 exploded_reference_time.minute = 0; | 32 exploded_reference_time.minute = 0; |
| 33 exploded_reference_time.second = 0; | 33 exploded_reference_time.second = 0; |
| 34 exploded_reference_time.millisecond = 0; | 34 exploded_reference_time.millisecond = 0; |
| 35 | 35 |
| 36 return base::Time::FromLocalExploded(exploded_reference_time); | 36 base::Time out_time; |
| 37 EXPECT_TRUE( |
| 38 base::Time::FromLocalExploded(exploded_reference_time, &out_time)); |
| 39 return out_time; |
| 37 } | 40 } |
| 38 | 41 |
| 39 } // namespace | 42 } // namespace |
| 40 | 43 |
| 41 class SiteEngagementScoreTest : public testing::Test { | 44 class SiteEngagementScoreTest : public testing::Test { |
| 42 public: | 45 public: |
| 43 SiteEngagementScoreTest() : score_(&test_clock_, nullptr) {} | 46 SiteEngagementScoreTest() : score_(&test_clock_, nullptr) {} |
| 44 | 47 |
| 45 void SetUp() override { | 48 void SetUp() override { |
| 46 testing::Test::SetUp(); | 49 testing::Test::SetUp(); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 EXPECT_DOUBLE_EQ(2.0, score_.GetScore()); | 438 EXPECT_DOUBLE_EQ(2.0, score_.GetScore()); |
| 436 | 439 |
| 437 // Ensure point removal happens after proportional decay. | 440 // Ensure point removal happens after proportional decay. |
| 438 score_.AddPoints(4.0); | 441 score_.AddPoints(4.0); |
| 439 EXPECT_DOUBLE_EQ(6.0, score_.GetScore()); | 442 EXPECT_DOUBLE_EQ(6.0, score_.GetScore()); |
| 440 SetParamValue(SiteEngagementScore::DECAY_POINTS, 2.0); | 443 SetParamValue(SiteEngagementScore::DECAY_POINTS, 2.0); |
| 441 current_day += base::TimeDelta::FromDays(7); | 444 current_day += base::TimeDelta::FromDays(7); |
| 442 test_clock_.SetNow(current_day); | 445 test_clock_.SetNow(current_day); |
| 443 EXPECT_DOUBLE_EQ(1.0, score_.GetScore()); | 446 EXPECT_DOUBLE_EQ(1.0, score_.GetScore()); |
| 444 } | 447 } |
| OLD | NEW |