| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "chrome/browser/metrics/metrics_state_manager.h" | 11 #include "chrome/browser/metrics/metrics_state_manager.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/test/base/scoped_testing_local_state.h" | 13 #include "chrome/test/base/scoped_testing_local_state.h" |
| 14 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
| 15 #include "components/metrics/metrics_log_base.h" | 15 #include "components/metrics/metrics_log_base.h" |
| 16 #include "components/metrics/metrics_service_observer.h" | 16 #include "components/metrics/metrics_service_observer.h" |
| 17 #include "components/metrics/test_metrics_service_client.h" | 17 #include "components/metrics/test_metrics_service_client.h" |
| 18 #include "components/variations/metrics_util.h" | 18 #include "components/variations/metrics_util.h" |
| 19 #include "content/public/common/process_type.h" | 19 #include "content/public/common/process_type.h" |
| 20 #include "content/public/common/webplugininfo.h" | 20 #include "content/public/common/webplugininfo.h" |
| 21 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "ui/gfx/size.h" | |
| 24 | 23 |
| 25 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 26 #include "chrome/browser/metrics/metrics_log_chromeos.h" | 25 #include "chrome/browser/metrics/metrics_log_chromeos.h" |
| 27 #endif // OS_CHROMEOS | 26 #endif // OS_CHROMEOS |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 using metrics::MetricsLogManager; | 30 using metrics::MetricsLogManager; |
| 32 | 31 |
| 33 class TestMetricsService : public MetricsService { | 32 class TestMetricsService : public MetricsService { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 metrics::MetricsServiceClient* client) | 64 metrics::MetricsServiceClient* client) |
| 66 : MetricsLog(client_id, session_id, MetricsLog::ONGOING_LOG, client) { | 65 : MetricsLog(client_id, session_id, MetricsLog::ONGOING_LOG, client) { |
| 67 #if defined(OS_CHROMEOS) | 66 #if defined(OS_CHROMEOS) |
| 68 metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( | 67 metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( |
| 69 MetricsLog::uma_proto())); | 68 MetricsLog::uma_proto())); |
| 70 #endif // OS_CHROMEOS | 69 #endif // OS_CHROMEOS |
| 71 } | 70 } |
| 72 virtual ~TestMetricsLog() {} | 71 virtual ~TestMetricsLog() {} |
| 73 | 72 |
| 74 private: | 73 private: |
| 75 virtual gfx::Size GetScreenSize() const OVERRIDE { | |
| 76 return gfx::Size(1024, 768); | |
| 77 } | |
| 78 | |
| 79 virtual float GetScreenDeviceScaleFactor() const OVERRIDE { | |
| 80 return 1.0f; | |
| 81 } | |
| 82 | |
| 83 virtual int GetScreenCount() const OVERRIDE { | |
| 84 return 1; | |
| 85 } | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 74 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
| 88 }; | 75 }; |
| 89 | 76 |
| 90 class MetricsServiceTest : public testing::Test { | 77 class MetricsServiceTest : public testing::Test { |
| 91 public: | 78 public: |
| 92 MetricsServiceTest() | 79 MetricsServiceTest() |
| 93 : testing_local_state_(TestingBrowserProcess::GetGlobal()), | 80 : testing_local_state_(TestingBrowserProcess::GetGlobal()), |
| 94 is_metrics_reporting_enabled_(false), | 81 is_metrics_reporting_enabled_(false), |
| 95 metrics_state_manager_( | 82 metrics_state_manager_( |
| 96 metrics::MetricsStateManager::Create( | 83 metrics::MetricsStateManager::Create( |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 317 |
| 331 service.RemoveObserver(&observer1); | 318 service.RemoveObserver(&observer1); |
| 332 | 319 |
| 333 service.OpenNewLog(); | 320 service.OpenNewLog(); |
| 334 EXPECT_EQ(2, observer1.observed()); | 321 EXPECT_EQ(2, observer1.observed()); |
| 335 EXPECT_EQ(2, observer2.observed()); | 322 EXPECT_EQ(2, observer2.observed()); |
| 336 service.log_manager_.FinishCurrentLog(); | 323 service.log_manager_.FinishCurrentLog(); |
| 337 | 324 |
| 338 service.RemoveObserver(&observer2); | 325 service.RemoveObserver(&observer2); |
| 339 } | 326 } |
| OLD | NEW |