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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/port.h" | 12 #include "base/port.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/prefs/scoped_user_pref_update.h" | 14 #include "base/prefs/scoped_user_pref_update.h" |
15 #include "base/prefs/testing_pref_service.h" | 15 #include "base/prefs/testing_pref_service.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "base/tracked_objects.h" | 22 #include "base/tracked_objects.h" |
23 #include "chrome/browser/google/google_util.h" | 23 #include "chrome/browser/google/google_util.h" |
24 #include "chrome/browser/prefs/browser_prefs.h" | 24 #include "chrome/browser/prefs/browser_prefs.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/chrome_version_info.h" | 26 #include "chrome/common/chrome_version_info.h" |
27 #include "chrome/common/metrics/variations/variations_util.h" | |
28 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
29 #include "chrome/installer/util/google_update_settings.h" | 28 #include "chrome/installer/util/google_update_settings.h" |
30 #include "components/metrics/metrics_hashes.h" | 29 #include "components/metrics/metrics_hashes.h" |
31 #include "components/metrics/proto/profiler_event.pb.h" | 30 #include "components/metrics/proto/profiler_event.pb.h" |
32 #include "components/metrics/proto/system_profile.pb.h" | 31 #include "components/metrics/proto/system_profile.pb.h" |
| 32 #include "components/variations/active_field_trials.h" |
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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const int64 kInstallDate = 1373051956; | 82 const int64 kInstallDate = 1373051956; |
83 const int64 kInstallDateExpected = 1373050800; // Computed from kInstallDate. | 83 const int64 kInstallDateExpected = 1373050800; // Computed from kInstallDate. |
84 const int64 kEnabledDate = 1373001211; | 84 const int64 kEnabledDate = 1373001211; |
85 const int64 kEnabledDateExpected = 1373000400; // Computed from kEnabledDate. | 85 const int64 kEnabledDateExpected = 1373000400; // Computed from kEnabledDate. |
86 const int kSessionId = 127; | 86 const int kSessionId = 127; |
87 const int kScreenWidth = 1024; | 87 const int kScreenWidth = 1024; |
88 const int kScreenHeight = 768; | 88 const int kScreenHeight = 768; |
89 const int kScreenCount = 3; | 89 const int kScreenCount = 3; |
90 const float kScreenScaleFactor = 2; | 90 const float kScreenScaleFactor = 2; |
91 const char kBrandForTesting[] = "brand_for_testing"; | 91 const char kBrandForTesting[] = "brand_for_testing"; |
92 const chrome_variations::ActiveGroupId kFieldTrialIds[] = { | 92 const variations::ActiveGroupId kFieldTrialIds[] = { |
93 {37, 43}, | 93 {37, 43}, |
94 {13, 47}, | 94 {13, 47}, |
95 {23, 17} | 95 {23, 17} |
96 }; | 96 }; |
97 const chrome_variations::ActiveGroupId kSyntheticTrials[] = { | 97 const variations::ActiveGroupId kSyntheticTrials[] = { |
98 {55, 15}, | 98 {55, 15}, |
99 {66, 16} | 99 {66, 16} |
100 }; | 100 }; |
101 | 101 |
102 #if defined(ENABLE_PLUGINS) | 102 #if defined(ENABLE_PLUGINS) |
103 content::WebPluginInfo CreateFakePluginInfo( | 103 content::WebPluginInfo CreateFakePluginInfo( |
104 const std::string& name, | 104 const std::string& name, |
105 const base::FilePath::CharType* path, | 105 const base::FilePath::CharType* path, |
106 const std::string& version, | 106 const std::string& version, |
107 bool is_pepper) { | 107 bool is_pepper) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 base::Int64ToString(kEnabledDate)); | 176 base::Int64ToString(kEnabledDate)); |
177 #if defined(OS_CHROMEOS) | 177 #if defined(OS_CHROMEOS) |
178 prefs_->SetInteger(prefs::kStabilityChildProcessCrashCount, 10); | 178 prefs_->SetInteger(prefs::kStabilityChildProcessCrashCount, 10); |
179 prefs_->SetInteger(prefs::kStabilityOtherUserCrashCount, 11); | 179 prefs_->SetInteger(prefs::kStabilityOtherUserCrashCount, 11); |
180 prefs_->SetInteger(prefs::kStabilityKernelCrashCount, 12); | 180 prefs_->SetInteger(prefs::kStabilityKernelCrashCount, 12); |
181 prefs_->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 13); | 181 prefs_->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 13); |
182 #endif // OS_CHROMEOS | 182 #endif // OS_CHROMEOS |
183 } | 183 } |
184 | 184 |
185 virtual void GetFieldTrialIds( | 185 virtual void GetFieldTrialIds( |
186 std::vector<chrome_variations::ActiveGroupId>* field_trial_ids) const | 186 std::vector<variations::ActiveGroupId>* field_trial_ids) const |
187 OVERRIDE { | 187 OVERRIDE { |
188 ASSERT_TRUE(field_trial_ids->empty()); | 188 ASSERT_TRUE(field_trial_ids->empty()); |
189 | 189 |
190 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { | 190 for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) { |
191 field_trial_ids->push_back(kFieldTrialIds[i]); | 191 field_trial_ids->push_back(kFieldTrialIds[i]); |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 virtual gfx::Size GetScreenSize() const OVERRIDE { | 195 virtual gfx::Size GetScreenSize() const OVERRIDE { |
196 return gfx::Size(kScreenWidth, kScreenHeight); | 196 return gfx::Size(kScreenWidth, kScreenHeight); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 content::TestBrowserThreadBundle thread_bundle_; | 312 content::TestBrowserThreadBundle thread_bundle_; |
313 | 313 |
314 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest); | 314 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest); |
315 }; | 315 }; |
316 | 316 |
317 TEST_F(MetricsLogTest, RecordEnvironment) { | 317 TEST_F(MetricsLogTest, RecordEnvironment) { |
318 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 318 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
319 | 319 |
320 std::vector<content::WebPluginInfo> plugins; | 320 std::vector<content::WebPluginInfo> plugins; |
321 GoogleUpdateMetrics google_update_metrics; | 321 GoogleUpdateMetrics google_update_metrics; |
322 std::vector<chrome_variations::ActiveGroupId> synthetic_trials; | 322 std::vector<variations::ActiveGroupId> synthetic_trials; |
323 // Add two synthetic trials. | 323 // Add two synthetic trials. |
324 synthetic_trials.push_back(kSyntheticTrials[0]); | 324 synthetic_trials.push_back(kSyntheticTrials[0]); |
325 synthetic_trials.push_back(kSyntheticTrials[1]); | 325 synthetic_trials.push_back(kSyntheticTrials[1]); |
326 | 326 |
327 log.RecordEnvironment(plugins, google_update_metrics, synthetic_trials); | 327 log.RecordEnvironment(plugins, google_update_metrics, synthetic_trials); |
328 // Check that the system profile on the log has the correct values set. | 328 // Check that the system profile on the log has the correct values set. |
329 CheckSystemProfile(log.system_profile()); | 329 CheckSystemProfile(log.system_profile()); |
330 | 330 |
331 // Check that the system profile has also been written to prefs. | 331 // Check that the system profile has also been written to prefs. |
332 PrefService* local_state = log.GetPrefService(); | 332 PrefService* local_state = log.GetPrefService(); |
(...skipping 19 matching lines...) Expand all Loading... |
352 { | 352 { |
353 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 353 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
354 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); | 354 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); |
355 } | 355 } |
356 | 356 |
357 // Do a RecordEnvironment() call and check whether the pref is recorded. | 357 // Do a RecordEnvironment() call and check whether the pref is recorded. |
358 { | 358 { |
359 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 359 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
360 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 360 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
361 GoogleUpdateMetrics(), | 361 GoogleUpdateMetrics(), |
362 std::vector<chrome_variations::ActiveGroupId>()); | 362 std::vector<variations::ActiveGroupId>()); |
363 EXPECT_FALSE(prefs.GetString(kSystemProfilePref).empty()); | 363 EXPECT_FALSE(prefs.GetString(kSystemProfilePref).empty()); |
364 EXPECT_FALSE(prefs.GetString(kSystemProfileHashPref).empty()); | 364 EXPECT_FALSE(prefs.GetString(kSystemProfileHashPref).empty()); |
365 } | 365 } |
366 | 366 |
367 { | 367 { |
368 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 368 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
369 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs()); | 369 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs()); |
370 // Check some values in the system profile. | 370 // Check some values in the system profile. |
371 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date()); | 371 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date()); |
372 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date()); | 372 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date()); |
373 // Ensure that the call cleared the prefs. | 373 // Ensure that the call cleared the prefs. |
374 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); | 374 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); |
375 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); | 375 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); |
376 } | 376 } |
377 | 377 |
378 // Ensure that a non-matching hash results in the pref being invalid. | 378 // Ensure that a non-matching hash results in the pref being invalid. |
379 { | 379 { |
380 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 380 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
381 // Call RecordEnvironment() to record the pref again. | 381 // Call RecordEnvironment() to record the pref again. |
382 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 382 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
383 GoogleUpdateMetrics(), | 383 GoogleUpdateMetrics(), |
384 std::vector<chrome_variations::ActiveGroupId>()); | 384 std::vector<variations::ActiveGroupId>()); |
385 } | 385 } |
386 | 386 |
387 { | 387 { |
388 // Set the hash to a bad value. | 388 // Set the hash to a bad value. |
389 prefs.SetString(kSystemProfileHashPref, "deadbeef"); | 389 prefs.SetString(kSystemProfileHashPref, "deadbeef"); |
390 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 390 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
391 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); | 391 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); |
392 // Ensure that the prefs are cleared, even if the call failed. | 392 // Ensure that the prefs are cleared, even if the call failed. |
393 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); | 393 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); |
394 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); | 394 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); |
395 } | 395 } |
396 } | 396 } |
397 | 397 |
398 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) { | 398 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) { |
399 TestMetricsLog log(kClientId, kSessionId, MetricsLog::INITIAL_STABILITY_LOG); | 399 TestMetricsLog log(kClientId, kSessionId, MetricsLog::INITIAL_STABILITY_LOG); |
400 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 400 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
401 GoogleUpdateMetrics(), | 401 GoogleUpdateMetrics(), |
402 std::vector<chrome_variations::ActiveGroupId>()); | 402 std::vector<variations::ActiveGroupId>()); |
403 log.RecordStabilityMetrics(base::TimeDelta(), base::TimeDelta()); | 403 log.RecordStabilityMetrics(base::TimeDelta(), base::TimeDelta()); |
404 const metrics::SystemProfileProto_Stability& stability = | 404 const metrics::SystemProfileProto_Stability& stability = |
405 log.system_profile().stability(); | 405 log.system_profile().stability(); |
406 // Required metrics: | 406 // Required metrics: |
407 EXPECT_TRUE(stability.has_launch_count()); | 407 EXPECT_TRUE(stability.has_launch_count()); |
408 EXPECT_TRUE(stability.has_crash_count()); | 408 EXPECT_TRUE(stability.has_crash_count()); |
409 // Initial log metrics: | 409 // Initial log metrics: |
410 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); | 410 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); |
411 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); | 411 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); |
412 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); | 412 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); |
413 EXPECT_TRUE(stability.has_debugger_present_count()); | 413 EXPECT_TRUE(stability.has_debugger_present_count()); |
414 EXPECT_TRUE(stability.has_debugger_not_present_count()); | 414 EXPECT_TRUE(stability.has_debugger_not_present_count()); |
415 } | 415 } |
416 | 416 |
417 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { | 417 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { |
418 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 418 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
419 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 419 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
420 GoogleUpdateMetrics(), | 420 GoogleUpdateMetrics(), |
421 std::vector<chrome_variations::ActiveGroupId>()); | 421 std::vector<variations::ActiveGroupId>()); |
422 log.RecordStabilityMetrics(base::TimeDelta(), base::TimeDelta()); | 422 log.RecordStabilityMetrics(base::TimeDelta(), base::TimeDelta()); |
423 const metrics::SystemProfileProto_Stability& stability = | 423 const metrics::SystemProfileProto_Stability& stability = |
424 log.system_profile().stability(); | 424 log.system_profile().stability(); |
425 // Required metrics: | 425 // Required metrics: |
426 EXPECT_TRUE(stability.has_launch_count()); | 426 EXPECT_TRUE(stability.has_launch_count()); |
427 EXPECT_TRUE(stability.has_crash_count()); | 427 EXPECT_TRUE(stability.has_crash_count()); |
428 // Initial log metrics: | 428 // Initial log metrics: |
429 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); | 429 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); |
430 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); | 430 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); |
431 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); | 431 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); |
432 EXPECT_FALSE(stability.has_debugger_present_count()); | 432 EXPECT_FALSE(stability.has_debugger_present_count()); |
433 EXPECT_FALSE(stability.has_debugger_not_present_count()); | 433 EXPECT_FALSE(stability.has_debugger_not_present_count()); |
434 } | 434 } |
435 | 435 |
436 #if defined(ENABLE_PLUGINS) | 436 #if defined(ENABLE_PLUGINS) |
437 TEST_F(MetricsLogTest, Plugins) { | 437 TEST_F(MetricsLogTest, Plugins) { |
438 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 438 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
439 | 439 |
440 std::vector<content::WebPluginInfo> plugins; | 440 std::vector<content::WebPluginInfo> plugins; |
441 plugins.push_back(CreateFakePluginInfo("p1", FILE_PATH_LITERAL("p1.plugin"), | 441 plugins.push_back(CreateFakePluginInfo("p1", FILE_PATH_LITERAL("p1.plugin"), |
442 "1.5", true)); | 442 "1.5", true)); |
443 plugins.push_back(CreateFakePluginInfo("p2", FILE_PATH_LITERAL("p2.plugin"), | 443 plugins.push_back(CreateFakePluginInfo("p2", FILE_PATH_LITERAL("p2.plugin"), |
444 "2.0", false)); | 444 "2.0", false)); |
445 log.RecordEnvironment(plugins, GoogleUpdateMetrics(), | 445 log.RecordEnvironment(plugins, GoogleUpdateMetrics(), |
446 std::vector<chrome_variations::ActiveGroupId>()); | 446 std::vector<variations::ActiveGroupId>()); |
447 | 447 |
448 const metrics::SystemProfileProto& system_profile = log.system_profile(); | 448 const metrics::SystemProfileProto& system_profile = log.system_profile(); |
449 ASSERT_EQ(2, system_profile.plugin_size()); | 449 ASSERT_EQ(2, system_profile.plugin_size()); |
450 EXPECT_EQ("p1", system_profile.plugin(0).name()); | 450 EXPECT_EQ("p1", system_profile.plugin(0).name()); |
451 EXPECT_EQ("p1.plugin", system_profile.plugin(0).filename()); | 451 EXPECT_EQ("p1.plugin", system_profile.plugin(0).filename()); |
452 EXPECT_EQ("1.5", system_profile.plugin(0).version()); | 452 EXPECT_EQ("1.5", system_profile.plugin(0).version()); |
453 EXPECT_TRUE(system_profile.plugin(0).is_pepper()); | 453 EXPECT_TRUE(system_profile.plugin(0).is_pepper()); |
454 EXPECT_EQ("p2", system_profile.plugin(1).name()); | 454 EXPECT_EQ("p2", system_profile.plugin(1).name()); |
455 EXPECT_EQ("p2.plugin", system_profile.plugin(1).filename()); | 455 EXPECT_EQ("p2.plugin", system_profile.plugin(1).filename()); |
456 EXPECT_EQ("2.0", system_profile.plugin(1).version()); | 456 EXPECT_EQ("2.0", system_profile.plugin(1).version()); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 user_manager->AddKioskAppUser(user1); | 668 user_manager->AddKioskAppUser(user1); |
669 user_manager->AddKioskAppUser(user2); | 669 user_manager->AddKioskAppUser(user2); |
670 user_manager->AddKioskAppUser(user3); | 670 user_manager->AddKioskAppUser(user3); |
671 | 671 |
672 user_manager->LoginUser(user1); | 672 user_manager->LoginUser(user1); |
673 user_manager->LoginUser(user3); | 673 user_manager->LoginUser(user3); |
674 | 674 |
675 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 675 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
676 std::vector<content::WebPluginInfo> plugins; | 676 std::vector<content::WebPluginInfo> plugins; |
677 GoogleUpdateMetrics google_update_metrics; | 677 GoogleUpdateMetrics google_update_metrics; |
678 std::vector<chrome_variations::ActiveGroupId> synthetic_trials; | 678 std::vector<variations::ActiveGroupId> synthetic_trials; |
679 log.RecordEnvironment(plugins, google_update_metrics, synthetic_trials); | 679 log.RecordEnvironment(plugins, google_update_metrics, synthetic_trials); |
680 EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); | 680 EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); |
681 } | 681 } |
682 | 682 |
683 TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { | 683 TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { |
684 std::string user1("user1@example.com"); | 684 std::string user1("user1@example.com"); |
685 std::string user2("user2@example.com"); | 685 std::string user2("user2@example.com"); |
686 std::string user3("user3@example.com"); | 686 std::string user3("user3@example.com"); |
687 | 687 |
688 // |scoped_enabler| takes over the lifetime of |user_manager|. | 688 // |scoped_enabler| takes over the lifetime of |user_manager|. |
689 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); | 689 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); |
690 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | 690 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
691 user_manager->AddKioskAppUser(user1); | 691 user_manager->AddKioskAppUser(user1); |
692 user_manager->AddKioskAppUser(user2); | 692 user_manager->AddKioskAppUser(user2); |
693 user_manager->AddKioskAppUser(user3); | 693 user_manager->AddKioskAppUser(user3); |
694 | 694 |
695 user_manager->LoginUser(user1); | 695 user_manager->LoginUser(user1); |
696 | 696 |
697 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 697 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
698 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); | 698 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); |
699 | 699 |
700 user_manager->LoginUser(user2); | 700 user_manager->LoginUser(user2); |
701 std::vector<chrome_variations::ActiveGroupId> synthetic_trials; | 701 std::vector<variations::ActiveGroupId> synthetic_trials; |
702 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 702 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
703 GoogleUpdateMetrics(), synthetic_trials); | 703 GoogleUpdateMetrics(), synthetic_trials); |
704 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); | 704 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); |
705 } | 705 } |
706 | 706 |
707 TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { | 707 TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { |
708 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 708 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
709 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 709 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
710 GoogleUpdateMetrics(), | 710 GoogleUpdateMetrics(), |
711 std::vector<chrome_variations::ActiveGroupId>()); | 711 std::vector<variations::ActiveGroupId>()); |
712 | 712 |
713 EXPECT_TRUE(log.system_profile().has_hardware()); | 713 EXPECT_TRUE(log.system_profile().has_hardware()); |
714 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | 714 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
715 | 715 |
716 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | 716 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
717 EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); | 717 EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); |
718 } | 718 } |
719 | 719 |
720 TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { | 720 TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { |
721 FakeBluetoothAdapterClient::Properties* properties = | 721 FakeBluetoothAdapterClient::Properties* properties = |
722 fake_bluetooth_adapter_client_->GetProperties( | 722 fake_bluetooth_adapter_client_->GetProperties( |
723 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); | 723 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); |
724 properties->powered.ReplaceValue(true); | 724 properties->powered.ReplaceValue(true); |
725 | 725 |
726 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 726 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
727 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 727 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
728 GoogleUpdateMetrics(), | 728 GoogleUpdateMetrics(), |
729 std::vector<chrome_variations::ActiveGroupId>()); | 729 std::vector<variations::ActiveGroupId>()); |
730 | 730 |
731 EXPECT_TRUE(log.system_profile().has_hardware()); | 731 EXPECT_TRUE(log.system_profile().has_hardware()); |
732 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | 732 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
733 | 733 |
734 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | 734 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
735 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); | 735 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); |
736 } | 736 } |
737 | 737 |
738 TEST_F(MetricsLogTest, BluetoothPairedDevices) { | 738 TEST_F(MetricsLogTest, BluetoothPairedDevices) { |
739 // The fake bluetooth adapter class already claims to be paired with one | 739 // The fake bluetooth adapter class already claims to be paired with one |
740 // device when initialized. Add a second and third fake device to it so we | 740 // device when initialized. Add a second and third fake device to it so we |
741 // can test the cases where a device is not paired (LE device, generally) | 741 // can test the cases where a device is not paired (LE device, generally) |
742 // and a device that does not have Device ID information. | 742 // and a device that does not have Device ID information. |
743 fake_bluetooth_device_client_->CreateDevice( | 743 fake_bluetooth_device_client_->CreateDevice( |
744 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 744 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
745 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); | 745 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
746 | 746 |
747 fake_bluetooth_device_client_->CreateDevice( | 747 fake_bluetooth_device_client_->CreateDevice( |
748 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 748 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
749 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 749 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
750 | 750 |
751 FakeBluetoothDeviceClient::Properties* properties = | 751 FakeBluetoothDeviceClient::Properties* properties = |
752 fake_bluetooth_device_client_->GetProperties( | 752 fake_bluetooth_device_client_->GetProperties( |
753 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 753 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
754 properties->paired.ReplaceValue(true); | 754 properties->paired.ReplaceValue(true); |
755 | 755 |
756 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 756 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
757 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 757 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), |
758 GoogleUpdateMetrics(), | 758 GoogleUpdateMetrics(), |
759 std::vector<chrome_variations::ActiveGroupId>()); | 759 std::vector<variations::ActiveGroupId>()); |
760 | 760 |
761 ASSERT_TRUE(log.system_profile().has_hardware()); | 761 ASSERT_TRUE(log.system_profile().has_hardware()); |
762 ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); | 762 ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); |
763 | 763 |
764 // Only two of the devices should appear. | 764 // Only two of the devices should appear. |
765 EXPECT_EQ(2, | 765 EXPECT_EQ(2, |
766 log.system_profile().hardware().bluetooth().paired_device_size()); | 766 log.system_profile().hardware().bluetooth().paired_device_size()); |
767 | 767 |
768 typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice | 768 typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice |
769 PairedDevice; | 769 PairedDevice; |
(...skipping 17 matching lines...) Expand all Loading... |
787 PairedDevice device2 = | 787 PairedDevice device2 = |
788 log.system_profile().hardware().bluetooth().paired_device(1); | 788 log.system_profile().hardware().bluetooth().paired_device(1); |
789 | 789 |
790 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | 790 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
791 device2.bluetooth_class()); | 791 device2.bluetooth_class()); |
792 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | 792 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
793 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | 793 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
794 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | 794 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
795 } | 795 } |
796 #endif // OS_CHROMEOS | 796 #endif // OS_CHROMEOS |
OLD | NEW |