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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
11 #include "chrome/browser/metrics/metrics_service_observer.h" | 11 #include "chrome/browser/metrics/metrics_service_observer.h" |
12 #include "chrome/browser/metrics/metrics_state_manager.h" | 12 #include "chrome/browser/metrics/metrics_state_manager.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/scoped_testing_local_state.h" | 15 #include "chrome/test/base/scoped_testing_local_state.h" |
16 #include "chrome/test/base/testing_browser_process.h" | 16 #include "chrome/test/base/testing_browser_process.h" |
17 #include "components/variations/metrics_util.h" | 17 #include "components/variations/metrics_util.h" |
18 #include "content/public/common/process_type.h" | 18 #include "content/public/common/process_type.h" |
19 #include "content/public/common/webplugininfo.h" | 19 #include "content/public/common/webplugininfo.h" |
20 #include "content/public/test/test_browser_thread_bundle.h" | 20 #include "content/public/test/test_browser_thread_bundle.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/gfx/size.h" | |
23 | 22 |
24 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
25 #include "chrome/browser/metrics/metrics_log_chromeos.h" | 24 #include "chrome/browser/metrics/metrics_log_chromeos.h" |
26 #endif // OS_CHROMEOS | 25 #endif // OS_CHROMEOS |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 using metrics::MetricsLogManager; | 29 using metrics::MetricsLogManager; |
31 | 30 |
32 class TestMetricsService : public MetricsService { | 31 class TestMetricsService : public MetricsService { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 TestMetricsLog(const std::string& client_id, int session_id) | 63 TestMetricsLog(const std::string& client_id, int session_id) |
65 : MetricsLog(client_id, session_id, MetricsLog::ONGOING_LOG) { | 64 : MetricsLog(client_id, session_id, MetricsLog::ONGOING_LOG) { |
66 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
67 metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( | 66 metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( |
68 MetricsLog::uma_proto())); | 67 MetricsLog::uma_proto())); |
69 #endif // OS_CHROMEOS | 68 #endif // OS_CHROMEOS |
70 } | 69 } |
71 virtual ~TestMetricsLog() {} | 70 virtual ~TestMetricsLog() {} |
72 | 71 |
73 private: | 72 private: |
74 virtual gfx::Size GetScreenSize() const OVERRIDE { | |
75 return gfx::Size(1024, 768); | |
76 } | |
77 | |
78 virtual float GetScreenDeviceScaleFactor() const OVERRIDE { | |
79 return 1.0f; | |
80 } | |
81 | |
82 virtual int GetScreenCount() const OVERRIDE { | |
83 return 1; | |
84 } | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 73 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
87 }; | 74 }; |
88 | 75 |
89 class MetricsServiceTest : public testing::Test { | 76 class MetricsServiceTest : public testing::Test { |
90 public: | 77 public: |
91 MetricsServiceTest() | 78 MetricsServiceTest() |
92 : testing_local_state_(TestingBrowserProcess::GetGlobal()), | 79 : testing_local_state_(TestingBrowserProcess::GetGlobal()), |
93 metrics_state_manager_(metrics::MetricsStateManager::Create( | 80 metrics_state_manager_(metrics::MetricsStateManager::Create( |
94 GetLocalState())) { | 81 GetLocalState())) { |
95 } | 82 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 342 |
356 service.RemoveObserver(&observer1); | 343 service.RemoveObserver(&observer1); |
357 | 344 |
358 service.OpenNewLog(); | 345 service.OpenNewLog(); |
359 EXPECT_EQ(2, observer1.observed()); | 346 EXPECT_EQ(2, observer1.observed()); |
360 EXPECT_EQ(2, observer2.observed()); | 347 EXPECT_EQ(2, observer2.observed()); |
361 service.log_manager_.FinishCurrentLog(); | 348 service.log_manager_.FinishCurrentLog(); |
362 | 349 |
363 service.RemoveObserver(&observer2); | 350 service.RemoveObserver(&observer2); |
364 } | 351 } |
OLD | NEW |