| 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/profiler_event.pb.h" | 31 #include "components/metrics/proto/profiler_event.pb.h" |
| 32 #include "components/metrics/proto/system_profile.pb.h" | 32 #include "components/metrics/proto/system_profile.pb.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 char kBrandForTesting[] = "brand_for_testing"; | 87 const char kBrandForTesting[] = "brand_for_testing"; |
| 93 const variations::ActiveGroupId kFieldTrialIds[] = { | 88 const variations::ActiveGroupId kFieldTrialIds[] = { |
| 94 {37, 43}, | 89 {37, 43}, |
| 95 {13, 47}, | 90 {13, 47}, |
| 96 {23, 17} | 91 {23, 17} |
| 97 }; | 92 }; |
| 98 const variations::ActiveGroupId kSyntheticTrials[] = { | 93 const variations::ActiveGroupId kSyntheticTrials[] = { |
| 99 {55, 15}, | 94 {55, 15}, |
| 100 {66, 16} | 95 {66, 16} |
| 101 }; | 96 }; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 virtual void GetFieldTrialIds( | 181 virtual void GetFieldTrialIds( |
| 187 std::vector<variations::ActiveGroupId>* field_trial_ids) const | 182 std::vector<variations::ActiveGroupId>* field_trial_ids) const |
| 188 OVERRIDE { | 183 OVERRIDE { |
| 189 ASSERT_TRUE(field_trial_ids->empty()); | 184 ASSERT_TRUE(field_trial_ids->empty()); |
| 190 | 185 |
| 191 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { | 186 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { |
| 192 field_trial_ids->push_back(kFieldTrialIds[i]); | 187 field_trial_ids->push_back(kFieldTrialIds[i]); |
| 193 } | 188 } |
| 194 } | 189 } |
| 195 | 190 |
| 196 virtual gfx::Size GetScreenSize() const OVERRIDE { | |
| 197 return gfx::Size(kScreenWidth, kScreenHeight); | |
| 198 } | |
| 199 | |
| 200 virtual float GetScreenDeviceScaleFactor() const OVERRIDE { | |
| 201 return kScreenScaleFactor; | |
| 202 } | |
| 203 | |
| 204 virtual int GetScreenCount() const OVERRIDE { | |
| 205 return kScreenCount; | |
| 206 } | |
| 207 | |
| 208 // Scoped PrefsService, which may not be used if |prefs_ != &scoped_prefs|. | 191 // Scoped PrefsService, which may not be used if |prefs_ != &scoped_prefs|. |
| 209 TestingPrefServiceSimple scoped_prefs_; | 192 TestingPrefServiceSimple scoped_prefs_; |
| 210 // Weak pointer to the PrefsService used by this log. | 193 // Weak pointer to the PrefsService used by this log. |
| 211 TestingPrefServiceSimple* prefs_; | 194 TestingPrefServiceSimple* prefs_; |
| 212 | 195 |
| 213 google_util::BrandForTesting brand_for_testing_; | 196 google_util::BrandForTesting brand_for_testing_; |
| 214 | 197 |
| 215 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); | 198 DISALLOW_COPY_AND_ASSIGN(TestMetricsLog); |
| 216 }; | 199 }; |
| 217 | 200 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 const metrics::SystemProfileProto::FieldTrial& field_trial = | 266 const metrics::SystemProfileProto::FieldTrial& field_trial = |
| 284 system_profile.field_trial(i + arraysize(kFieldTrialIds)); | 267 system_profile.field_trial(i + arraysize(kFieldTrialIds)); |
| 285 EXPECT_EQ(kSyntheticTrials[i].name, field_trial.name_id()); | 268 EXPECT_EQ(kSyntheticTrials[i].name, field_trial.name_id()); |
| 286 EXPECT_EQ(kSyntheticTrials[i].group, field_trial.group_id()); | 269 EXPECT_EQ(kSyntheticTrials[i].group, field_trial.group_id()); |
| 287 } | 270 } |
| 288 | 271 |
| 289 EXPECT_EQ(kBrandForTesting, system_profile.brand_code()); | 272 EXPECT_EQ(kBrandForTesting, system_profile.brand_code()); |
| 290 | 273 |
| 291 const metrics::SystemProfileProto::Hardware& hardware = | 274 const metrics::SystemProfileProto::Hardware& hardware = |
| 292 system_profile.hardware(); | 275 system_profile.hardware(); |
| 293 EXPECT_EQ(kScreenWidth, hardware.primary_screen_width()); | |
| 294 EXPECT_EQ(kScreenHeight, hardware.primary_screen_height()); | |
| 295 EXPECT_EQ(kScreenScaleFactor, hardware.primary_screen_scale_factor()); | |
| 296 EXPECT_EQ(kScreenCount, hardware.screen_count()); | |
| 297 | 276 |
| 298 EXPECT_TRUE(hardware.has_cpu()); | 277 EXPECT_TRUE(hardware.has_cpu()); |
| 299 EXPECT_TRUE(hardware.cpu().has_vendor_name()); | 278 EXPECT_TRUE(hardware.cpu().has_vendor_name()); |
| 300 EXPECT_TRUE(hardware.cpu().has_signature()); | 279 EXPECT_TRUE(hardware.cpu().has_signature()); |
| 301 | 280 |
| 302 // TODO(isherman): Verify other data written into the protobuf as a result | 281 // TODO(isherman): Verify other data written into the protobuf as a result |
| 303 // of this call. | 282 // of this call. |
| 304 } | 283 } |
| 305 | 284 |
| 306 protected: | 285 protected: |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 PairedDevice device2 = | 784 PairedDevice device2 = |
| 806 log.system_profile().hardware().bluetooth().paired_device(1); | 785 log.system_profile().hardware().bluetooth().paired_device(1); |
| 807 | 786 |
| 808 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | 787 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
| 809 device2.bluetooth_class()); | 788 device2.bluetooth_class()); |
| 810 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | 789 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
| 811 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | 790 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
| 812 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | 791 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
| 813 } | 792 } |
| 814 #endif // OS_CHROMEOS | 793 #endif // OS_CHROMEOS |
| OLD | NEW |