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

Side by Side Diff: chrome/browser/metrics/extensions_metrics_provider_unittest.cc

Issue 372473004: Retrieve client_id from GoogleUpdateSettings when its missing from Local State. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: put dependency back for installer_util_nacl_win64 fixes compile?! Created 6 years, 5 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 | Annotate | Revision Log
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 "chrome/browser/metrics/extensions_metrics_provider.h" 5 #include "chrome/browser/metrics/extensions_metrics_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
11 #include "components/metrics/client_info.h"
10 #include "components/metrics/metrics_state_manager.h" 12 #include "components/metrics/metrics_state_manager.h"
11 #include "components/metrics/proto/system_profile.pb.h" 13 #include "components/metrics/proto/system_profile.pb.h"
12 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
13 #include "extensions/common/extension_builder.h" 15 #include "extensions/common/extension_builder.h"
14 #include "extensions/common/extension_set.h" 16 #include "extensions/common/extension_set.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 namespace { 19 namespace {
18 20
19 bool IsMetricsReportingEnabled() { 21 bool IsMetricsReportingEnabled() {
20 return true; 22 return true;
21 } 23 }
22 24
25 void StoreNoClientInfoBackup(const metrics::ClientInfo& /* client_info */) {
26 }
27
28 scoped_ptr<metrics::ClientInfo> ReturnNoBackup() {
29 return scoped_ptr<metrics::ClientInfo>();
30 }
31
23 class TestExtensionsMetricsProvider : public ExtensionsMetricsProvider { 32 class TestExtensionsMetricsProvider : public ExtensionsMetricsProvider {
24 public: 33 public:
25 explicit TestExtensionsMetricsProvider( 34 explicit TestExtensionsMetricsProvider(
26 metrics::MetricsStateManager* metrics_state_manager) 35 metrics::MetricsStateManager* metrics_state_manager)
27 : ExtensionsMetricsProvider(metrics_state_manager) {} 36 : ExtensionsMetricsProvider(metrics_state_manager) {}
28 37
29 // Makes the protected HashExtension method available to testing code. 38 // Makes the protected HashExtension method available to testing code.
30 using ExtensionsMetricsProvider::HashExtension; 39 using ExtensionsMetricsProvider::HashExtension;
31 40
32 protected: 41 protected:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 "mdhofdjgenpkhlmddfaegdjddcecipmo", 3817)); 97 "mdhofdjgenpkhlmddfaegdjddcecipmo", 3817));
89 } 98 }
90 99
91 // Checks that the fake set of extensions provided by 100 // Checks that the fake set of extensions provided by
92 // TestExtensionsMetricsProvider is encoded properly. 101 // TestExtensionsMetricsProvider is encoded properly.
93 TEST(ExtensionsMetricsProvider, SystemProtoEncoding) { 102 TEST(ExtensionsMetricsProvider, SystemProtoEncoding) {
94 metrics::SystemProfileProto system_profile; 103 metrics::SystemProfileProto system_profile;
95 TestingPrefServiceSimple local_state; 104 TestingPrefServiceSimple local_state;
96 metrics::MetricsStateManager::RegisterPrefs(local_state.registry()); 105 metrics::MetricsStateManager::RegisterPrefs(local_state.registry());
97 scoped_ptr<metrics::MetricsStateManager> metrics_state_manager( 106 scoped_ptr<metrics::MetricsStateManager> metrics_state_manager(
98 metrics::MetricsStateManager::Create(&local_state, 107 metrics::MetricsStateManager::Create(
99 base::Bind(&IsMetricsReportingEnabled))); 108 &local_state,
109 base::Bind(&IsMetricsReportingEnabled),
110 base::Bind(&StoreNoClientInfoBackup),
111 base::Bind(&ReturnNoBackup)));
100 TestExtensionsMetricsProvider extension_metrics(metrics_state_manager.get()); 112 TestExtensionsMetricsProvider extension_metrics(metrics_state_manager.get());
101 extension_metrics.ProvideSystemProfileMetrics(&system_profile); 113 extension_metrics.ProvideSystemProfileMetrics(&system_profile);
102 ASSERT_EQ(2, system_profile.occupied_extension_bucket_size()); 114 ASSERT_EQ(2, system_profile.occupied_extension_bucket_size());
103 EXPECT_EQ(10, system_profile.occupied_extension_bucket(0)); 115 EXPECT_EQ(10, system_profile.occupied_extension_bucket(0));
104 EXPECT_EQ(1007, system_profile.occupied_extension_bucket(1)); 116 EXPECT_EQ(1007, system_profile.occupied_extension_bucket(1));
105 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698