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_log.h" | 5 #include "chrome/browser/metrics/metrics_log.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "components/variations/metrics_util.h" | 33 #include "components/variations/metrics_util.h" |
34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/common/process_type.h" | 35 #include "content/public/common/process_type.h" |
36 #include "content/public/common/webplugininfo.h" | 36 #include "content/public/common/webplugininfo.h" |
37 #include "content/public/test/test_browser_thread_bundle.h" | 37 #include "content/public/test/test_browser_thread_bundle.h" |
38 #include "content/public/test/test_utils.h" | 38 #include "content/public/test/test_utils.h" |
39 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
40 #include "ui/gfx/size.h" | 40 #include "ui/gfx/size.h" |
41 #include "url/gurl.h" | 41 #include "url/gurl.h" |
42 | 42 |
43 #if defined(OS_CHROMEOS) | |
44 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | |
45 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
46 #include "chrome/browser/metrics/metrics_log_chromeos.h" | |
47 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | |
48 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | |
49 #include "chromeos/dbus/fake_bluetooth_device_client.h" | |
50 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" | |
51 #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" | |
52 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" | |
53 #include "chromeos/dbus/fake_bluetooth_input_client.h" | |
54 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
55 | |
56 using chromeos::DBusThreadManager; | |
57 using chromeos::BluetoothAdapterClient; | |
58 using chromeos::BluetoothAgentManagerClient; | |
59 using chromeos::BluetoothDeviceClient; | |
60 using chromeos::BluetoothGattCharacteristicClient; | |
61 using chromeos::BluetoothGattDescriptorClient; | |
62 using chromeos::BluetoothGattServiceClient; | |
63 using chromeos::BluetoothInputClient; | |
64 using chromeos::FakeBluetoothAdapterClient; | |
65 using chromeos::FakeBluetoothAgentManagerClient; | |
66 using chromeos::FakeBluetoothDeviceClient; | |
67 using chromeos::FakeBluetoothGattCharacteristicClient; | |
68 using chromeos::FakeBluetoothGattDescriptorClient; | |
69 using chromeos::FakeBluetoothGattServiceClient; | |
70 using chromeos::FakeBluetoothInputClient; | |
71 using chromeos::FakeDBusThreadManager; | |
72 #endif // OS_CHROMEOS | |
Alexei Svitkine (slow)
2014/05/23 08:41:47
Sweet!
| |
73 | |
74 using base::TimeDelta; | 43 using base::TimeDelta; |
75 using metrics::ProfilerEventProto; | 44 using metrics::ProfilerEventProto; |
76 using tracked_objects::ProcessDataSnapshot; | 45 using tracked_objects::ProcessDataSnapshot; |
77 using tracked_objects::TaskSnapshot; | 46 using tracked_objects::TaskSnapshot; |
78 | 47 |
79 namespace { | 48 namespace { |
80 | 49 |
81 const char kClientId[] = "bogus client ID"; | 50 const char kClientId[] = "bogus client ID"; |
82 const int64 kInstallDate = 1373051956; | 51 const int64 kInstallDate = 1373051956; |
83 const int64 kInstallDateExpected = 1373050800; // Computed from kInstallDate. | 52 const int64 kInstallDateExpected = 1373050800; // Computed from kInstallDate. |
(...skipping 26 matching lines...) Expand all Loading... | |
110 base::UTF8ToUTF16(version), | 79 base::UTF8ToUTF16(version), |
111 base::string16()); | 80 base::string16()); |
112 if (is_pepper) | 81 if (is_pepper) |
113 plugin.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS; | 82 plugin.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS; |
114 else | 83 else |
115 plugin.type = content::WebPluginInfo::PLUGIN_TYPE_NPAPI; | 84 plugin.type = content::WebPluginInfo::PLUGIN_TYPE_NPAPI; |
116 return plugin; | 85 return plugin; |
117 } | 86 } |
118 #endif // defined(ENABLE_PLUGINS) | 87 #endif // defined(ENABLE_PLUGINS) |
119 | 88 |
120 #if defined(OS_CHROMEOS) | |
121 class TestMetricsLogChromeOS : public MetricsLogChromeOS { | |
122 public: | |
123 explicit TestMetricsLogChromeOS( | |
124 metrics::ChromeUserMetricsExtension* uma_proto) | |
125 : MetricsLogChromeOS(uma_proto) { | |
126 } | |
127 }; | |
128 #endif // OS_CHROMEOS | |
129 | |
130 class TestMetricsLog : public MetricsLog { | 89 class TestMetricsLog : public MetricsLog { |
131 public: | 90 public: |
132 TestMetricsLog(const std::string& client_id, int session_id, LogType log_type) | 91 TestMetricsLog(const std::string& client_id, int session_id, LogType log_type) |
133 : MetricsLog(client_id, session_id, log_type), | 92 : MetricsLog(client_id, session_id, log_type), |
134 prefs_(&scoped_prefs_), | 93 prefs_(&scoped_prefs_), |
135 brand_for_testing_(kBrandForTesting) { | 94 brand_for_testing_(kBrandForTesting) { |
136 #if defined(OS_CHROMEOS) | |
137 metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( | |
138 MetricsLog::uma_proto())); | |
139 #endif // OS_CHROMEOS | |
140 chrome::RegisterLocalState(scoped_prefs_.registry()); | 95 chrome::RegisterLocalState(scoped_prefs_.registry()); |
141 InitPrefs(); | 96 InitPrefs(); |
142 } | 97 } |
143 // Creates a TestMetricsLog that will use |prefs| as the fake local state. | 98 // Creates a TestMetricsLog that will use |prefs| as the fake local state. |
144 // Useful for tests that need to re-use the local state prefs between logs. | 99 // Useful for tests that need to re-use the local state prefs between logs. |
145 TestMetricsLog(const std::string& client_id, | 100 TestMetricsLog(const std::string& client_id, |
146 int session_id, | 101 int session_id, |
147 LogType log_type, | 102 LogType log_type, |
148 TestingPrefServiceSimple* prefs) | 103 TestingPrefServiceSimple* prefs) |
149 : MetricsLog(client_id, session_id, log_type), | 104 : MetricsLog(client_id, session_id, log_type), |
150 prefs_(prefs), | 105 prefs_(prefs), |
151 brand_for_testing_(kBrandForTesting) { | 106 brand_for_testing_(kBrandForTesting) { |
152 #if defined(OS_CHROMEOS) | |
153 metrics_log_chromeos_.reset(new TestMetricsLogChromeOS( | |
154 MetricsLog::uma_proto())); | |
155 #endif // OS_CHROMEOS | |
156 InitPrefs(); | 107 InitPrefs(); |
157 } | 108 } |
158 virtual ~TestMetricsLog() {} | 109 virtual ~TestMetricsLog() {} |
159 | 110 |
160 virtual PrefService* GetPrefService() OVERRIDE { | 111 virtual PrefService* GetPrefService() OVERRIDE { |
161 return prefs_; | 112 return prefs_; |
162 } | 113 } |
163 | 114 |
164 const metrics::ChromeUserMetricsExtension& uma_proto() const { | 115 const metrics::ChromeUserMetricsExtension& uma_proto() const { |
165 return *MetricsLog::uma_proto(); | 116 return *MetricsLog::uma_proto(); |
166 } | 117 } |
167 | 118 |
168 const metrics::SystemProfileProto& system_profile() const { | 119 const metrics::SystemProfileProto& system_profile() const { |
169 return uma_proto().system_profile(); | 120 return uma_proto().system_profile(); |
170 } | 121 } |
171 | 122 |
172 private: | 123 private: |
173 void InitPrefs() { | 124 void InitPrefs() { |
174 prefs_->SetInt64(prefs::kInstallDate, kInstallDate); | 125 prefs_->SetInt64(prefs::kInstallDate, kInstallDate); |
175 prefs_->SetString(prefs::kMetricsReportingEnabledTimestamp, | 126 prefs_->SetString(prefs::kMetricsReportingEnabledTimestamp, |
176 base::Int64ToString(kEnabledDate)); | 127 base::Int64ToString(kEnabledDate)); |
177 #if defined(OS_CHROMEOS) | |
178 prefs_->SetInteger(prefs::kStabilityChildProcessCrashCount, 10); | |
179 prefs_->SetInteger(prefs::kStabilityOtherUserCrashCount, 11); | |
180 prefs_->SetInteger(prefs::kStabilityKernelCrashCount, 12); | |
181 prefs_->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 13); | |
182 #endif // OS_CHROMEOS | |
183 } | 128 } |
184 | 129 |
185 virtual void GetFieldTrialIds( | 130 virtual void GetFieldTrialIds( |
186 std::vector<variations::ActiveGroupId>* field_trial_ids) const | 131 std::vector<variations::ActiveGroupId>* field_trial_ids) const |
187 OVERRIDE { | 132 OVERRIDE { |
188 ASSERT_TRUE(field_trial_ids->empty()); | 133 ASSERT_TRUE(field_trial_ids->empty()); |
189 | 134 |
190 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { | 135 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { |
191 field_trial_ids->push_back(kFieldTrialIds[i]); | 136 field_trial_ids->push_back(kFieldTrialIds[i]); |
192 } | 137 } |
(...skipping 21 matching lines...) Expand all Loading... | |
214 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 159 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
215 }; | 160 }; |
216 | 161 |
217 } // namespace | 162 } // namespace |
218 | 163 |
219 class MetricsLogTest : public testing::Test { | 164 class MetricsLogTest : public testing::Test { |
220 public: | 165 public: |
221 MetricsLogTest() {} | 166 MetricsLogTest() {} |
222 | 167 |
223 protected: | 168 protected: |
224 virtual void SetUp() OVERRIDE { | |
225 #if defined(OS_CHROMEOS) | |
226 // Set up the fake Bluetooth environment, | |
227 scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager( | |
228 new FakeDBusThreadManager); | |
229 fake_dbus_thread_manager->SetBluetoothAdapterClient( | |
230 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); | |
231 fake_dbus_thread_manager->SetBluetoothDeviceClient( | |
232 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); | |
233 fake_dbus_thread_manager->SetBluetoothGattCharacteristicClient( | |
234 scoped_ptr<BluetoothGattCharacteristicClient>( | |
235 new FakeBluetoothGattCharacteristicClient)); | |
236 fake_dbus_thread_manager->SetBluetoothGattDescriptorClient( | |
237 scoped_ptr<BluetoothGattDescriptorClient>( | |
238 new FakeBluetoothGattDescriptorClient)); | |
239 fake_dbus_thread_manager->SetBluetoothGattServiceClient( | |
240 scoped_ptr<BluetoothGattServiceClient>( | |
241 new FakeBluetoothGattServiceClient)); | |
242 fake_dbus_thread_manager->SetBluetoothInputClient( | |
243 scoped_ptr<BluetoothInputClient>(new FakeBluetoothInputClient)); | |
244 fake_dbus_thread_manager->SetBluetoothAgentManagerClient( | |
245 scoped_ptr<BluetoothAgentManagerClient>( | |
246 new FakeBluetoothAgentManagerClient)); | |
247 DBusThreadManager::InitializeForTesting(fake_dbus_thread_manager.release()); | |
248 | |
249 // Grab pointers to members of the thread manager for easier testing. | |
250 fake_bluetooth_adapter_client_ = static_cast<FakeBluetoothAdapterClient*>( | |
251 DBusThreadManager::Get()->GetBluetoothAdapterClient()); | |
252 fake_bluetooth_device_client_ = static_cast<FakeBluetoothDeviceClient*>( | |
253 DBusThreadManager::Get()->GetBluetoothDeviceClient()); | |
254 #endif // OS_CHROMEOS | |
255 } | |
256 | |
257 virtual void TearDown() OVERRIDE { | |
258 #if defined(OS_CHROMEOS) | |
259 DBusThreadManager::Shutdown(); | |
260 #endif // OS_CHROMEOS | |
261 } | |
262 | |
263 // Check that the values in |system_values| correspond to the test data | 169 // Check that the values in |system_values| correspond to the test data |
264 // defined at the top of this file. | 170 // defined at the top of this file. |
265 void CheckSystemProfile(const metrics::SystemProfileProto& system_profile) { | 171 void CheckSystemProfile(const metrics::SystemProfileProto& system_profile) { |
266 EXPECT_EQ(kInstallDateExpected, system_profile.install_date()); | 172 EXPECT_EQ(kInstallDateExpected, system_profile.install_date()); |
267 EXPECT_EQ(kEnabledDateExpected, system_profile.uma_enabled_date()); | 173 EXPECT_EQ(kEnabledDateExpected, system_profile.uma_enabled_date()); |
268 | 174 |
269 ASSERT_EQ(arraysize(kFieldTrialIds) + arraysize(kSyntheticTrials), | 175 ASSERT_EQ(arraysize(kFieldTrialIds) + arraysize(kSyntheticTrials), |
270 static_cast<size_t>(system_profile.field_trial_size())); | 176 static_cast<size_t>(system_profile.field_trial_size())); |
271 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { | 177 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { |
272 const metrics::SystemProfileProto::FieldTrial& field_trial = | 178 const metrics::SystemProfileProto::FieldTrial& field_trial = |
(...skipping 19 matching lines...) Expand all Loading... | |
292 EXPECT_EQ(kScreenCount, hardware.screen_count()); | 198 EXPECT_EQ(kScreenCount, hardware.screen_count()); |
293 | 199 |
294 EXPECT_TRUE(hardware.has_cpu()); | 200 EXPECT_TRUE(hardware.has_cpu()); |
295 EXPECT_TRUE(hardware.cpu().has_vendor_name()); | 201 EXPECT_TRUE(hardware.cpu().has_vendor_name()); |
296 EXPECT_TRUE(hardware.cpu().has_signature()); | 202 EXPECT_TRUE(hardware.cpu().has_signature()); |
297 | 203 |
298 // TODO(isherman): Verify other data written into the protobuf as a result | 204 // TODO(isherman): Verify other data written into the protobuf as a result |
299 // of this call. | 205 // of this call. |
300 } | 206 } |
301 | 207 |
302 protected: | |
303 #if defined(OS_CHROMEOS) | |
304 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; | |
305 FakeBluetoothDeviceClient* fake_bluetooth_device_client_; | |
306 #endif // OS_CHROMEOS | |
307 | |
308 private: | 208 private: |
309 content::TestBrowserThreadBundle thread_bundle_; | 209 content::TestBrowserThreadBundle thread_bundle_; |
310 | 210 |
311 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest); | 211 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest); |
312 }; | 212 }; |
313 | 213 |
314 TEST_F(MetricsLogTest, RecordEnvironment) { | 214 TEST_F(MetricsLogTest, RecordEnvironment) { |
315 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 215 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
316 | 216 |
317 std::vector<content::WebPluginInfo> plugins; | 217 std::vector<content::WebPluginInfo> plugins; |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 tracked_object->exec_thread_name_hash()); | 551 tracked_object->exec_thread_name_hash()); |
652 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER, | 552 EXPECT_EQ(ProfilerEventProto::TrackedObject::RENDERER, |
653 tracked_object->process_type()); | 553 tracked_object->process_type()); |
654 } | 554 } |
655 } | 555 } |
656 | 556 |
657 TEST_F(MetricsLogTest, ChromeChannelWrittenToProtobuf) { | 557 TEST_F(MetricsLogTest, ChromeChannelWrittenToProtobuf) { |
658 TestMetricsLog log("user@test.com", kSessionId, MetricsLog::ONGOING_LOG); | 558 TestMetricsLog log("user@test.com", kSessionId, MetricsLog::ONGOING_LOG); |
659 EXPECT_TRUE(log.uma_proto().system_profile().has_channel()); | 559 EXPECT_TRUE(log.uma_proto().system_profile().has_channel()); |
660 } | 560 } |
661 | |
662 #if defined(OS_CHROMEOS) | |
663 TEST_F(MetricsLogTest, MultiProfileUserCount) { | |
664 std::string user1("user1@example.com"); | |
665 std::string user2("user2@example.com"); | |
666 std::string user3("user3@example.com"); | |
667 | |
668 // |scoped_enabler| takes over the lifetime of |user_manager|. | |
669 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); | |
670 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | |
671 user_manager->AddKioskAppUser(user1); | |
672 user_manager->AddKioskAppUser(user2); | |
673 user_manager->AddKioskAppUser(user3); | |
674 | |
675 user_manager->LoginUser(user1); | |
676 user_manager->LoginUser(user3); | |
677 | |
678 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | |
679 std::vector<metrics::MetricsProvider*> metrics_providers; | |
680 std::vector<content::WebPluginInfo> plugins; | |
681 std::vector<variations::ActiveGroupId> synthetic_trials; | |
682 log.RecordEnvironment(metrics_providers, plugins, synthetic_trials); | |
683 EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); | |
684 } | |
685 | |
686 TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { | |
687 std::string user1("user1@example.com"); | |
688 std::string user2("user2@example.com"); | |
689 std::string user3("user3@example.com"); | |
690 | |
691 // |scoped_enabler| takes over the lifetime of |user_manager|. | |
692 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); | |
693 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | |
694 user_manager->AddKioskAppUser(user1); | |
695 user_manager->AddKioskAppUser(user2); | |
696 user_manager->AddKioskAppUser(user3); | |
697 | |
698 user_manager->LoginUser(user1); | |
699 | |
700 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | |
701 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); | |
702 | |
703 user_manager->LoginUser(user2); | |
704 std::vector<metrics::MetricsProvider*> metrics_providers; | |
705 std::vector<variations::ActiveGroupId> synthetic_trials; | |
706 log.RecordEnvironment(metrics_providers, | |
707 std::vector<content::WebPluginInfo>(), | |
708 synthetic_trials); | |
709 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); | |
710 } | |
711 | |
712 TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { | |
713 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | |
714 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | |
715 std::vector<content::WebPluginInfo>(), | |
716 std::vector<variations::ActiveGroupId>()); | |
717 | |
718 EXPECT_TRUE(log.system_profile().has_hardware()); | |
719 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | |
720 | |
721 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | |
722 EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); | |
723 } | |
724 | |
725 TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { | |
726 FakeBluetoothAdapterClient::Properties* properties = | |
727 fake_bluetooth_adapter_client_->GetProperties( | |
728 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); | |
729 properties->powered.ReplaceValue(true); | |
730 | |
731 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | |
732 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | |
733 std::vector<content::WebPluginInfo>(), | |
734 std::vector<variations::ActiveGroupId>()); | |
735 | |
736 EXPECT_TRUE(log.system_profile().has_hardware()); | |
737 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | |
738 | |
739 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | |
740 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); | |
741 } | |
742 | |
743 TEST_F(MetricsLogTest, BluetoothPairedDevices) { | |
744 // The fake bluetooth adapter class already claims to be paired with one | |
745 // device when initialized. Add a second and third fake device to it so we | |
746 // can test the cases where a device is not paired (LE device, generally) | |
747 // and a device that does not have Device ID information. | |
748 fake_bluetooth_device_client_->CreateDevice( | |
749 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | |
750 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); | |
751 | |
752 fake_bluetooth_device_client_->CreateDevice( | |
753 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | |
754 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | |
755 | |
756 FakeBluetoothDeviceClient::Properties* properties = | |
757 fake_bluetooth_device_client_->GetProperties( | |
758 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | |
759 properties->paired.ReplaceValue(true); | |
760 | |
761 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | |
762 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | |
763 std::vector<content::WebPluginInfo>(), | |
764 std::vector<variations::ActiveGroupId>()); | |
765 | |
766 ASSERT_TRUE(log.system_profile().has_hardware()); | |
767 ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); | |
768 | |
769 // Only two of the devices should appear. | |
770 EXPECT_EQ(2, | |
771 log.system_profile().hardware().bluetooth().paired_device_size()); | |
772 | |
773 typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice | |
774 PairedDevice; | |
775 | |
776 // First device should match the Paired Device object, complete with | |
777 // parsed Device ID information. | |
778 PairedDevice device1 = | |
779 log.system_profile().hardware().bluetooth().paired_device(0); | |
780 | |
781 EXPECT_EQ(FakeBluetoothDeviceClient::kPairedDeviceClass, | |
782 device1.bluetooth_class()); | |
783 EXPECT_EQ(PairedDevice::DEVICE_COMPUTER, device1.type()); | |
784 EXPECT_EQ(0x001122U, device1.vendor_prefix()); | |
785 EXPECT_EQ(PairedDevice::VENDOR_ID_USB, device1.vendor_id_source()); | |
786 EXPECT_EQ(0x05ACU, device1.vendor_id()); | |
787 EXPECT_EQ(0x030DU, device1.product_id()); | |
788 EXPECT_EQ(0x0306U, device1.device_id()); | |
789 | |
790 // Second device should match the Confirm Passkey object, this has | |
791 // no Device ID information. | |
792 PairedDevice device2 = | |
793 log.system_profile().hardware().bluetooth().paired_device(1); | |
794 | |
795 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | |
796 device2.bluetooth_class()); | |
797 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | |
798 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | |
799 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | |
800 } | |
801 #endif // OS_CHROMEOS | |
OLD | NEW |