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

Side by Side Diff: chrome/browser/extensions/activity_log/ad_injection_unittest.cc

Issue 511623002: Add a mechanism for collecting Rappor samples on a daily interval. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/prefs/testing_pref_service.h"
5 #include "base/time/time.h" 6 #include "base/time/time.h"
6 #include "chrome/browser/extensions/activity_log/activity_actions.h" 7 #include "chrome/browser/extensions/activity_log/activity_actions.h"
7 #include "components/rappor/byte_vector_utils.h" 8 #include "components/rappor/byte_vector_utils.h"
8 #include "components/rappor/proto/rappor_metric.pb.h" 9 #include "components/rappor/proto/rappor_metric.pb.h"
9 #include "components/rappor/rappor_service.h" 10 #include "components/rappor/rappor_service.h"
10 #include "extensions/common/value_builder.h" 11 #include "extensions/common/value_builder.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace extensions { 14 namespace extensions {
14 15
(...skipping 20 matching lines...) Expand all
35 class TestRapporService : public rappor::RapporService { 36 class TestRapporService : public rappor::RapporService {
36 public: 37 public:
37 TestRapporService(); 38 TestRapporService();
38 virtual ~TestRapporService(); 39 virtual ~TestRapporService();
39 40
40 // Returns the active reports. This also clears the internal map of metrics 41 // Returns the active reports. This also clears the internal map of metrics
41 // as a biproduct, so if comparing numbers of reports, the comparison should 42 // as a biproduct, so if comparing numbers of reports, the comparison should
42 // be from the last time GetReports() was called (not from the beginning of 43 // be from the last time GetReports() was called (not from the beginning of
43 // the test). 44 // the test).
44 rappor::RapporReports GetReports(); 45 rappor::RapporReports GetReports();
46
47 protected:
48 TestingPrefServiceSimple prefs_;
45 }; 49 };
46 50
47 TestRapporService::TestRapporService() { 51 TestRapporService::TestRapporService()
52 : rappor::RapporService(&prefs_) {
48 // Initialize the RapporService for testing. 53 // Initialize the RapporService for testing.
49 SetCohortForTesting(0); 54 SetCohortForTesting(0);
50 SetSecretForTesting(rappor::HmacByteVectorGenerator::GenerateEntropyInput()); 55 SetSecretForTesting(rappor::HmacByteVectorGenerator::GenerateEntropyInput());
51 } 56 }
52 57
53 TestRapporService::~TestRapporService() {} 58 TestRapporService::~TestRapporService() {}
54 59
55 rappor::RapporReports TestRapporService::GetReports() { 60 rappor::RapporReports TestRapporService::GetReports() {
56 rappor::RapporReports result; 61 rappor::RapporReports result;
57 rappor::RapporService::ExportMetrics(&result); 62 rappor::RapporService::ExportMetrics(&result);
(...skipping 20 matching lines...) Expand all
78 EXPECT_EQ(1, reports.report_size()); 83 EXPECT_EQ(1, reports.report_size());
79 84
80 scoped_refptr<Action> harmless_action = 85 scoped_refptr<Action> harmless_action =
81 CreateAction("Location.replace", "", ""); 86 CreateAction("Location.replace", "", "");
82 harmless_action->DidInjectAd(&rappor_service); 87 harmless_action->DidInjectAd(&rappor_service);
83 reports = rappor_service.GetReports(); 88 reports = rappor_service.GetReports();
84 EXPECT_EQ(0, reports.report_size()); 89 EXPECT_EQ(0, reports.report_size());
85 } 90 }
86 91
87 } // namespace extensions 92 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/metrics/metrics_services_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698