OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/metrics_service.h" | 5 #include "chrome/browser/metrics/metrics_service.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 virtual ~TestMetricsService() {} | 27 virtual ~TestMetricsService() {} |
28 | 28 |
29 MetricsLogManager* log_manager() { | 29 MetricsLogManager* log_manager() { |
30 return &log_manager_; | 30 return &log_manager_; |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(TestMetricsService); | 34 DISALLOW_COPY_AND_ASSIGN(TestMetricsService); |
35 }; | 35 }; |
36 | 36 |
| 37 #if defined(OS_CHROMEOS) |
| 38 class TestMetricsLogChromeOS : public MetricsLogChromeOS { |
| 39 public: |
| 40 explicit TestMetricsLogChromeOS( |
| 41 metrics::SystemProfileProto* system_profile) |
| 42 : MetricsLogChromeOS(system_profile) { |
| 43 } |
| 44 |
| 45 protected: |
| 46 // Don't touch bluetooth information, as it won't be correctly initialized. |
| 47 virtual void WriteBluetoothProto( |
| 48 metrics::SystemProfileProto::Hardware* hardware) OVERRIDE { |
| 49 } |
| 50 }; |
| 51 #endif // OS_CHROMEOS |
| 52 |
37 class TestMetricsLog : public MetricsLog { | 53 class TestMetricsLog : public MetricsLog { |
38 public: | 54 public: |
39 TestMetricsLog(const std::string& client_id, int session_id) | 55 TestMetricsLog(const std::string& client_id, int session_id) |
40 : MetricsLog(client_id, session_id) {} | 56 : MetricsLog(client_id, session_id) { |
| 57 #if defined(OS_CHROMEOS) |
| 58 metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( |
| 59 MetricsLog::uma_proto()->mutable_system_profile())); |
| 60 #endif // OS_CHROMEOS |
| 61 } |
41 virtual ~TestMetricsLog() {} | 62 virtual ~TestMetricsLog() {} |
42 | 63 |
43 private: | 64 private: |
44 virtual gfx::Size GetScreenSize() const OVERRIDE { | 65 virtual gfx::Size GetScreenSize() const OVERRIDE { |
45 return gfx::Size(1024, 768); | 66 return gfx::Size(1024, 768); |
46 } | 67 } |
47 | 68 |
48 virtual float GetScreenDeviceScaleFactor() const OVERRIDE { | 69 virtual float GetScreenDeviceScaleFactor() const OVERRIDE { |
49 return 1.0f; | 70 return 1.0f; |
50 } | 71 } |
51 | 72 |
52 virtual int GetScreenCount() const OVERRIDE { | 73 virtual int GetScreenCount() const OVERRIDE { |
53 return 1; | 74 return 1; |
54 } | 75 } |
55 | 76 |
56 virtual void WriteBluetoothProto( | |
57 metrics::SystemProfileProto::Hardware* hardware) OVERRIDE { | |
58 } | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 77 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
61 }; | 78 }; |
62 | 79 |
63 class MetricsServiceTest : public testing::Test { | 80 class MetricsServiceTest : public testing::Test { |
64 public: | 81 public: |
65 MetricsServiceTest() | 82 MetricsServiceTest() |
66 : testing_local_state_(TestingBrowserProcess::GetGlobal()) { | 83 : testing_local_state_(TestingBrowserProcess::GetGlobal()) { |
67 } | 84 } |
68 | 85 |
69 virtual ~MetricsServiceTest() { | 86 virtual ~MetricsServiceTest() { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 service.log_manager_.FinishCurrentLog(); | 309 service.log_manager_.FinishCurrentLog(); |
293 service.log_manager_.BeginLoggingWithLog(new MetricsLog("clientID", 1), | 310 service.log_manager_.BeginLoggingWithLog(new MetricsLog("clientID", 1), |
294 MetricsLog::ONGOING_LOG); | 311 MetricsLog::ONGOING_LOG); |
295 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); | 312 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); |
296 EXPECT_EQ(3U, synthetic_trials.size()); | 313 EXPECT_EQ(3U, synthetic_trials.size()); |
297 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); | 314 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); |
298 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); | 315 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); |
299 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); | 316 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); |
300 service.log_manager_.FinishCurrentLog(); | 317 service.log_manager_.FinishCurrentLog(); |
301 } | 318 } |
OLD | NEW |