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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; | 108 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; |
109 FakeBluetoothDeviceClient* fake_bluetooth_device_client_; | 109 FakeBluetoothDeviceClient* fake_bluetooth_device_client_; |
110 | 110 |
111 private: | 111 private: |
112 content::TestBrowserThreadBundle thread_bundle_; | 112 content::TestBrowserThreadBundle thread_bundle_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProviderTest); | 114 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProviderTest); |
115 }; | 115 }; |
116 | 116 |
117 TEST_F(ChromeOSMetricsProviderTest, MultiProfileUserCount) { | 117 TEST_F(ChromeOSMetricsProviderTest, MultiProfileUserCount) { |
118 const AccountId account_id1(AccountId::FromUserEmail("user1@example.com")); | 118 std::string user1("user1@example.com"); |
119 const AccountId account_id2(AccountId::FromUserEmail("user2@example.com")); | 119 std::string user2("user2@example.com"); |
120 const AccountId account_id3(AccountId::FromUserEmail("user3@example.com")); | 120 std::string user3("user3@example.com"); |
121 | 121 |
122 // |scoped_enabler| takes over the lifetime of |user_manager|. | 122 // |scoped_enabler| takes over the lifetime of |user_manager|. |
123 chromeos::FakeChromeUserManager* user_manager = | 123 chromeos::FakeChromeUserManager* user_manager = |
124 new chromeos::FakeChromeUserManager(); | 124 new chromeos::FakeChromeUserManager(); |
125 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | 125 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
126 user_manager->AddKioskAppUser(account_id1); | 126 user_manager->AddKioskAppUser(user1); |
127 user_manager->AddKioskAppUser(account_id2); | 127 user_manager->AddKioskAppUser(user2); |
128 user_manager->AddKioskAppUser(account_id3); | 128 user_manager->AddKioskAppUser(user3); |
129 | 129 |
130 user_manager->LoginUser(account_id1); | 130 user_manager->LoginUser(user1); |
131 user_manager->LoginUser(account_id3); | 131 user_manager->LoginUser(user3); |
132 | 132 |
133 ChromeOSMetricsProvider provider; | 133 ChromeOSMetricsProvider provider; |
134 provider.OnDidCreateMetricsLog(); | 134 provider.OnDidCreateMetricsLog(); |
135 metrics::SystemProfileProto system_profile; | 135 metrics::SystemProfileProto system_profile; |
136 provider.ProvideSystemProfileMetrics(&system_profile); | 136 provider.ProvideSystemProfileMetrics(&system_profile); |
137 EXPECT_EQ(2u, system_profile.multi_profile_user_count()); | 137 EXPECT_EQ(2u, system_profile.multi_profile_user_count()); |
138 } | 138 } |
139 | 139 |
140 TEST_F(ChromeOSMetricsProviderTest, MultiProfileCountInvalidated) { | 140 TEST_F(ChromeOSMetricsProviderTest, MultiProfileCountInvalidated) { |
141 const AccountId account_id1(AccountId::FromUserEmail("user1@example.com")); | 141 std::string user1("user1@example.com"); |
142 const AccountId account_id2(AccountId::FromUserEmail("user2@example.com")); | 142 std::string user2("user2@example.com"); |
143 const AccountId account_id3(AccountId::FromUserEmail("user3@example.com")); | 143 std::string user3("user3@example.com"); |
144 | 144 |
145 // |scoped_enabler| takes over the lifetime of |user_manager|. | 145 // |scoped_enabler| takes over the lifetime of |user_manager|. |
146 chromeos::FakeChromeUserManager* user_manager = | 146 chromeos::FakeChromeUserManager* user_manager = |
147 new chromeos::FakeChromeUserManager(); | 147 new chromeos::FakeChromeUserManager(); |
148 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | 148 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
149 user_manager->AddKioskAppUser(account_id1); | 149 user_manager->AddKioskAppUser(user1); |
150 user_manager->AddKioskAppUser(account_id2); | 150 user_manager->AddKioskAppUser(user2); |
151 user_manager->AddKioskAppUser(account_id3); | 151 user_manager->AddKioskAppUser(user3); |
152 | 152 |
153 user_manager->LoginUser(account_id1); | 153 user_manager->LoginUser(user1); |
154 | 154 |
155 ChromeOSMetricsProvider provider; | 155 ChromeOSMetricsProvider provider; |
156 provider.OnDidCreateMetricsLog(); | 156 provider.OnDidCreateMetricsLog(); |
157 | 157 |
158 metrics::SystemProfileProto system_profile; | 158 metrics::SystemProfileProto system_profile; |
159 provider.ProvideSystemProfileMetrics(&system_profile); | 159 provider.ProvideSystemProfileMetrics(&system_profile); |
160 EXPECT_EQ(1u, system_profile.multi_profile_user_count()); | 160 EXPECT_EQ(1u, system_profile.multi_profile_user_count()); |
161 | 161 |
162 user_manager->LoginUser(account_id2); | 162 user_manager->LoginUser(user2); |
163 provider.ProvideSystemProfileMetrics(&system_profile); | 163 provider.ProvideSystemProfileMetrics(&system_profile); |
164 EXPECT_EQ(0u, system_profile.multi_profile_user_count()); | 164 EXPECT_EQ(0u, system_profile.multi_profile_user_count()); |
165 } | 165 } |
166 | 166 |
167 TEST_F(ChromeOSMetricsProviderTest, BluetoothHardwareDisabled) { | 167 TEST_F(ChromeOSMetricsProviderTest, BluetoothHardwareDisabled) { |
168 ChromeOSMetricsProvider provider; | 168 ChromeOSMetricsProvider provider; |
169 provider.OnDidCreateMetricsLog(); | 169 provider.OnDidCreateMetricsLog(); |
170 metrics::SystemProfileProto system_profile; | 170 metrics::SystemProfileProto system_profile; |
171 provider.ProvideSystemProfileMetrics(&system_profile); | 171 provider.ProvideSystemProfileMetrics(&system_profile); |
172 | 172 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 EXPECT_EQ(0x030DU, device1.product_id()); | 257 EXPECT_EQ(0x030DU, device1.product_id()); |
258 EXPECT_EQ(0x0306U, device1.device_id()); | 258 EXPECT_EQ(0x0306U, device1.device_id()); |
259 | 259 |
260 // The Confirm Passkey object, this has no Device ID information. | 260 // The Confirm Passkey object, this has no Device ID information. |
261 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | 261 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
262 device2.bluetooth_class()); | 262 device2.bluetooth_class()); |
263 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | 263 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
264 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | 264 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
265 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | 265 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
266 } | 266 } |
OLD | NEW |