| 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" |
| 11 #include "base/message_loop/message_loop.h" | |
| 12 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/test/base/scoped_testing_local_state.h" | 13 #include "chrome/test/base/scoped_testing_local_state.h" |
| 15 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "components/variations/metrics_util.h" | 15 #include "components/variations/metrics_util.h" |
| 17 #include "content/public/common/process_type.h" | 16 #include "content/public/common/process_type.h" |
| 18 #include "content/public/common/webplugininfo.h" | 17 #include "content/public/common/webplugininfo.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
| 22 | 21 |
| 23 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 24 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 23 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 25 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 24 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
| 26 #include "chromeos/dbus/fake_bluetooth_input_client.h" | 25 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
| 27 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 26 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
| 28 #endif // OS_CHROMEOS | 27 #endif // OS_CHROMEOS |
| 29 | 28 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 60 virtual int GetScreenCount() const OVERRIDE { | 59 virtual int GetScreenCount() const OVERRIDE { |
| 61 return 1; | 60 return 1; |
| 62 } | 61 } |
| 63 | 62 |
| 64 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 63 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 class MetricsServiceTest : public testing::Test { | 66 class MetricsServiceTest : public testing::Test { |
| 68 public: | 67 public: |
| 69 MetricsServiceTest() | 68 MetricsServiceTest() |
| 70 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 69 : testing_local_state_(TestingBrowserProcess::GetGlobal()) { |
| 71 testing_local_state_(TestingBrowserProcess::GetGlobal()) { | |
| 72 #if defined(OS_CHROMEOS) | 70 #if defined(OS_CHROMEOS) |
| 73 chromeos::FakeDBusThreadManager* fake_dbus_thread_manager = | 71 chromeos::FakeDBusThreadManager* fake_dbus_thread_manager = |
| 74 new chromeos::FakeDBusThreadManager; | 72 new chromeos::FakeDBusThreadManager; |
| 75 fake_dbus_thread_manager->SetBluetoothAdapterClient( | 73 fake_dbus_thread_manager->SetBluetoothAdapterClient( |
| 76 scoped_ptr<chromeos::BluetoothAdapterClient>( | 74 scoped_ptr<chromeos::BluetoothAdapterClient>( |
| 77 new chromeos::FakeBluetoothAdapterClient)); | 75 new chromeos::FakeBluetoothAdapterClient)); |
| 78 fake_dbus_thread_manager->SetBluetoothDeviceClient( | 76 fake_dbus_thread_manager->SetBluetoothDeviceClient( |
| 79 scoped_ptr<chromeos::BluetoothDeviceClient>( | 77 scoped_ptr<chromeos::BluetoothDeviceClient>( |
| 80 new chromeos::FakeBluetoothDeviceClient)); | 78 new chromeos::FakeBluetoothDeviceClient)); |
| 81 fake_dbus_thread_manager->SetBluetoothInputClient( | 79 fake_dbus_thread_manager->SetBluetoothInputClient( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 107 for (std::vector<chrome_variations::ActiveGroupId>::const_iterator it = | 105 for (std::vector<chrome_variations::ActiveGroupId>::const_iterator it = |
| 108 synthetic_trials.begin(); | 106 synthetic_trials.begin(); |
| 109 it != synthetic_trials.end(); ++it) { | 107 it != synthetic_trials.end(); ++it) { |
| 110 if ((*it).name == trial_name_hash && (*it).group == trial_group_hash) | 108 if ((*it).name == trial_name_hash && (*it).group == trial_group_hash) |
| 111 return true; | 109 return true; |
| 112 } | 110 } |
| 113 return false; | 111 return false; |
| 114 } | 112 } |
| 115 | 113 |
| 116 private: | 114 private: |
| 117 base::MessageLoopForUI message_loop_; | 115 content::TestBrowserThreadBundle thread_bundle_; |
| 118 content::TestBrowserThread ui_thread_; | |
| 119 ScopedTestingLocalState testing_local_state_; | 116 ScopedTestingLocalState testing_local_state_; |
| 120 | 117 |
| 121 DISALLOW_COPY_AND_ASSIGN(MetricsServiceTest); | 118 DISALLOW_COPY_AND_ASSIGN(MetricsServiceTest); |
| 122 }; | 119 }; |
| 123 | 120 |
| 124 } // namespace | 121 } // namespace |
| 125 | 122 |
| 126 // Ensure the ClientId is formatted as expected. | 123 // Ensure the ClientId is formatted as expected. |
| 127 TEST_F(MetricsServiceTest, ClientIdCorrectlyFormatted) { | 124 TEST_F(MetricsServiceTest, ClientIdCorrectlyFormatted) { |
| 128 std::string clientid = MetricsService::GenerateClientID(); | 125 std::string clientid = MetricsService::GenerateClientID(); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 service.log_manager_.FinishCurrentLog(); | 312 service.log_manager_.FinishCurrentLog(); |
| 316 service.log_manager_.BeginLoggingWithLog(new MetricsLog("clientID", 1), | 313 service.log_manager_.BeginLoggingWithLog(new MetricsLog("clientID", 1), |
| 317 MetricsLog::ONGOING_LOG); | 314 MetricsLog::ONGOING_LOG); |
| 318 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); | 315 service.GetCurrentSyntheticFieldTrials(&synthetic_trials); |
| 319 EXPECT_EQ(3U, synthetic_trials.size()); | 316 EXPECT_EQ(3U, synthetic_trials.size()); |
| 320 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); | 317 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial1", "Group2")); |
| 321 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); | 318 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial2", "Group2")); |
| 322 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); | 319 EXPECT_TRUE(HasSyntheticTrial(synthetic_trials, "TestTrial3", "Group3")); |
| 323 service.log_manager_.FinishCurrentLog(); | 320 service.log_manager_.FinishCurrentLog(); |
| 324 } | 321 } |
| OLD | NEW |