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 20 matching lines...) Expand all Loading... |
31 #include "components/metrics/proto/system_profile.pb.h" | 31 #include "components/metrics/proto/system_profile.pb.h" |
32 #include "components/metrics/test_metrics_service_client.h" | 32 #include "components/metrics/test_metrics_service_client.h" |
33 #include "components/variations/active_field_trials.h" | 33 #include "components/variations/active_field_trials.h" |
34 #include "components/variations/metrics_util.h" | 34 #include "components/variations/metrics_util.h" |
35 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/common/process_type.h" | 36 #include "content/public/common/process_type.h" |
37 #include "content/public/common/webplugininfo.h" | 37 #include "content/public/common/webplugininfo.h" |
38 #include "content/public/test/test_browser_thread_bundle.h" | 38 #include "content/public/test/test_browser_thread_bundle.h" |
39 #include "content/public/test/test_utils.h" | 39 #include "content/public/test/test_utils.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
41 #include "ui/gfx/size.h" | |
42 #include "url/gurl.h" | 41 #include "url/gurl.h" |
43 | 42 |
44 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
45 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 44 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
46 #include "chrome/browser/chromeos/login/users/user_manager.h" | 45 #include "chrome/browser/chromeos/login/users/user_manager.h" |
47 #include "chrome/browser/metrics/metrics_log_chromeos.h" | 46 #include "chrome/browser/metrics/metrics_log_chromeos.h" |
48 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | 47 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
49 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" | 48 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" |
50 #include "chromeos/dbus/fake_bluetooth_device_client.h" | 49 #include "chromeos/dbus/fake_bluetooth_device_client.h" |
51 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" | 50 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" |
(...skipping 26 matching lines...) Expand all Loading... |
78 using tracked_objects::TaskSnapshot; | 77 using tracked_objects::TaskSnapshot; |
79 | 78 |
80 namespace { | 79 namespace { |
81 | 80 |
82 const char kClientId[] = "bogus client ID"; | 81 const char kClientId[] = "bogus client ID"; |
83 const int64 kInstallDate = 1373051956; | 82 const int64 kInstallDate = 1373051956; |
84 const int64 kInstallDateExpected = 1373050800; // Computed from kInstallDate. | 83 const int64 kInstallDateExpected = 1373050800; // Computed from kInstallDate. |
85 const int64 kEnabledDate = 1373001211; | 84 const int64 kEnabledDate = 1373001211; |
86 const int64 kEnabledDateExpected = 1373000400; // Computed from kEnabledDate. | 85 const int64 kEnabledDateExpected = 1373000400; // Computed from kEnabledDate. |
87 const int kSessionId = 127; | 86 const int kSessionId = 127; |
88 const int kScreenWidth = 1024; | |
89 const int kScreenHeight = 768; | |
90 const int kScreenCount = 3; | |
91 const float kScreenScaleFactor = 2; | |
92 const variations::ActiveGroupId kFieldTrialIds[] = { | 87 const variations::ActiveGroupId kFieldTrialIds[] = { |
93 {37, 43}, | 88 {37, 43}, |
94 {13, 47}, | 89 {13, 47}, |
95 {23, 17} | 90 {23, 17} |
96 }; | 91 }; |
97 const variations::ActiveGroupId kSyntheticTrials[] = { | 92 const variations::ActiveGroupId kSyntheticTrials[] = { |
98 {55, 15}, | 93 {55, 15}, |
99 {66, 16} | 94 {66, 16} |
100 }; | 95 }; |
101 | 96 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 virtual void GetFieldTrialIds( | 183 virtual void GetFieldTrialIds( |
189 std::vector<variations::ActiveGroupId>* field_trial_ids) const | 184 std::vector<variations::ActiveGroupId>* field_trial_ids) const |
190 OVERRIDE { | 185 OVERRIDE { |
191 ASSERT_TRUE(field_trial_ids->empty()); | 186 ASSERT_TRUE(field_trial_ids->empty()); |
192 | 187 |
193 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { | 188 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { |
194 field_trial_ids->push_back(kFieldTrialIds[i]); | 189 field_trial_ids->push_back(kFieldTrialIds[i]); |
195 } | 190 } |
196 } | 191 } |
197 | 192 |
198 virtual gfx::Size GetScreenSize() const OVERRIDE { | |
199 return gfx::Size(kScreenWidth, kScreenHeight); | |
200 } | |
201 | |
202 virtual float GetScreenDeviceScaleFactor() const OVERRIDE { | |
203 return kScreenScaleFactor; | |
204 } | |
205 | |
206 virtual int GetScreenCount() const OVERRIDE { | |
207 return kScreenCount; | |
208 } | |
209 | |
210 // Scoped PrefsService, which may not be used if |prefs_ != &scoped_prefs|. | 193 // Scoped PrefsService, which may not be used if |prefs_ != &scoped_prefs|. |
211 TestingPrefServiceSimple scoped_prefs_; | 194 TestingPrefServiceSimple scoped_prefs_; |
212 // Weak pointer to the PrefsService used by this log. | 195 // Weak pointer to the PrefsService used by this log. |
213 TestingPrefServiceSimple* prefs_; | 196 TestingPrefServiceSimple* prefs_; |
214 | 197 |
215 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 198 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
216 }; | 199 }; |
217 | 200 |
218 } // namespace | 201 } // namespace |
219 | 202 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 system_profile.field_trial(i + arraysize(kFieldTrialIds)); | 264 system_profile.field_trial(i + arraysize(kFieldTrialIds)); |
282 EXPECT_EQ(kSyntheticTrials[i].name, field_trial.name_id()); | 265 EXPECT_EQ(kSyntheticTrials[i].name, field_trial.name_id()); |
283 EXPECT_EQ(kSyntheticTrials[i].group, field_trial.group_id()); | 266 EXPECT_EQ(kSyntheticTrials[i].group, field_trial.group_id()); |
284 } | 267 } |
285 | 268 |
286 EXPECT_EQ(metrics::TestMetricsServiceClient::kBrandForTesting, | 269 EXPECT_EQ(metrics::TestMetricsServiceClient::kBrandForTesting, |
287 system_profile.brand_code()); | 270 system_profile.brand_code()); |
288 | 271 |
289 const metrics::SystemProfileProto::Hardware& hardware = | 272 const metrics::SystemProfileProto::Hardware& hardware = |
290 system_profile.hardware(); | 273 system_profile.hardware(); |
291 EXPECT_EQ(kScreenWidth, hardware.primary_screen_width()); | |
292 EXPECT_EQ(kScreenHeight, hardware.primary_screen_height()); | |
293 EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor()); | |
294 EXPECT_EQ(kScreenCount, hardware.screen_count()); | |
295 | 274 |
296 EXPECT_TRUE(hardware.has_cpu()); | 275 EXPECT_TRUE(hardware.has_cpu()); |
297 EXPECT_TRUE(hardware.cpu().has_vendor_name()); | 276 EXPECT_TRUE(hardware.cpu().has_vendor_name()); |
298 EXPECT_TRUE(hardware.cpu().has_signature()); | 277 EXPECT_TRUE(hardware.cpu().has_signature()); |
299 | 278 |
300 // TODO(isherman): Verify other data written into the protobuf as a result | 279 // TODO(isherman): Verify other data written into the protobuf as a result |
301 // of this call. | 280 // of this call. |
302 } | 281 } |
303 | 282 |
304 protected: | 283 protected: |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 PairedDevice device2 = | 792 PairedDevice device2 = |
814 log.system_profile().hardware().bluetooth().paired_device(1); | 793 log.system_profile().hardware().bluetooth().paired_device(1); |
815 | 794 |
816 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | 795 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
817 device2.bluetooth_class()); | 796 device2.bluetooth_class()); |
818 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | 797 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
819 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | 798 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
820 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | 799 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
821 } | 800 } |
822 #endif // OS_CHROMEOS | 801 #endif // OS_CHROMEOS |
OLD | NEW |