| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "content/public/common/process_type.h" | 31 #include "content/public/common/process_type.h" |
| 32 #include "content/public/common/webplugininfo.h" | 32 #include "content/public/common/webplugininfo.h" |
| 33 #include "content/public/test/test_utils.h" | 33 #include "content/public/test/test_utils.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 35 #include "ui/gfx/size.h" | 35 #include "ui/gfx/size.h" |
| 36 #include "url/gurl.h" | 36 #include "url/gurl.h" |
| 37 | 37 |
| 38 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
| 39 #include "chrome/browser/chromeos/login/fake_user_manager.h" | 39 #include "chrome/browser/chromeos/login/fake_user_manager.h" |
| 40 #include "chrome/browser/chromeos/login/user_manager.h" | 40 #include "chrome/browser/chromeos/login/user_manager.h" |
| 41 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 42 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
| 43 #include "chromeos/dbus/fake_bluetooth_input_client.h" |
| 41 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 44 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
| 42 #endif // OS_CHROMEOS | 45 #endif // OS_CHROMEOS |
| 43 | 46 |
| 44 using base::TimeDelta; | 47 using base::TimeDelta; |
| 45 using metrics::ProfilerEventProto; | 48 using metrics::ProfilerEventProto; |
| 46 using tracked_objects::ProcessDataSnapshot; | 49 using tracked_objects::ProcessDataSnapshot; |
| 47 using tracked_objects::TaskSnapshot; | 50 using tracked_objects::TaskSnapshot; |
| 48 | 51 |
| 49 namespace { | 52 namespace { |
| 50 | 53 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 EXPECT_TRUE(hardware.has_cpu()); | 172 EXPECT_TRUE(hardware.has_cpu()); |
| 170 EXPECT_TRUE(hardware.cpu().has_vendor_name()); | 173 EXPECT_TRUE(hardware.cpu().has_vendor_name()); |
| 171 EXPECT_TRUE(hardware.cpu().has_signature()); | 174 EXPECT_TRUE(hardware.cpu().has_signature()); |
| 172 | 175 |
| 173 // TODO(isherman): Verify other data written into the protobuf as a result | 176 // TODO(isherman): Verify other data written into the protobuf as a result |
| 174 // of this call. | 177 // of this call. |
| 175 } | 178 } |
| 176 | 179 |
| 177 virtual void SetUp() OVERRIDE { | 180 virtual void SetUp() OVERRIDE { |
| 178 #if defined(OS_CHROMEOS) | 181 #if defined(OS_CHROMEOS) |
| 179 fake_dbus_thread_manager_ = new chromeos::FakeDBusThreadManager(); | 182 chromeos::FakeDBusThreadManager* fake_dbus_thread_manager = |
| 180 chromeos::DBusThreadManager::InitializeForTesting( | 183 new chromeos::FakeDBusThreadManager; |
| 181 fake_dbus_thread_manager_); | 184 fake_dbus_thread_manager->SetBluetoothAdapterClient( |
| 185 scoped_ptr<chromeos::BluetoothAdapterClient>( |
| 186 new chromeos::FakeBluetoothAdapterClient)); |
| 187 fake_dbus_thread_manager->SetBluetoothDeviceClient( |
| 188 scoped_ptr<chromeos::BluetoothDeviceClient>( |
| 189 new chromeos::FakeBluetoothDeviceClient)); |
| 190 fake_dbus_thread_manager->SetBluetoothInputClient( |
| 191 scoped_ptr<chromeos::BluetoothInputClient>( |
| 192 new chromeos::FakeBluetoothInputClient)); |
| 193 chromeos::DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager); |
| 182 | 194 |
| 183 // Enable multi-profiles. | 195 // Enable multi-profiles. |
| 184 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles); | 196 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kMultiProfiles); |
| 185 field_trial_list_.reset(new base::FieldTrialList( | 197 field_trial_list_.reset(new base::FieldTrialList( |
| 186 new metrics::SHA1EntropyProvider("42"))); | 198 new metrics::SHA1EntropyProvider("42"))); |
| 187 base::FieldTrialList::CreateTrialsFromString( | 199 base::FieldTrialList::CreateTrialsFromString( |
| 188 "ChromeOSUseMultiProfiles/Enable/", | 200 "ChromeOSUseMultiProfiles/Enable/", |
| 189 base::FieldTrialList::ACTIVATE_TRIALS); | 201 base::FieldTrialList::ACTIVATE_TRIALS); |
| 190 #endif // OS_CHROMEOS | 202 #endif // OS_CHROMEOS |
| 191 } | 203 } |
| 192 | 204 |
| 193 virtual void TearDown() OVERRIDE { | 205 virtual void TearDown() OVERRIDE { |
| 194 // Drain the blocking pool from PostTaskAndReply executed by | 206 // Drain the blocking pool from PostTaskAndReply executed by |
| 195 // MetrticsLog.network_observer_. | 207 // MetrticsLog.network_observer_. |
| 196 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 208 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 197 content::RunAllPendingInMessageLoop(); | 209 content::RunAllPendingInMessageLoop(); |
| 198 | 210 |
| 199 #if defined(OS_CHROMEOS) | 211 #if defined(OS_CHROMEOS) |
| 200 chromeos::DBusThreadManager::Shutdown(); | 212 chromeos::DBusThreadManager::Shutdown(); |
| 201 #endif // OS_CHROMEOS | 213 #endif // OS_CHROMEOS |
| 202 } | 214 } |
| 203 | 215 |
| 204 private: | 216 private: |
| 205 // This is necessary because eventually some tests call base::RepeatingTimer | 217 // This is necessary because eventually some tests call base::RepeatingTimer |
| 206 // functions and a message loop is required for that. | 218 // functions and a message loop is required for that. |
| 207 base::MessageLoop message_loop_; | 219 base::MessageLoop message_loop_; |
| 208 | 220 |
| 209 #if defined(OS_CHROMEOS) | 221 #if defined(OS_CHROMEOS) |
| 210 chromeos::FakeDBusThreadManager* fake_dbus_thread_manager_; | |
| 211 scoped_ptr<base::FieldTrialList> field_trial_list_; | 222 scoped_ptr<base::FieldTrialList> field_trial_list_; |
| 212 #endif // OS_CHROMEOS | 223 #endif // OS_CHROMEOS |
| 213 }; | 224 }; |
| 214 | 225 |
| 215 TEST_F(MetricsLogTest, RecordEnvironment) { | 226 TEST_F(MetricsLogTest, RecordEnvironment) { |
| 216 // Test that recording the environment works via both of the public methods | 227 // Test that recording the environment works via both of the public methods |
| 217 // RecordEnvironment() and RecordEnvironmentProto(). | 228 // RecordEnvironment() and RecordEnvironmentProto(). |
| 218 TestRecordEnvironment(false); | 229 TestRecordEnvironment(false); |
| 219 TestRecordEnvironment(true); | 230 TestRecordEnvironment(true); |
| 220 } | 231 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 400 |
| 390 TestMetricsLog log(kClientId, kSessionId); | 401 TestMetricsLog log(kClientId, kSessionId); |
| 391 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); | 402 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); |
| 392 | 403 |
| 393 user_manager->LoginUser(user2); | 404 user_manager->LoginUser(user2); |
| 394 log.RecordEnvironmentProto(std::vector<content::WebPluginInfo>(), | 405 log.RecordEnvironmentProto(std::vector<content::WebPluginInfo>(), |
| 395 GoogleUpdateMetrics()); | 406 GoogleUpdateMetrics()); |
| 396 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); | 407 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); |
| 397 } | 408 } |
| 398 #endif // OS_CHROMEOS | 409 #endif // OS_CHROMEOS |
| OLD | NEW |