| 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/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/installer/util/google_update_settings.h" | 28 #include "chrome/installer/util/google_update_settings.h" |
| 29 #include "components/metrics/metrics_hashes.h" | 29 #include "components/metrics/metrics_hashes.h" |
| 30 #include "components/metrics/metrics_provider.h" |
| 30 #include "components/metrics/proto/profiler_event.pb.h" | 31 #include "components/metrics/proto/profiler_event.pb.h" |
| 31 #include "components/metrics/proto/system_profile.pb.h" | 32 #include "components/metrics/proto/system_profile.pb.h" |
| 32 #include "components/variations/active_field_trials.h" | 33 #include "components/variations/active_field_trials.h" |
| 33 #include "components/variations/metrics_util.h" | 34 #include "components/variations/metrics_util.h" |
| 34 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/common/process_type.h" | 36 #include "content/public/common/process_type.h" |
| 36 #include "content/public/common/webplugininfo.h" | 37 #include "content/public/common/webplugininfo.h" |
| 37 #include "content/public/test/test_browser_thread_bundle.h" | 38 #include "content/public/test/test_browser_thread_bundle.h" |
| 38 #include "content/public/test/test_utils.h" | 39 #include "content/public/test/test_utils.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 TEST_F(MetricsLogTest, RecordEnvironment) { | 318 TEST_F(MetricsLogTest, RecordEnvironment) { |
| 318 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 319 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 319 | 320 |
| 320 std::vector<content::WebPluginInfo> plugins; | 321 std::vector<content::WebPluginInfo> plugins; |
| 321 GoogleUpdateMetrics google_update_metrics; | 322 GoogleUpdateMetrics google_update_metrics; |
| 322 std::vector<variations::ActiveGroupId> synthetic_trials; | 323 std::vector<variations::ActiveGroupId> synthetic_trials; |
| 323 // Add two synthetic trials. | 324 // Add two synthetic trials. |
| 324 synthetic_trials.push_back(kSyntheticTrials[0]); | 325 synthetic_trials.push_back(kSyntheticTrials[0]); |
| 325 synthetic_trials.push_back(kSyntheticTrials[1]); | 326 synthetic_trials.push_back(kSyntheticTrials[1]); |
| 326 | 327 |
| 327 log.RecordEnvironment(plugins, google_update_metrics, synthetic_trials); | 328 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| 329 plugins, google_update_metrics, synthetic_trials); |
| 328 // Check that the system profile on the log has the correct values set. | 330 // Check that the system profile on the log has the correct values set. |
| 329 CheckSystemProfile(log.system_profile()); | 331 CheckSystemProfile(log.system_profile()); |
| 330 | 332 |
| 331 // Check that the system profile has also been written to prefs. | 333 // Check that the system profile has also been written to prefs. |
| 332 PrefService* local_state = log.GetPrefService(); | 334 PrefService* local_state = log.GetPrefService(); |
| 333 const std::string base64_system_profile = | 335 const std::string base64_system_profile = |
| 334 local_state->GetString(prefs::kStabilitySavedSystemProfile); | 336 local_state->GetString(prefs::kStabilitySavedSystemProfile); |
| 335 EXPECT_FALSE(base64_system_profile.empty()); | 337 EXPECT_FALSE(base64_system_profile.empty()); |
| 336 std::string serialied_system_profile; | 338 std::string serialied_system_profile; |
| 337 EXPECT_TRUE(base::Base64Decode(base64_system_profile, | 339 EXPECT_TRUE(base::Base64Decode(base64_system_profile, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 350 | 352 |
| 351 // The pref value is empty, so loading it from prefs should fail. | 353 // The pref value is empty, so loading it from prefs should fail. |
| 352 { | 354 { |
| 353 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 355 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
| 354 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); | 356 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); |
| 355 } | 357 } |
| 356 | 358 |
| 357 // Do a RecordEnvironment() call and check whether the pref is recorded. | 359 // Do a RecordEnvironment() call and check whether the pref is recorded. |
| 358 { | 360 { |
| 359 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 361 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
| 360 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 362 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| 363 std::vector<content::WebPluginInfo>(), |
| 361 GoogleUpdateMetrics(), | 364 GoogleUpdateMetrics(), |
| 362 std::vector<variations::ActiveGroupId>()); | 365 std::vector<variations::ActiveGroupId>()); |
| 363 EXPECT_FALSE(prefs.GetString(kSystemProfilePref).empty()); | 366 EXPECT_FALSE(prefs.GetString(kSystemProfilePref).empty()); |
| 364 EXPECT_FALSE(prefs.GetString(kSystemProfileHashPref).empty()); | 367 EXPECT_FALSE(prefs.GetString(kSystemProfileHashPref).empty()); |
| 365 } | 368 } |
| 366 | 369 |
| 367 { | 370 { |
| 368 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 371 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
| 369 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs()); | 372 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs()); |
| 370 // Check some values in the system profile. | 373 // Check some values in the system profile. |
| 371 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date()); | 374 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date()); |
| 372 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date()); | 375 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date()); |
| 373 // Ensure that the call cleared the prefs. | 376 // Ensure that the call cleared the prefs. |
| 374 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); | 377 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); |
| 375 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); | 378 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); |
| 376 } | 379 } |
| 377 | 380 |
| 378 // Ensure that a non-matching hash results in the pref being invalid. | 381 // Ensure that a non-matching hash results in the pref being invalid. |
| 379 { | 382 { |
| 380 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 383 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
| 381 // Call RecordEnvironment() to record the pref again. | 384 // Call RecordEnvironment() to record the pref again. |
| 382 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 385 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| 386 std::vector<content::WebPluginInfo>(), |
| 383 GoogleUpdateMetrics(), | 387 GoogleUpdateMetrics(), |
| 384 std::vector<variations::ActiveGroupId>()); | 388 std::vector<variations::ActiveGroupId>()); |
| 385 } | 389 } |
| 386 | 390 |
| 387 { | 391 { |
| 388 // Set the hash to a bad value. | 392 // Set the hash to a bad value. |
| 389 prefs.SetString(kSystemProfileHashPref, "deadbeef"); | 393 prefs.SetString(kSystemProfileHashPref, "deadbeef"); |
| 390 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); | 394 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &prefs); |
| 391 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); | 395 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); |
| 392 // Ensure that the prefs are cleared, even if the call failed. | 396 // Ensure that the prefs are cleared, even if the call failed. |
| 393 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); | 397 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); |
| 394 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); | 398 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); |
| 395 } | 399 } |
| 396 } | 400 } |
| 397 | 401 |
| 398 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) { | 402 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) { |
| 399 TestMetricsLog log(kClientId, kSessionId, MetricsLog::INITIAL_STABILITY_LOG); | 403 TestMetricsLog log(kClientId, kSessionId, MetricsLog::INITIAL_STABILITY_LOG); |
| 400 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 404 std::vector<metrics::MetricsProvider*> metrics_providers; |
| 405 log.RecordEnvironment(metrics_providers, |
| 406 std::vector<content::WebPluginInfo>(), |
| 401 GoogleUpdateMetrics(), | 407 GoogleUpdateMetrics(), |
| 402 std::vector<variations::ActiveGroupId>()); | 408 std::vector<variations::ActiveGroupId>()); |
| 403 log.RecordStabilityMetrics(base::TimeDelta(), base::TimeDelta()); | 409 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), |
| 410 base::TimeDelta()); |
| 404 const metrics::SystemProfileProto_Stability& stability = | 411 const metrics::SystemProfileProto_Stability& stability = |
| 405 log.system_profile().stability(); | 412 log.system_profile().stability(); |
| 406 // Required metrics: | 413 // Required metrics: |
| 407 EXPECT_TRUE(stability.has_launch_count()); | 414 EXPECT_TRUE(stability.has_launch_count()); |
| 408 EXPECT_TRUE(stability.has_crash_count()); | 415 EXPECT_TRUE(stability.has_crash_count()); |
| 409 // Initial log metrics: | 416 // Initial log metrics: |
| 410 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); | 417 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); |
| 411 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); | 418 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); |
| 412 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); | 419 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); |
| 413 EXPECT_TRUE(stability.has_debugger_present_count()); | 420 EXPECT_TRUE(stability.has_debugger_present_count()); |
| 414 EXPECT_TRUE(stability.has_debugger_not_present_count()); | 421 EXPECT_TRUE(stability.has_debugger_not_present_count()); |
| 415 } | 422 } |
| 416 | 423 |
| 417 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { | 424 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { |
| 418 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 425 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 419 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 426 std::vector<metrics::MetricsProvider*> metrics_providers; |
| 427 log.RecordEnvironment(metrics_providers, |
| 428 std::vector<content::WebPluginInfo>(), |
| 420 GoogleUpdateMetrics(), | 429 GoogleUpdateMetrics(), |
| 421 std::vector<variations::ActiveGroupId>()); | 430 std::vector<variations::ActiveGroupId>()); |
| 422 log.RecordStabilityMetrics(base::TimeDelta(), base::TimeDelta()); | 431 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), |
| 432 base::TimeDelta()); |
| 423 const metrics::SystemProfileProto_Stability& stability = | 433 const metrics::SystemProfileProto_Stability& stability = |
| 424 log.system_profile().stability(); | 434 log.system_profile().stability(); |
| 425 // Required metrics: | 435 // Required metrics: |
| 426 EXPECT_TRUE(stability.has_launch_count()); | 436 EXPECT_TRUE(stability.has_launch_count()); |
| 427 EXPECT_TRUE(stability.has_crash_count()); | 437 EXPECT_TRUE(stability.has_crash_count()); |
| 428 // Initial log metrics: | 438 // Initial log metrics: |
| 429 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); | 439 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); |
| 430 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); | 440 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); |
| 431 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); | 441 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); |
| 432 EXPECT_FALSE(stability.has_debugger_present_count()); | 442 EXPECT_FALSE(stability.has_debugger_present_count()); |
| 433 EXPECT_FALSE(stability.has_debugger_not_present_count()); | 443 EXPECT_FALSE(stability.has_debugger_not_present_count()); |
| 434 } | 444 } |
| 435 | 445 |
| 436 #if defined(ENABLE_PLUGINS) | 446 #if defined(ENABLE_PLUGINS) |
| 437 TEST_F(MetricsLogTest, Plugins) { | 447 TEST_F(MetricsLogTest, Plugins) { |
| 438 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 448 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 449 std::vector<metrics::MetricsProvider*> metrics_providers; |
| 439 | 450 |
| 440 std::vector<content::WebPluginInfo> plugins; | 451 std::vector<content::WebPluginInfo> plugins; |
| 441 plugins.push_back(CreateFakePluginInfo("p1", FILE_PATH_LITERAL("p1.plugin"), | 452 plugins.push_back(CreateFakePluginInfo("p1", FILE_PATH_LITERAL("p1.plugin"), |
| 442 "1.5", true)); | 453 "1.5", true)); |
| 443 plugins.push_back(CreateFakePluginInfo("p2", FILE_PATH_LITERAL("p2.plugin"), | 454 plugins.push_back(CreateFakePluginInfo("p2", FILE_PATH_LITERAL("p2.plugin"), |
| 444 "2.0", false)); | 455 "2.0", false)); |
| 445 log.RecordEnvironment(plugins, GoogleUpdateMetrics(), | 456 log.RecordEnvironment(metrics_providers, plugins, GoogleUpdateMetrics(), |
| 446 std::vector<variations::ActiveGroupId>()); | 457 std::vector<variations::ActiveGroupId>()); |
| 447 | 458 |
| 448 const metrics::SystemProfileProto& system_profile = log.system_profile(); | 459 const metrics::SystemProfileProto& system_profile = log.system_profile(); |
| 449 ASSERT_EQ(2, system_profile.plugin_size()); | 460 ASSERT_EQ(2, system_profile.plugin_size()); |
| 450 EXPECT_EQ("p1", system_profile.plugin(0).name()); | 461 EXPECT_EQ("p1", system_profile.plugin(0).name()); |
| 451 EXPECT_EQ("p1.plugin", system_profile.plugin(0).filename()); | 462 EXPECT_EQ("p1.plugin", system_profile.plugin(0).filename()); |
| 452 EXPECT_EQ("1.5", system_profile.plugin(0).version()); | 463 EXPECT_EQ("1.5", system_profile.plugin(0).version()); |
| 453 EXPECT_TRUE(system_profile.plugin(0).is_pepper()); | 464 EXPECT_TRUE(system_profile.plugin(0).is_pepper()); |
| 454 EXPECT_EQ("p2", system_profile.plugin(1).name()); | 465 EXPECT_EQ("p2", system_profile.plugin(1).name()); |
| 455 EXPECT_EQ("p2.plugin", system_profile.plugin(1).filename()); | 466 EXPECT_EQ("p2.plugin", system_profile.plugin(1).filename()); |
| 456 EXPECT_EQ("2.0", system_profile.plugin(1).version()); | 467 EXPECT_EQ("2.0", system_profile.plugin(1).version()); |
| 457 EXPECT_FALSE(system_profile.plugin(1).is_pepper()); | 468 EXPECT_FALSE(system_profile.plugin(1).is_pepper()); |
| 458 | 469 |
| 459 // Now set some plugin stability stats for p2 and verify they're recorded. | 470 // Now set some plugin stability stats for p2 and verify they're recorded. |
| 460 scoped_ptr<base::DictionaryValue> plugin_dict(new base::DictionaryValue); | 471 scoped_ptr<base::DictionaryValue> plugin_dict(new base::DictionaryValue); |
| 461 plugin_dict->SetString(prefs::kStabilityPluginName, "p2"); | 472 plugin_dict->SetString(prefs::kStabilityPluginName, "p2"); |
| 462 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1); | 473 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1); |
| 463 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 2); | 474 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 2); |
| 464 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 3); | 475 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 3); |
| 465 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, 4); | 476 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, 4); |
| 466 { | 477 { |
| 467 ListPrefUpdate update(log.GetPrefService(), prefs::kStabilityPluginStats); | 478 ListPrefUpdate update(log.GetPrefService(), prefs::kStabilityPluginStats); |
| 468 update.Get()->Append(plugin_dict.release()); | 479 update.Get()->Append(plugin_dict.release()); |
| 469 } | 480 } |
| 470 | 481 |
| 471 log.RecordStabilityMetrics(base::TimeDelta(), base::TimeDelta()); | 482 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), |
| 483 base::TimeDelta()); |
| 472 const metrics::SystemProfileProto_Stability& stability = | 484 const metrics::SystemProfileProto_Stability& stability = |
| 473 log.system_profile().stability(); | 485 log.system_profile().stability(); |
| 474 ASSERT_EQ(1, stability.plugin_stability_size()); | 486 ASSERT_EQ(1, stability.plugin_stability_size()); |
| 475 EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name()); | 487 EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name()); |
| 476 EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename()); | 488 EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename()); |
| 477 EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version()); | 489 EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version()); |
| 478 EXPECT_FALSE(stability.plugin_stability(0).plugin().is_pepper()); | 490 EXPECT_FALSE(stability.plugin_stability(0).plugin().is_pepper()); |
| 479 EXPECT_EQ(1, stability.plugin_stability(0).launch_count()); | 491 EXPECT_EQ(1, stability.plugin_stability(0).launch_count()); |
| 480 EXPECT_EQ(2, stability.plugin_stability(0).crash_count()); | 492 EXPECT_EQ(2, stability.plugin_stability(0).crash_count()); |
| 481 EXPECT_EQ(3, stability.plugin_stability(0).instance_count()); | 493 EXPECT_EQ(3, stability.plugin_stability(0).instance_count()); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); | 678 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); |
| 667 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | 679 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
| 668 user_manager->AddKioskAppUser(user1); | 680 user_manager->AddKioskAppUser(user1); |
| 669 user_manager->AddKioskAppUser(user2); | 681 user_manager->AddKioskAppUser(user2); |
| 670 user_manager->AddKioskAppUser(user3); | 682 user_manager->AddKioskAppUser(user3); |
| 671 | 683 |
| 672 user_manager->LoginUser(user1); | 684 user_manager->LoginUser(user1); |
| 673 user_manager->LoginUser(user3); | 685 user_manager->LoginUser(user3); |
| 674 | 686 |
| 675 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 687 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 688 std::vector<metrics::MetricsProvider*> metrics_providers; |
| 676 std::vector<content::WebPluginInfo> plugins; | 689 std::vector<content::WebPluginInfo> plugins; |
| 677 GoogleUpdateMetrics google_update_metrics; | 690 GoogleUpdateMetrics google_update_metrics; |
| 678 std::vector<variations::ActiveGroupId> synthetic_trials; | 691 std::vector<variations::ActiveGroupId> synthetic_trials; |
| 679 log.RecordEnvironment(plugins, google_update_metrics, synthetic_trials); | 692 log.RecordEnvironment(metrics_providers, plugins, google_update_metrics, |
| 693 synthetic_trials); |
| 680 EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); | 694 EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); |
| 681 } | 695 } |
| 682 | 696 |
| 683 TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { | 697 TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { |
| 684 std::string user1("user1@example.com"); | 698 std::string user1("user1@example.com"); |
| 685 std::string user2("user2@example.com"); | 699 std::string user2("user2@example.com"); |
| 686 std::string user3("user3@example.com"); | 700 std::string user3("user3@example.com"); |
| 687 | 701 |
| 688 // |scoped_enabler| takes over the lifetime of |user_manager|. | 702 // |scoped_enabler| takes over the lifetime of |user_manager|. |
| 689 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); | 703 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); |
| 690 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | 704 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
| 691 user_manager->AddKioskAppUser(user1); | 705 user_manager->AddKioskAppUser(user1); |
| 692 user_manager->AddKioskAppUser(user2); | 706 user_manager->AddKioskAppUser(user2); |
| 693 user_manager->AddKioskAppUser(user3); | 707 user_manager->AddKioskAppUser(user3); |
| 694 | 708 |
| 695 user_manager->LoginUser(user1); | 709 user_manager->LoginUser(user1); |
| 696 | 710 |
| 697 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 711 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 698 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); | 712 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); |
| 699 | 713 |
| 700 user_manager->LoginUser(user2); | 714 user_manager->LoginUser(user2); |
| 715 std::vector<metrics::MetricsProvider*> metrics_providers; |
| 701 std::vector<variations::ActiveGroupId> synthetic_trials; | 716 std::vector<variations::ActiveGroupId> synthetic_trials; |
| 702 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 717 log.RecordEnvironment(metrics_providers, |
| 718 std::vector<content::WebPluginInfo>(), |
| 703 GoogleUpdateMetrics(), synthetic_trials); | 719 GoogleUpdateMetrics(), synthetic_trials); |
| 704 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); | 720 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); |
| 705 } | 721 } |
| 706 | 722 |
| 707 TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { | 723 TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { |
| 708 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 724 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 709 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 725 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| 726 std::vector<content::WebPluginInfo>(), |
| 710 GoogleUpdateMetrics(), | 727 GoogleUpdateMetrics(), |
| 711 std::vector<variations::ActiveGroupId>()); | 728 std::vector<variations::ActiveGroupId>()); |
| 712 | 729 |
| 713 EXPECT_TRUE(log.system_profile().has_hardware()); | 730 EXPECT_TRUE(log.system_profile().has_hardware()); |
| 714 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | 731 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
| 715 | 732 |
| 716 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | 733 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
| 717 EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); | 734 EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); |
| 718 } | 735 } |
| 719 | 736 |
| 720 TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { | 737 TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { |
| 721 FakeBluetoothAdapterClient::Properties* properties = | 738 FakeBluetoothAdapterClient::Properties* properties = |
| 722 fake_bluetooth_adapter_client_->GetProperties( | 739 fake_bluetooth_adapter_client_->GetProperties( |
| 723 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); | 740 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); |
| 724 properties->powered.ReplaceValue(true); | 741 properties->powered.ReplaceValue(true); |
| 725 | 742 |
| 726 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 743 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 727 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 744 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| 745 std::vector<content::WebPluginInfo>(), |
| 728 GoogleUpdateMetrics(), | 746 GoogleUpdateMetrics(), |
| 729 std::vector<variations::ActiveGroupId>()); | 747 std::vector<variations::ActiveGroupId>()); |
| 730 | 748 |
| 731 EXPECT_TRUE(log.system_profile().has_hardware()); | 749 EXPECT_TRUE(log.system_profile().has_hardware()); |
| 732 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | 750 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
| 733 | 751 |
| 734 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | 752 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
| 735 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); | 753 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); |
| 736 } | 754 } |
| 737 | 755 |
| 738 TEST_F(MetricsLogTest, BluetoothPairedDevices) { | 756 TEST_F(MetricsLogTest, BluetoothPairedDevices) { |
| 739 // The fake bluetooth adapter class already claims to be paired with one | 757 // 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 | 758 // 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) | 759 // can test the cases where a device is not paired (LE device, generally) |
| 742 // and a device that does not have Device ID information. | 760 // and a device that does not have Device ID information. |
| 743 fake_bluetooth_device_client_->CreateDevice( | 761 fake_bluetooth_device_client_->CreateDevice( |
| 744 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 762 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 745 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); | 763 dbus::ObjectPath(FakeBluetoothDeviceClient::kRequestPinCodePath)); |
| 746 | 764 |
| 747 fake_bluetooth_device_client_->CreateDevice( | 765 fake_bluetooth_device_client_->CreateDevice( |
| 748 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), | 766 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath), |
| 749 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 767 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 750 | 768 |
| 751 FakeBluetoothDeviceClient::Properties* properties = | 769 FakeBluetoothDeviceClient::Properties* properties = |
| 752 fake_bluetooth_device_client_->GetProperties( | 770 fake_bluetooth_device_client_->GetProperties( |
| 753 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 771 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
| 754 properties->paired.ReplaceValue(true); | 772 properties->paired.ReplaceValue(true); |
| 755 | 773 |
| 756 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); | 774 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG); |
| 757 log.RecordEnvironment(std::vector<content::WebPluginInfo>(), | 775 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
| 776 std::vector<content::WebPluginInfo>(), |
| 758 GoogleUpdateMetrics(), | 777 GoogleUpdateMetrics(), |
| 759 std::vector<variations::ActiveGroupId>()); | 778 std::vector<variations::ActiveGroupId>()); |
| 760 | 779 |
| 761 ASSERT_TRUE(log.system_profile().has_hardware()); | 780 ASSERT_TRUE(log.system_profile().has_hardware()); |
| 762 ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); | 781 ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); |
| 763 | 782 |
| 764 // Only two of the devices should appear. | 783 // Only two of the devices should appear. |
| 765 EXPECT_EQ(2, | 784 EXPECT_EQ(2, |
| 766 log.system_profile().hardware().bluetooth().paired_device_size()); | 785 log.system_profile().hardware().bluetooth().paired_device_size()); |
| 767 | 786 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 787 PairedDevice device2 = | 806 PairedDevice device2 = |
| 788 log.system_profile().hardware().bluetooth().paired_device(1); | 807 log.system_profile().hardware().bluetooth().paired_device(1); |
| 789 | 808 |
| 790 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | 809 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
| 791 device2.bluetooth_class()); | 810 device2.bluetooth_class()); |
| 792 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | 811 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
| 793 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | 812 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
| 794 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | 813 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
| 795 } | 814 } |
| 796 #endif // OS_CHROMEOS | 815 #endif // OS_CHROMEOS |
| OLD | NEW |