Chromium Code Reviews| Index: chrome/browser/metrics/metrics_log_unittest.cc |
| diff --git a/chrome/browser/metrics/metrics_log_unittest.cc b/chrome/browser/metrics/metrics_log_unittest.cc |
| index 1507947033df1ab055061d999a6c30d12eeeaf1d..72166b27e260a210255acbbda5f7eb889d8e1651 100644 |
| --- a/chrome/browser/metrics/metrics_log_unittest.cc |
| +++ b/chrome/browser/metrics/metrics_log_unittest.cc |
| @@ -40,37 +40,6 @@ |
| #include "ui/gfx/size.h" |
| #include "url/gurl.h" |
| -#if defined(OS_CHROMEOS) |
| -#include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
| -#include "chrome/browser/chromeos/login/users/user_manager.h" |
| -#include "chrome/browser/metrics/metrics_log_chromeos.h" |
| -#include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| -#include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
| -#include "chromeos/dbus/fake_bluetooth_device_client.h" |
| -#include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" |
| -#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" |
| -#include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" |
| -#include "chromeos/dbus/fake_bluetooth_input_client.h" |
| -#include "chromeos/dbus/fake_dbus_thread_manager.h" |
| - |
| -using chromeos::DBusThreadManager; |
| -using chromeos::BluetoothAdapterClient; |
| -using chromeos::BluetoothAgentManagerClient; |
| -using chromeos::BluetoothDeviceClient; |
| -using chromeos::BluetoothGattCharacteristicClient; |
| -using chromeos::BluetoothGattDescriptorClient; |
| -using chromeos::BluetoothGattServiceClient; |
| -using chromeos::BluetoothInputClient; |
| -using chromeos::FakeBluetoothAdapterClient; |
| -using chromeos::FakeBluetoothAgentManagerClient; |
| -using chromeos::FakeBluetoothDeviceClient; |
| -using chromeos::FakeBluetoothGattCharacteristicClient; |
| -using chromeos::FakeBluetoothGattDescriptorClient; |
| -using chromeos::FakeBluetoothGattServiceClient; |
| -using chromeos::FakeBluetoothInputClient; |
| -using chromeos::FakeDBusThreadManager; |
| -#endif // OS_CHROMEOS |
|
Alexei Svitkine (slow)
2014/05/23 08:41:47
Sweet!
|
| - |
| using base::TimeDelta; |
| using metrics::ProfilerEventProto; |
| using tracked_objects::ProcessDataSnapshot; |
| @@ -117,26 +86,12 @@ content::WebPluginInfo CreateFakePluginInfo( |
| } |
| #endif // defined(ENABLE_PLUGINS) |
| -#if defined(OS_CHROMEOS) |
| -class TestMetricsLogChromeOS : public MetricsLogChromeOS { |
| - public: |
| - explicit TestMetricsLogChromeOS( |
| - metrics::ChromeUserMetricsExtension* uma_proto) |
| - : MetricsLogChromeOS(uma_proto) { |
| - } |
| -}; |
| -#endif // OS_CHROMEOS |
| - |
| class TestMetricsLog : public MetricsLog { |
| public: |
| TestMetricsLog(const std::string& client_id, int session_id, LogType log_type) |
| : MetricsLog(client_id, session_id, log_type), |
| prefs_(&scoped_prefs_), |
| brand_for_testing_(kBrandForTesting) { |
| -#if defined(OS_CHROMEOS) |
| - metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( |
| - MetricsLog::uma_proto())); |
| -#endif // OS_CHROMEOS |
| chrome::RegisterLocalState(scoped_prefs_.registry()); |
| InitPrefs(); |
| } |
| @@ -149,10 +104,6 @@ class TestMetricsLog : public MetricsLog { |
| : MetricsLog(client_id, session_id, log_type), |
| prefs_(prefs), |
| brand_for_testing_(kBrandForTesting) { |
| -#if defined(OS_CHROMEOS) |
| - metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( |
| - MetricsLog::uma_proto())); |
| -#endif // OS_CHROMEOS |
| InitPrefs(); |
| } |
| virtual ~TestMetricsLog() {} |
| @@ -174,12 +125,6 @@ class TestMetricsLog : public MetricsLog { |
| prefs_->SetInt64(prefs::kInstallDate, kInstallDate); |
| prefs_->SetString(prefs::kMetricsReportingEnabledTimestamp, |
| base::Int64ToString(kEnabledDate)); |
| -#if defined(OS_CHROMEOS) |
| - prefs_->SetInteger(prefs::kStabilityChildProcessCrashCount, 10); |
| - prefs_->SetInteger(prefs::kStabilityOtherUserCrashCount, 11); |
| - prefs_->SetInteger(prefs::kStabilityKernelCrashCount, 12); |
| - prefs_->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 13); |
| -#endif // OS_CHROMEOS |
| } |
| virtual void GetFieldTrialIds( |
| @@ -221,45 +166,6 @@ class MetricsLogTest : public testing::Test { |
| MetricsLogTest() {} |
| protected: |
| - virtual void SetUp() OVERRIDE { |
| -#if defined(OS_CHROMEOS) |
| - // Set up the fake Bluetooth environment, |
| - scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager( |
| - new FakeDBusThreadManager); |
| - fake_dbus_thread_manager->SetBluetoothAdapterClient( |
| - scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); |
| - fake_dbus_thread_manager->SetBluetoothDeviceClient( |
| - scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); |
| - fake_dbus_thread_manager->SetBluetoothGattCharacteristicClient( |
| - scoped_ptr<BluetoothGattCharacteristicClient>( |
| - new FakeBluetoothGattCharacteristicClient)); |
| - fake_dbus_thread_manager->SetBluetoothGattDescriptorClient( |
| - scoped_ptr<BluetoothGattDescriptorClient>( |
| - new FakeBluetoothGattDescriptorClient)); |
| - fake_dbus_thread_manager->SetBluetoothGattServiceClient( |
| - scoped_ptr<BluetoothGattServiceClient>( |
| - new FakeBluetoothGattServiceClient)); |
| - fake_dbus_thread_manager->SetBluetoothInputClient( |
| - scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); |
| - fake_dbus_thread_manager->SetBluetoothAgentManagerClient( |
| - scoped_ptr<BluetoothAgentManagerClient>( |
| - new FakeBluetoothAgentManagerClient)); |
| - DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager.release()); |
| - |
| - // Grab pointers to members of the thread manager for easier testing. |
| - fake_bluetooth_adapter_client_ = static_cast<FakeBluetoothAdapterClient*>( |
| - DBusThreadManager::Get()->GetBluetoothAdapterClient()); |
| - fake_bluetooth_device_client_ = static_cast<FakeBluetoothDeviceClient*>( |
| - DBusThreadManager::Get()->GetBluetoothDeviceClient()); |
| -#endif // OS_CHROMEOS |
| - } |
| - |
| - virtual void TearDown() OVERRIDE { |
| -#if defined(OS_CHROMEOS) |
| - DBusThreadManager::Shutdown(); |
| -#endif // OS_CHROMEOS |
| - } |
| - |
| // Check that the values in |system_values| correspond to the test data |
| // defined at the top of this file. |
| void CheckSystemProfile(const metrics::SystemProfileProto& system_profile) { |
| @@ -299,12 +205,6 @@ class MetricsLogTest : public testing::Test { |
| // of this call. |
| } |
| - protected: |
| -#if defined(OS_CHROMEOS) |
| - FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; |
| - FakeBluetoothDeviceClient* fake_bluetooth_device_client_; |
| -#endif // OS_CHROMEOS |
| - |
| private: |
| content::TestBrowserThreadBundle thread_bundle_; |
| @@ -658,144 +558,3 @@ TEST_F(MetricsLogTest, ChromeChannelWrittenToProtobuf) { |
| TestMetricsLog log("user@test.com", kSessionId, MetricsLog::ONGOING_LOG); |
| EXPECT_TRUE(log.uma_proto().system_profile().has_channel()); |
| } |
| - |
| -#if defined(OS_CHROMEOS) |
| -TEST_F(MetricsLogTest, MultiProfileUserCount) { |
| - std::string user1("user1@example.com"); |
| - std::string user2("user2@example.com"); |
| - std::string user3("user3@example.com"); |
| - |
| - // |scoped_enabler| takes over the lifetime of |user_manager|. |
| - chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); |
| - chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
| - user_manager->AddKioskAppUser(user1); |
| - user_manager->AddKioskAppUser(user2); |
| - user_manager->AddKioskAppUser(user3); |
| - |
| - user_manager->LoginUser(user1); |
| - user_manager->LoginUser(user3); |
| - |
| - TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| - std::vector<metrics::MetricsProvider*> metrics_providers; |
| - std::vector<content::WebPluginInfo> plugins; |
| - std::vector<variations::ActiveGroupId> synthetic_trials; |
| - log.RecordEnvironment(metrics_providers, plugins, synthetic_trials); |
| - EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); |
| -} |
| - |
| -TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { |
| - std::string user1("user1@example.com"); |
| - std::string user2("user2@example.com"); |
| - std::string user3("user3@example.com"); |
| - |
| - // |scoped_enabler| takes over the lifetime of |user_manager|. |
| - chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); |
| - chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
| - user_manager->AddKioskAppUser(user1); |
| - user_manager->AddKioskAppUser(user2); |
| - user_manager->AddKioskAppUser(user3); |
| - |
| - user_manager->LoginUser(user1); |
| - |
| - TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| - EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); |
| - |
| - user_manager->LoginUser(user2); |
| - std::vector<metrics::MetricsProvider*> metrics_providers; |
| - std::vector<variations::ActiveGroupId> synthetic_trials; |
| - log.RecordEnvironment(metrics_providers, |
| - std::vector<content::WebPluginInfo>(), |
| - synthetic_trials); |
| - EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); |
| -} |
| - |
| -TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { |
| - TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| - log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| - std::vector<content::WebPluginInfo>(), |
| - std::vector<variations::ActiveGroupId>()); |
| - |
| - EXPECT_TRUE(log.system_profile().has_hardware()); |
| - EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
| - |
| - EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
| - EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); |
| -} |
| - |
| -TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { |
| - FakeBluetoothAdapterClient::Properties* properties = |
| - fake_bluetooth_adapter_client_->GetProperties( |
| - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); |
| - properties->powered.ReplaceValue(true); |
| - |
| - TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| - log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| - std::vector<content::WebPluginInfo>(), |
| - std::vector<variations::ActiveGroupId>()); |
| - |
| - EXPECT_TRUE(log.system_profile().has_hardware()); |
| - EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
| - |
| - EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
| - EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); |
| -} |
| - |
| -TEST_F(MetricsLogTest, BluetoothPairedDevices) { |
| - // The fake bluetooth adapter class already claims to be paired with one |
| - // device when initialized. Add a second and third fake device to it so we |
| - // can test the cases where a device is not paired (LE device, generally) |
| - // and a device that does not have Device ID information. |
| - fake_bluetooth_device_client_->CreateDevice( |
| - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| - dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| - |
| - fake_bluetooth_device_client_->CreateDevice( |
| - dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| - |
| - FakeBluetoothDeviceClient::Properties* properties = |
| - fake_bluetooth_device_client_->GetProperties( |
| - dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| - properties->paired.ReplaceValue(true); |
| - |
| - TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| - log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| - std::vector<content::WebPluginInfo>(), |
| - std::vector<variations::ActiveGroupId>()); |
| - |
| - ASSERT_TRUE(log.system_profile().has_hardware()); |
| - ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); |
| - |
| - // Only two of the devices should appear. |
| - EXPECT_EQ(2, |
| - log.system_profile().hardware().bluetooth().paired_device_size()); |
| - |
| - typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice |
| - PairedDevice; |
| - |
| - // First device should match the Paired Device object, complete with |
| - // parsed Device ID information. |
| - PairedDevice device1 = |
| - log.system_profile().hardware().bluetooth().paired_device(0); |
| - |
| - EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceClass, |
| - device1.bluetooth_class()); |
| - EXPECT_EQ(PairedDevice::DEVICE_COMPUTER, device1.type()); |
| - EXPECT_EQ(0x001122U, device1.vendor_prefix()); |
| - EXPECT_EQ(PairedDevice::VENDOR_ID_USB, device1.vendor_id_source()); |
| - EXPECT_EQ(0x05ACU, device1.vendor_id()); |
| - EXPECT_EQ(0x030DU, device1.product_id()); |
| - EXPECT_EQ(0x0306U, device1.device_id()); |
| - |
| - // Second device should match the Confirm Passkey object, this has |
| - // no Device ID information. |
| - PairedDevice device2 = |
| - log.system_profile().hardware().bluetooth().paired_device(1); |
| - |
| - EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
| - device2.bluetooth_class()); |
| - EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
| - EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
| - EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
| -} |
| -#endif // OS_CHROMEOS |