| OLD | NEW |
| 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" |
| 6 |
| 7 #include <utility> |
| 8 |
| 5 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 10 #include "base/macros.h" |
| 7 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 8 #include "base/test/histogram_tester.h" | 12 #include "base/test/histogram_tester.h" |
| 9 #include "base/test/simple_test_clock.h" | 13 #include "base/test/simple_test_clock.h" |
| 10 #include "base/values.h" | 14 #include "base/values.h" |
| 11 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 12 #include "chrome/browser/engagement/site_engagement_helper.h" | 16 #include "chrome/browser/engagement/site_engagement_helper.h" |
| 13 #include "chrome/browser/engagement/site_engagement_metrics.h" | 17 #include "chrome/browser/engagement/site_engagement_metrics.h" |
| 14 #include "chrome/browser/engagement/site_engagement_service.h" | |
| 15 #include "chrome/browser/engagement/site_engagement_service_factory.h" | 18 #include "chrome/browser/engagement/site_engagement_service_factory.h" |
| 16 #include "chrome/browser/history/history_service_factory.h" | 19 #include "chrome/browser/history/history_service_factory.h" |
| 17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 18 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/browser_with_test_window_test.h" | 22 #include "chrome/test/base/browser_with_test_window_test.h" |
| 20 #include "components/content_settings/core/browser/content_settings_observer.h" | 23 #include "components/content_settings/core/browser/content_settings_observer.h" |
| 21 #include "components/content_settings/core/browser/host_content_settings_map.h" | 24 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 22 #include "components/history/core/browser/history_database_params.h" | 25 #include "components/history/core/browser/history_database_params.h" |
| 23 #include "components/history/core/browser/history_service.h" | 26 #include "components/history/core/browser/history_service.h" |
| 24 #include "components/history/core/test/test_history_database.h" | 27 #include "components/history/core/test/test_history_database.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 exploded_reference_time.millisecond = 0; | 83 exploded_reference_time.millisecond = 0; |
| 81 | 84 |
| 82 return base::Time::FromLocalExploded(exploded_reference_time); | 85 return base::Time::FromLocalExploded(exploded_reference_time); |
| 83 } | 86 } |
| 84 | 87 |
| 85 scoped_ptr<KeyedService> BuildTestHistoryService( | 88 scoped_ptr<KeyedService> BuildTestHistoryService( |
| 86 content::BrowserContext* context) { | 89 content::BrowserContext* context) { |
| 87 scoped_ptr<history::HistoryService> service(new history::HistoryService()); | 90 scoped_ptr<history::HistoryService> service(new history::HistoryService()); |
| 88 service->Init(std::string(), | 91 service->Init(std::string(), |
| 89 history::TestHistoryDatabaseParamsForPath(g_temp_history_dir)); | 92 history::TestHistoryDatabaseParamsForPath(g_temp_history_dir)); |
| 90 return service.Pass(); | 93 return std::move(service); |
| 91 } | 94 } |
| 92 | 95 |
| 93 } // namespace | 96 } // namespace |
| 94 | 97 |
| 95 class SiteEngagementScoreTest : public testing::Test { | 98 class SiteEngagementScoreTest : public testing::Test { |
| 96 public: | 99 public: |
| 97 SiteEngagementScoreTest() : score_(&test_clock_) {} | 100 SiteEngagementScoreTest() : score_(&test_clock_) {} |
| 98 | 101 |
| 99 protected: | 102 protected: |
| 100 void VerifyScore(const SiteEngagementScore& score, | 103 void VerifyScore(const SiteEngagementScore& score, |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 &task_tracker); | 923 &task_tracker); |
| 921 waiter.Wait(); | 924 waiter.Wait(); |
| 922 | 925 |
| 923 // Only origin3 remains. | 926 // Only origin3 remains. |
| 924 EXPECT_EQ(0, engagement->GetScore(origin1)); | 927 EXPECT_EQ(0, engagement->GetScore(origin1)); |
| 925 EXPECT_EQ(0, engagement->GetScore(origin2)); | 928 EXPECT_EQ(0, engagement->GetScore(origin2)); |
| 926 EXPECT_EQ(5.0, engagement->GetScore(origin3)); | 929 EXPECT_EQ(5.0, engagement->GetScore(origin3)); |
| 927 EXPECT_EQ(5.0, engagement->GetTotalEngagementPoints()); | 930 EXPECT_EQ(5.0, engagement->GetTotalEngagementPoints()); |
| 928 } | 931 } |
| 929 } | 932 } |
| OLD | NEW |