| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos_metrics_provider.h" | 5 #include "chrome/browser/metrics/chromeos_metrics_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 10 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 provider.ProvideSystemProfileMetrics(&system_profile); | 188 provider.ProvideSystemProfileMetrics(&system_profile); |
| 189 | 189 |
| 190 EXPECT_TRUE(system_profile.has_hardware()); | 190 EXPECT_TRUE(system_profile.has_hardware()); |
| 191 EXPECT_TRUE(system_profile.hardware().has_bluetooth()); | 191 EXPECT_TRUE(system_profile.hardware().has_bluetooth()); |
| 192 | 192 |
| 193 EXPECT_TRUE(system_profile.hardware().bluetooth().is_present()); | 193 EXPECT_TRUE(system_profile.hardware().bluetooth().is_present()); |
| 194 EXPECT_TRUE(system_profile.hardware().bluetooth().is_enabled()); | 194 EXPECT_TRUE(system_profile.hardware().bluetooth().is_enabled()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 TEST_F(ChromeOSMetricsProviderTest, BluetoothPairedDevices) { | 197 TEST_F(ChromeOSMetricsProviderTest, BluetoothPairedDevices) { |
| 198 // The fake bluetooth adapter class already claims to be paired with one | 198 // The fake bluetooth adapter class already claims to be paired with two |
| 199 // device when initialized. Add a second and third fake device to it so we | 199 // device when initialized. Add a third and fourth fake device to it so we |
| 200 // can test the cases where a device is not paired (LE device, generally) | 200 // can test the cases where a device is not paired (LE device, generally) |
| 201 // and a device that does not have Device ID information. | 201 // and a device that does not have Device ID information. |
| 202 fake_bluetooth_device_client_->CreateDevice( | 202 fake_bluetooth_device_client_->CreateDevice( |
| 203 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 203 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 204 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); | 204 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 205 | 205 |
| 206 fake_bluetooth_device_client_->CreateDevice( | 206 fake_bluetooth_device_client_->CreateDevice( |
| 207 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 207 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 208 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 208 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 209 | 209 |
| 210 FakeBluetoothDeviceClient::Properties* properties = | 210 FakeBluetoothDeviceClient::Properties* properties = |
| 211 fake_bluetooth_device_client_->GetProperties( | 211 fake_bluetooth_device_client_->GetProperties( |
| 212 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 212 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 213 properties->paired.ReplaceValue(true); | 213 properties->paired.ReplaceValue(true); |
| 214 | 214 |
| 215 ChromeOSMetricsProvider provider; | 215 ChromeOSMetricsProvider provider; |
| 216 provider.OnDidCreateMetricsLog(); | 216 provider.OnDidCreateMetricsLog(); |
| 217 metrics::SystemProfileProto system_profile; | 217 metrics::SystemProfileProto system_profile; |
| 218 provider.ProvideSystemProfileMetrics(&system_profile); | 218 provider.ProvideSystemProfileMetrics(&system_profile); |
| 219 | 219 |
| 220 ASSERT_TRUE(system_profile.has_hardware()); | 220 ASSERT_TRUE(system_profile.has_hardware()); |
| 221 ASSERT_TRUE(system_profile.hardware().has_bluetooth()); | 221 ASSERT_TRUE(system_profile.hardware().has_bluetooth()); |
| 222 | 222 |
| 223 // Only two of the devices should appear. | 223 // Only three of the devices should appear. |
| 224 EXPECT_EQ(2, system_profile.hardware().bluetooth().paired_device_size()); | 224 EXPECT_EQ(3, system_profile.hardware().bluetooth().paired_device_size()); |
| 225 | 225 |
| 226 typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice | 226 typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice |
| 227 PairedDevice; | 227 PairedDevice; |
| 228 | 228 |
| 229 // First device should match the Paired Device object, complete with | 229 // First device should match the Paired Device object, complete with |
| 230 // parsed Device ID information. | 230 // parsed Device ID information. |
| 231 PairedDevice device1 = system_profile.hardware().bluetooth().paired_device(0); | 231 PairedDevice device1 = system_profile.hardware().bluetooth().paired_device(0); |
| 232 | 232 |
| 233 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceClass, | 233 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceClass, |
| 234 device1.bluetooth_class()); | 234 device1.bluetooth_class()); |
| 235 EXPECT_EQ(PairedDevice::DEVICE_COMPUTER, device1.type()); | 235 EXPECT_EQ(PairedDevice::DEVICE_COMPUTER, device1.type()); |
| 236 EXPECT_EQ(0x001122U, device1.vendor_prefix()); | 236 EXPECT_EQ(0x001122U, device1.vendor_prefix()); |
| 237 EXPECT_EQ(PairedDevice::VENDOR_ID_USB, device1.vendor_id_source()); | 237 EXPECT_EQ(PairedDevice::VENDOR_ID_USB, device1.vendor_id_source()); |
| 238 EXPECT_EQ(0x05ACU, device1.vendor_id()); | 238 EXPECT_EQ(0x05ACU, device1.vendor_id()); |
| 239 EXPECT_EQ(0x030DU, device1.product_id()); | 239 EXPECT_EQ(0x030DU, device1.product_id()); |
| 240 EXPECT_EQ(0x0306U, device1.device_id()); | 240 EXPECT_EQ(0x0306U, device1.device_id()); |
| 241 | 241 |
| 242 // Second device should match the Confirm Passkey object, this has | 242 // Third device should match the Confirm Passkey object, this has |
| 243 // no Device ID information. | 243 // no Device ID information. |
| 244 PairedDevice device2 = system_profile.hardware().bluetooth().paired_device(1); | 244 PairedDevice device2 = system_profile.hardware().bluetooth().paired_device(1); |
| 245 | 245 |
| 246 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | 246 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
| 247 device2.bluetooth_class()); | 247 device2.bluetooth_class()); |
| 248 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | 248 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
| 249 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | 249 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
| 250 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | 250 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
| 251 } | 251 } |
| OLD | NEW |