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

Side by Side Diff: components/metrics/metrics_service_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 "components/metrics/metrics_service.h" 5 #include "components/metrics/metrics_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "base/prefs/testing_pref_service.h" 12 #include "base/prefs/testing_pref_service.h"
12 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "components/metrics/client_info.h"
13 #include "components/metrics/compression_utils.h" 15 #include "components/metrics/compression_utils.h"
14 #include "components/metrics/metrics_log.h" 16 #include "components/metrics/metrics_log.h"
15 #include "components/metrics/metrics_pref_names.h" 17 #include "components/metrics/metrics_pref_names.h"
16 #include "components/metrics/metrics_service_observer.h" 18 #include "components/metrics/metrics_service_observer.h"
17 #include "components/metrics/metrics_state_manager.h" 19 #include "components/metrics/metrics_state_manager.h"
18 #include "components/metrics/test_metrics_service_client.h" 20 #include "components/metrics/test_metrics_service_client.h"
19 #include "components/variations/metrics_util.h" 21 #include "components/variations/metrics_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
21 23
22 namespace { 24 namespace {
23 25
24 using metrics::MetricsLogManager; 26 using metrics::MetricsLogManager;
25 27
28 void StoreNoClientInfoBackup(const metrics::ClientInfo& /* client_info */) {
29 }
30
31 scoped_ptr<metrics::ClientInfo> ReturnNoBackup() {
32 return scoped_ptr<metrics::ClientInfo>();
33 }
34
26 class TestMetricsService : public MetricsService { 35 class TestMetricsService : public MetricsService {
27 public: 36 public:
28 TestMetricsService(metrics::MetricsStateManager* state_manager, 37 TestMetricsService(metrics::MetricsStateManager* state_manager,
29 metrics::MetricsServiceClient* client, 38 metrics::MetricsServiceClient* client,
30 PrefService* local_state) 39 PrefService* local_state)
31 : MetricsService(state_manager, client, local_state) {} 40 : MetricsService(state_manager, client, local_state) {}
32 virtual ~TestMetricsService() {} 41 virtual ~TestMetricsService() {}
33 42
34 using MetricsService::log_manager; 43 using MetricsService::log_manager;
35 44
(...skipping 19 matching lines...) Expand all
55 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); 64 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog);
56 }; 65 };
57 66
58 class MetricsServiceTest : public testing::Test { 67 class MetricsServiceTest : public testing::Test {
59 public: 68 public:
60 MetricsServiceTest() : is_metrics_reporting_enabled_(false) { 69 MetricsServiceTest() : is_metrics_reporting_enabled_(false) {
61 MetricsService::RegisterPrefs(testing_local_state_.registry()); 70 MetricsService::RegisterPrefs(testing_local_state_.registry());
62 metrics_state_manager_ = metrics::MetricsStateManager::Create( 71 metrics_state_manager_ = metrics::MetricsStateManager::Create(
63 GetLocalState(), 72 GetLocalState(),
64 base::Bind(&MetricsServiceTest::is_metrics_reporting_enabled, 73 base::Bind(&MetricsServiceTest::is_metrics_reporting_enabled,
65 base::Unretained(this))); 74 base::Unretained(this)),
75 base::Bind(&StoreNoClientInfoBackup),
76 base::Bind(&ReturnNoBackup));
66 } 77 }
67 78
68 virtual ~MetricsServiceTest() { 79 virtual ~MetricsServiceTest() {
69 MetricsService::SetExecutionPhase(MetricsService::UNINITIALIZED_PHASE, 80 MetricsService::SetExecutionPhase(MetricsService::UNINITIALIZED_PHASE,
70 GetLocalState()); 81 GetLocalState());
71 } 82 }
72 83
73 metrics::MetricsStateManager* GetMetricsStateManager() { 84 metrics::MetricsStateManager* GetMetricsStateManager() {
74 return metrics_state_manager_.get(); 85 return metrics_state_manager_.get();
75 } 86 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 307
297 service.RemoveObserver(&observer1); 308 service.RemoveObserver(&observer1);
298 309
299 service.OpenNewLog(); 310 service.OpenNewLog();
300 EXPECT_EQ(2, observer1.observed()); 311 EXPECT_EQ(2, observer1.observed());
301 EXPECT_EQ(2, observer2.observed()); 312 EXPECT_EQ(2, observer2.observed());
302 service.log_manager_.FinishCurrentLog(); 313 service.log_manager_.FinishCurrentLog();
303 314
304 service.RemoveObserver(&observer2); 315 service.RemoveObserver(&observer2);
305 } 316 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698