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

Side by Side Diff: components/metrics/persisted_logs_unittest.cc

Issue 2588873002: Delegate PersistedLogs metrics recording (Closed)
Patch Set: Fix tests Created 3 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
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 "components/metrics/persisted_logs.h" 5 #include "components/metrics/persisted_logs.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/sha1.h" 12 #include "base/sha1.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "components/metrics/persisted_logs_metrics_impl.h"
14 #include "components/prefs/pref_registry_simple.h" 15 #include "components/prefs/pref_registry_simple.h"
15 #include "components/prefs/scoped_user_pref_update.h" 16 #include "components/prefs/scoped_user_pref_update.h"
16 #include "components/prefs/testing_pref_service.h" 17 #include "components/prefs/testing_pref_service.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/zlib/google/compression_utils.h" 19 #include "third_party/zlib/google/compression_utils.h"
19 20
20 namespace metrics { 21 namespace metrics {
21 22
22 namespace { 23 namespace {
23 24
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 protected: 58 protected:
58 TestingPrefServiceSimple prefs_; 59 TestingPrefServiceSimple prefs_;
59 60
60 private: 61 private:
61 DISALLOW_COPY_AND_ASSIGN(PersistedLogsTest); 62 DISALLOW_COPY_AND_ASSIGN(PersistedLogsTest);
62 }; 63 };
63 64
64 class TestPersistedLogs : public PersistedLogs { 65 class TestPersistedLogs : public PersistedLogs {
65 public: 66 public:
66 TestPersistedLogs(PrefService* service, size_t min_log_bytes) 67 TestPersistedLogs(PrefService* service, size_t min_log_bytes)
67 : PersistedLogs(service, 68 : PersistedLogs(std::unique_ptr<PersistedLogsMetricsImpl>(
69 new PersistedLogsMetricsImpl()),
70 service,
68 kTestPrefName, 71 kTestPrefName,
69 kTestOutdatedPrefName, 72 kTestOutdatedPrefName,
70 kLogCountLimit, 73 kLogCountLimit,
71 min_log_bytes, 74 min_log_bytes,
72 0) {} 75 0) {}
73 76
74 // Stages and removes the next log, while testing it's value. 77 // Stages and removes the next log, while testing it's value.
75 void ExpectNextLog(const std::string& expected_log) { 78 void ExpectNextLog(const std::string& expected_log) {
76 StageLog(); 79 StageLog();
77 EXPECT_EQ(staged_log(), Compress(expected_log)); 80 EXPECT_EQ(staged_log(), Compress(expected_log));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 289
287 TestPersistedLogs persisted_logs(&prefs_, kLogByteLimit); 290 TestPersistedLogs persisted_logs(&prefs_, kLogByteLimit);
288 persisted_logs.StoreLog(kFooText); 291 persisted_logs.StoreLog(kFooText);
289 persisted_logs.StageLog(); 292 persisted_logs.StageLog();
290 293
291 EXPECT_EQ(Compress(kFooText), persisted_logs.staged_log()); 294 EXPECT_EQ(Compress(kFooText), persisted_logs.staged_log());
292 EXPECT_EQ(foo_hash, persisted_logs.staged_log_hash()); 295 EXPECT_EQ(foo_hash, persisted_logs.staged_log_hash());
293 } 296 }
294 297
295 } // namespace metrics 298 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/persisted_logs_metrics_impl.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698