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" | |
15 #include "base/prefs/testing_pref_service.h" | 14 #include "base/prefs/testing_pref_service.h" |
16 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | |
20 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
21 #include "base/time/time.h" | 19 #include "base/time/time.h" |
22 #include "base/tracked_objects.h" | 20 #include "base/tracked_objects.h" |
23 #include "chrome/browser/google/google_util.h" | 21 #include "chrome/browser/google/google_util.h" |
24 #include "chrome/browser/prefs/browser_prefs.h" | 22 #include "chrome/browser/prefs/browser_prefs.h" |
25 #include "chrome/common/chrome_version_info.h" | 23 #include "chrome/common/chrome_version_info.h" |
26 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
27 #include "chrome/installer/util/google_update_settings.h" | |
28 #include "components/metrics/metrics_hashes.h" | 25 #include "components/metrics/metrics_hashes.h" |
29 #include "components/metrics/metrics_provider.h" | 26 #include "components/metrics/metrics_provider.h" |
30 #include "components/metrics/proto/profiler_event.pb.h" | 27 #include "components/metrics/proto/profiler_event.pb.h" |
31 #include "components/metrics/proto/system_profile.pb.h" | 28 #include "components/metrics/proto/system_profile.pb.h" |
32 #include "components/metrics/test_metrics_service_client.h" | 29 #include "components/metrics/test_metrics_service_client.h" |
33 #include "components/variations/active_field_trials.h" | 30 #include "components/variations/active_field_trials.h" |
34 #include "components/variations/metrics_util.h" | |
35 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/common/process_type.h" | 32 #include "content/public/common/process_type.h" |
37 #include "content/public/common/webplugininfo.h" | |
38 #include "content/public/test/test_browser_thread_bundle.h" | 33 #include "content/public/test/test_browser_thread_bundle.h" |
39 #include "content/public/test/test_utils.h" | 34 #include "content/public/test/test_utils.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
41 #include "ui/gfx/size.h" | 36 #include "ui/gfx/size.h" |
42 #include "url/gurl.h" | 37 #include "url/gurl.h" |
43 | 38 |
44 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
45 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" | 40 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" |
46 #include "chrome/browser/chromeos/login/users/user_manager.h" | 41 #include "chrome/browser/chromeos/login/users/user_manager.h" |
47 #include "chrome/browser/metrics/metrics_log_chromeos.h" | 42 #include "chrome/browser/metrics/metrics_log_chromeos.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
102 #if defined(ENABLE_PLUGINS) | |
103 content::WebPluginInfo CreateFakePluginInfo( | |
104 const std::string& name, | |
105 const base::FilePath::CharType* path, | |
106 const std::string& version, | |
107 bool is_pepper) { | |
108 content::WebPluginInfo plugin(base::UTF8ToUTF16(name), | |
109 base::FilePath(path), | |
110 base::UTF8ToUTF16(version), | |
111 base::string16()); | |
112 if (is_pepper) | |
113 plugin.type = content::WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS; | |
114 else | |
115 plugin.type = content::WebPluginInfo::PLUGIN_TYPE_NPAPI; | |
116 return plugin; | |
117 } | |
118 #endif // defined(ENABLE_PLUGINS) | |
119 | |
120 #if defined(OS_CHROMEOS) | 97 #if defined(OS_CHROMEOS) |
121 class TestMetricsLogChromeOS : public MetricsLogChromeOS { | 98 class TestMetricsLogChromeOS : public MetricsLogChromeOS { |
122 public: | 99 public: |
123 explicit TestMetricsLogChromeOS( | 100 explicit TestMetricsLogChromeOS( |
124 metrics::ChromeUserMetricsExtension* uma_proto) | 101 metrics::ChromeUserMetricsExtension* uma_proto) |
125 : MetricsLogChromeOS(uma_proto) { | 102 : MetricsLogChromeOS(uma_proto) { |
126 } | 103 } |
127 }; | 104 }; |
128 #endif // OS_CHROMEOS | 105 #endif // OS_CHROMEOS |
129 | 106 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 private: | 287 private: |
311 content::TestBrowserThreadBundle thread_bundle_; | 288 content::TestBrowserThreadBundle thread_bundle_; |
312 | 289 |
313 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest); | 290 DISALLOW_COPY_AND_ASSIGN(MetricsLogTest); |
314 }; | 291 }; |
315 | 292 |
316 TEST_F(MetricsLogTest, RecordEnvironment) { | 293 TEST_F(MetricsLogTest, RecordEnvironment) { |
317 metrics::TestMetricsServiceClient client; | 294 metrics::TestMetricsServiceClient client; |
318 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 295 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
319 | 296 |
320 std::vector<content::WebPluginInfo> plugins; | |
321 std::vector<variations::ActiveGroupId> synthetic_trials; | 297 std::vector<variations::ActiveGroupId> synthetic_trials; |
322 // Add two synthetic trials. | 298 // Add two synthetic trials. |
323 synthetic_trials.push_back(kSyntheticTrials[0]); | 299 synthetic_trials.push_back(kSyntheticTrials[0]); |
324 synthetic_trials.push_back(kSyntheticTrials[1]); | 300 synthetic_trials.push_back(kSyntheticTrials[1]); |
325 | 301 |
326 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 302 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
327 plugins, synthetic_trials); | 303 synthetic_trials); |
328 // Check that the system profile on the log has the correct values set. | 304 // Check that the system profile on the log has the correct values set. |
329 CheckSystemProfile(log.system_profile()); | 305 CheckSystemProfile(log.system_profile()); |
330 | 306 |
331 // Check that the system profile has also been written to prefs. | 307 // Check that the system profile has also been written to prefs. |
332 PrefService* local_state = log.GetPrefService(); | 308 PrefService* local_state = log.GetPrefService(); |
333 const std::string base64_system_profile = | 309 const std::string base64_system_profile = |
334 local_state->GetString(prefs::kStabilitySavedSystemProfile); | 310 local_state->GetString(prefs::kStabilitySavedSystemProfile); |
335 EXPECT_FALSE(base64_system_profile.empty()); | 311 EXPECT_FALSE(base64_system_profile.empty()); |
336 std::string serialied_system_profile; | 312 std::string serialied_system_profile; |
337 EXPECT_TRUE(base::Base64Decode(base64_system_profile, | 313 EXPECT_TRUE(base::Base64Decode(base64_system_profile, |
(...skipping 16 matching lines...) Expand all Loading... |
354 TestMetricsLog log( | 330 TestMetricsLog log( |
355 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); | 331 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); |
356 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); | 332 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); |
357 } | 333 } |
358 | 334 |
359 // Do a RecordEnvironment() call and check whether the pref is recorded. | 335 // Do a RecordEnvironment() call and check whether the pref is recorded. |
360 { | 336 { |
361 TestMetricsLog log( | 337 TestMetricsLog log( |
362 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); | 338 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); |
363 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 339 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
364 std::vector<content::WebPluginInfo>(), | |
365 std::vector<variations::ActiveGroupId>()); | 340 std::vector<variations::ActiveGroupId>()); |
366 EXPECT_FALSE(prefs.GetString(kSystemProfilePref).empty()); | 341 EXPECT_FALSE(prefs.GetString(kSystemProfilePref).empty()); |
367 EXPECT_FALSE(prefs.GetString(kSystemProfileHashPref).empty()); | 342 EXPECT_FALSE(prefs.GetString(kSystemProfileHashPref).empty()); |
368 } | 343 } |
369 | 344 |
370 { | 345 { |
371 TestMetricsLog log( | 346 TestMetricsLog log( |
372 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); | 347 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); |
373 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs()); | 348 EXPECT_TRUE(log.LoadSavedEnvironmentFromPrefs()); |
374 // Check some values in the system profile. | 349 // Check some values in the system profile. |
375 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date()); | 350 EXPECT_EQ(kInstallDateExpected, log.system_profile().install_date()); |
376 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date()); | 351 EXPECT_EQ(kEnabledDateExpected, log.system_profile().uma_enabled_date()); |
377 // Ensure that the call cleared the prefs. | 352 // Ensure that the call cleared the prefs. |
378 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); | 353 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); |
379 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); | 354 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); |
380 } | 355 } |
381 | 356 |
382 // Ensure that a non-matching hash results in the pref being invalid. | 357 // Ensure that a non-matching hash results in the pref being invalid. |
383 { | 358 { |
384 TestMetricsLog log( | 359 TestMetricsLog log( |
385 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); | 360 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); |
386 // Call RecordEnvironment() to record the pref again. | 361 // Call RecordEnvironment() to record the pref again. |
387 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 362 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
388 std::vector<content::WebPluginInfo>(), | |
389 std::vector<variations::ActiveGroupId>()); | 363 std::vector<variations::ActiveGroupId>()); |
390 } | 364 } |
391 | 365 |
392 { | 366 { |
393 // Set the hash to a bad value. | 367 // Set the hash to a bad value. |
394 prefs.SetString(kSystemProfileHashPref, "deadbeef"); | 368 prefs.SetString(kSystemProfileHashPref, "deadbeef"); |
395 TestMetricsLog log( | 369 TestMetricsLog log( |
396 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); | 370 kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client, &prefs); |
397 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); | 371 EXPECT_FALSE(log.LoadSavedEnvironmentFromPrefs()); |
398 // Ensure that the prefs are cleared, even if the call failed. | 372 // Ensure that the prefs are cleared, even if the call failed. |
399 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); | 373 EXPECT_TRUE(prefs.GetString(kSystemProfilePref).empty()); |
400 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); | 374 EXPECT_TRUE(prefs.GetString(kSystemProfileHashPref).empty()); |
401 } | 375 } |
402 } | 376 } |
403 | 377 |
404 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) { | 378 TEST_F(MetricsLogTest, InitialLogStabilityMetrics) { |
405 metrics::TestMetricsServiceClient client; | 379 metrics::TestMetricsServiceClient client; |
406 TestMetricsLog log( | 380 TestMetricsLog log( |
407 kClientId, kSessionId, MetricsLog::INITIAL_STABILITY_LOG, &client); | 381 kClientId, kSessionId, MetricsLog::INITIAL_STABILITY_LOG, &client); |
408 std::vector<metrics::MetricsProvider*> metrics_providers; | 382 std::vector<metrics::MetricsProvider*> metrics_providers; |
409 log.RecordEnvironment(metrics_providers, | 383 log.RecordEnvironment(metrics_providers, |
410 std::vector<content::WebPluginInfo>(), | |
411 std::vector<variations::ActiveGroupId>()); | 384 std::vector<variations::ActiveGroupId>()); |
412 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), | 385 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), |
413 base::TimeDelta()); | 386 base::TimeDelta()); |
414 const metrics::SystemProfileProto_Stability& stability = | 387 const metrics::SystemProfileProto_Stability& stability = |
415 log.system_profile().stability(); | 388 log.system_profile().stability(); |
416 // Required metrics: | 389 // Required metrics: |
417 EXPECT_TRUE(stability.has_launch_count()); | 390 EXPECT_TRUE(stability.has_launch_count()); |
418 EXPECT_TRUE(stability.has_crash_count()); | 391 EXPECT_TRUE(stability.has_crash_count()); |
419 // Initial log metrics: | 392 // Initial log metrics: |
420 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); | 393 EXPECT_TRUE(stability.has_incomplete_shutdown_count()); |
421 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); | 394 EXPECT_TRUE(stability.has_breakpad_registration_success_count()); |
422 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); | 395 EXPECT_TRUE(stability.has_breakpad_registration_failure_count()); |
423 EXPECT_TRUE(stability.has_debugger_present_count()); | 396 EXPECT_TRUE(stability.has_debugger_present_count()); |
424 EXPECT_TRUE(stability.has_debugger_not_present_count()); | 397 EXPECT_TRUE(stability.has_debugger_not_present_count()); |
425 } | 398 } |
426 | 399 |
427 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { | 400 TEST_F(MetricsLogTest, OngoingLogStabilityMetrics) { |
428 metrics::TestMetricsServiceClient client; | 401 metrics::TestMetricsServiceClient client; |
429 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 402 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
430 std::vector<metrics::MetricsProvider*> metrics_providers; | 403 std::vector<metrics::MetricsProvider*> metrics_providers; |
431 log.RecordEnvironment(metrics_providers, | 404 log.RecordEnvironment(metrics_providers, |
432 std::vector<content::WebPluginInfo>(), | |
433 std::vector<variations::ActiveGroupId>()); | 405 std::vector<variations::ActiveGroupId>()); |
434 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), | 406 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), |
435 base::TimeDelta()); | 407 base::TimeDelta()); |
436 const metrics::SystemProfileProto_Stability& stability = | 408 const metrics::SystemProfileProto_Stability& stability = |
437 log.system_profile().stability(); | 409 log.system_profile().stability(); |
438 // Required metrics: | 410 // Required metrics: |
439 EXPECT_TRUE(stability.has_launch_count()); | 411 EXPECT_TRUE(stability.has_launch_count()); |
440 EXPECT_TRUE(stability.has_crash_count()); | 412 EXPECT_TRUE(stability.has_crash_count()); |
441 // Initial log metrics: | 413 // Initial log metrics: |
442 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); | 414 EXPECT_FALSE(stability.has_incomplete_shutdown_count()); |
443 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); | 415 EXPECT_FALSE(stability.has_breakpad_registration_success_count()); |
444 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); | 416 EXPECT_FALSE(stability.has_breakpad_registration_failure_count()); |
445 EXPECT_FALSE(stability.has_debugger_present_count()); | 417 EXPECT_FALSE(stability.has_debugger_present_count()); |
446 EXPECT_FALSE(stability.has_debugger_not_present_count()); | 418 EXPECT_FALSE(stability.has_debugger_not_present_count()); |
447 } | 419 } |
448 | 420 |
449 #if defined(ENABLE_PLUGINS) | |
450 TEST_F(MetricsLogTest, Plugins) { | |
451 metrics::TestMetricsServiceClient client; | |
452 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | |
453 | |
454 std::vector<metrics::MetricsProvider*> metrics_providers; | |
455 std::vector<content::WebPluginInfo> plugins; | |
456 plugins.push_back(CreateFakePluginInfo("p1", FILE_PATH_LITERAL("p1.plugin"), | |
457 "1.5", true)); | |
458 plugins.push_back(CreateFakePluginInfo("p2", FILE_PATH_LITERAL("p2.plugin"), | |
459 "2.0", false)); | |
460 log.RecordEnvironment(metrics_providers, plugins, | |
461 std::vector<variations::ActiveGroupId>()); | |
462 | |
463 const metrics::SystemProfileProto& system_profile = log.system_profile(); | |
464 ASSERT_EQ(2, system_profile.plugin_size()); | |
465 EXPECT_EQ("p1", system_profile.plugin(0).name()); | |
466 EXPECT_EQ("p1.plugin", system_profile.plugin(0).filename()); | |
467 EXPECT_EQ("1.5", system_profile.plugin(0).version()); | |
468 EXPECT_TRUE(system_profile.plugin(0).is_pepper()); | |
469 EXPECT_EQ("p2", system_profile.plugin(1).name()); | |
470 EXPECT_EQ("p2.plugin", system_profile.plugin(1).filename()); | |
471 EXPECT_EQ("2.0", system_profile.plugin(1).version()); | |
472 EXPECT_FALSE(system_profile.plugin(1).is_pepper()); | |
473 | |
474 // Now set some plugin stability stats for p2 and verify they're recorded. | |
475 scoped_ptr<base::DictionaryValue> plugin_dict(new base::DictionaryValue); | |
476 plugin_dict->SetString(prefs::kStabilityPluginName, "p2"); | |
477 plugin_dict->SetInteger(prefs::kStabilityPluginLaunches, 1); | |
478 plugin_dict->SetInteger(prefs::kStabilityPluginCrashes, 2); | |
479 plugin_dict->SetInteger(prefs::kStabilityPluginInstances, 3); | |
480 plugin_dict->SetInteger(prefs::kStabilityPluginLoadingErrors, 4); | |
481 { | |
482 ListPrefUpdate update(log.GetPrefService(), prefs::kStabilityPluginStats); | |
483 update.Get()->Append(plugin_dict.release()); | |
484 } | |
485 | |
486 log.RecordStabilityMetrics(metrics_providers, base::TimeDelta(), | |
487 base::TimeDelta()); | |
488 const metrics::SystemProfileProto_Stability& stability = | |
489 log.system_profile().stability(); | |
490 ASSERT_EQ(1, stability.plugin_stability_size()); | |
491 EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name()); | |
492 EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename()); | |
493 EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version()); | |
494 EXPECT_FALSE(stability.plugin_stability(0).plugin().is_pepper()); | |
495 EXPECT_EQ(1, stability.plugin_stability(0).launch_count()); | |
496 EXPECT_EQ(2, stability.plugin_stability(0).crash_count()); | |
497 EXPECT_EQ(3, stability.plugin_stability(0).instance_count()); | |
498 EXPECT_EQ(4, stability.plugin_stability(0).loading_error_count()); | |
499 } | |
500 #endif // defined(ENABLE_PLUGINS) | |
501 | |
502 // Test that we properly write profiler data to the log. | 421 // Test that we properly write profiler data to the log. |
503 TEST_F(MetricsLogTest, RecordProfilerData) { | 422 TEST_F(MetricsLogTest, RecordProfilerData) { |
504 // WARNING: If you broke the below check, you've modified how | 423 // WARNING: If you broke the below check, you've modified how |
505 // metrics::HashMetricName works. Please also modify all server-side code that | 424 // metrics::HashMetricName works. Please also modify all server-side code that |
506 // relies on the existing way of hashing. | 425 // relies on the existing way of hashing. |
507 EXPECT_EQ(GG_UINT64_C(1518842999910132863), | 426 EXPECT_EQ(GG_UINT64_C(1518842999910132863), |
508 metrics::HashMetricName("birth_thread*")); | 427 metrics::HashMetricName("birth_thread*")); |
509 | 428 |
510 metrics::TestMetricsServiceClient client; | 429 metrics::TestMetricsServiceClient client; |
511 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 430 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 user_manager->AddKioskAppUser(user1); | 606 user_manager->AddKioskAppUser(user1); |
688 user_manager->AddKioskAppUser(user2); | 607 user_manager->AddKioskAppUser(user2); |
689 user_manager->AddKioskAppUser(user3); | 608 user_manager->AddKioskAppUser(user3); |
690 | 609 |
691 user_manager->LoginUser(user1); | 610 user_manager->LoginUser(user1); |
692 user_manager->LoginUser(user3); | 611 user_manager->LoginUser(user3); |
693 | 612 |
694 metrics::TestMetricsServiceClient client; | 613 metrics::TestMetricsServiceClient client; |
695 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 614 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
696 std::vector<metrics::MetricsProvider*> metrics_providers; | 615 std::vector<metrics::MetricsProvider*> metrics_providers; |
697 std::vector<content::WebPluginInfo> plugins; | |
698 std::vector<variations::ActiveGroupId> synthetic_trials; | 616 std::vector<variations::ActiveGroupId> synthetic_trials; |
699 log.RecordEnvironment(metrics_providers, plugins, synthetic_trials); | 617 log.RecordEnvironment(metrics_providers, synthetic_trials); |
700 EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); | 618 EXPECT_EQ(2u, log.system_profile().multi_profile_user_count()); |
701 } | 619 } |
702 | 620 |
703 TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { | 621 TEST_F(MetricsLogTest, MultiProfileCountInvalidated) { |
704 std::string user1("user1@example.com"); | 622 std::string user1("user1@example.com"); |
705 std::string user2("user2@example.com"); | 623 std::string user2("user2@example.com"); |
706 std::string user3("user3@example.com"); | 624 std::string user3("user3@example.com"); |
707 | 625 |
708 // |scoped_enabler| takes over the lifetime of |user_manager|. | 626 // |scoped_enabler| takes over the lifetime of |user_manager|. |
709 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); | 627 chromeos::FakeUserManager* user_manager = new chromeos::FakeUserManager(); |
710 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); | 628 chromeos::ScopedUserManagerEnabler scoped_enabler(user_manager); |
711 user_manager->AddKioskAppUser(user1); | 629 user_manager->AddKioskAppUser(user1); |
712 user_manager->AddKioskAppUser(user2); | 630 user_manager->AddKioskAppUser(user2); |
713 user_manager->AddKioskAppUser(user3); | 631 user_manager->AddKioskAppUser(user3); |
714 | 632 |
715 user_manager->LoginUser(user1); | 633 user_manager->LoginUser(user1); |
716 | 634 |
717 metrics::TestMetricsServiceClient client; | 635 metrics::TestMetricsServiceClient client; |
718 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 636 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
719 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); | 637 EXPECT_EQ(1u, log.system_profile().multi_profile_user_count()); |
720 | 638 |
721 user_manager->LoginUser(user2); | 639 user_manager->LoginUser(user2); |
722 std::vector<metrics::MetricsProvider*> metrics_providers; | 640 std::vector<metrics::MetricsProvider*> metrics_providers; |
723 std::vector<variations::ActiveGroupId> synthetic_trials; | 641 std::vector<variations::ActiveGroupId> synthetic_trials; |
724 log.RecordEnvironment(metrics_providers, | 642 log.RecordEnvironment(metrics_providers, synthetic_trials); |
725 std::vector<content::WebPluginInfo>(), | |
726 synthetic_trials); | |
727 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); | 643 EXPECT_EQ(0u, log.system_profile().multi_profile_user_count()); |
728 } | 644 } |
729 | 645 |
730 TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { | 646 TEST_F(MetricsLogTest, BluetoothHardwareDisabled) { |
731 metrics::TestMetricsServiceClient client; | 647 metrics::TestMetricsServiceClient client; |
732 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 648 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
733 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 649 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
734 std::vector<content::WebPluginInfo>(), | |
735 std::vector<variations::ActiveGroupId>()); | 650 std::vector<variations::ActiveGroupId>()); |
736 | 651 |
737 EXPECT_TRUE(log.system_profile().has_hardware()); | 652 EXPECT_TRUE(log.system_profile().has_hardware()); |
738 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | 653 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
739 | 654 |
740 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | 655 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
741 EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); | 656 EXPECT_FALSE(log.system_profile().hardware().bluetooth().is_enabled()); |
742 } | 657 } |
743 | 658 |
744 TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { | 659 TEST_F(MetricsLogTest, BluetoothHardwareEnabled) { |
745 FakeBluetoothAdapterClient::Properties* properties = | 660 FakeBluetoothAdapterClient::Properties* properties = |
746 fake_bluetooth_adapter_client_->GetProperties( | 661 fake_bluetooth_adapter_client_->GetProperties( |
747 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); | 662 dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)); |
748 properties->powered.ReplaceValue(true); | 663 properties->powered.ReplaceValue(true); |
749 | 664 |
750 metrics::TestMetricsServiceClient client; | 665 metrics::TestMetricsServiceClient client; |
751 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 666 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
752 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 667 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
753 std::vector<content::WebPluginInfo>(), | |
754 std::vector<variations::ActiveGroupId>()); | 668 std::vector<variations::ActiveGroupId>()); |
755 | 669 |
756 EXPECT_TRUE(log.system_profile().has_hardware()); | 670 EXPECT_TRUE(log.system_profile().has_hardware()); |
757 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); | 671 EXPECT_TRUE(log.system_profile().hardware().has_bluetooth()); |
758 | 672 |
759 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); | 673 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_present()); |
760 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); | 674 EXPECT_TRUE(log.system_profile().hardware().bluetooth().is_enabled()); |
761 } | 675 } |
762 | 676 |
763 TEST_F(MetricsLogTest, BluetoothPairedDevices) { | 677 TEST_F(MetricsLogTest, BluetoothPairedDevices) { |
(...skipping 10 matching lines...) Expand all Loading... |
774 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 688 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
775 | 689 |
776 FakeBluetoothDeviceClient::Properties* properties = | 690 FakeBluetoothDeviceClient::Properties* properties = |
777 fake_bluetooth_device_client_->GetProperties( | 691 fake_bluetooth_device_client_->GetProperties( |
778 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); | 692 dbus::ObjectPath(FakeBluetoothDeviceClient::kConfirmPasskeyPath)); |
779 properties->paired.ReplaceValue(true); | 693 properties->paired.ReplaceValue(true); |
780 | 694 |
781 metrics::TestMetricsServiceClient client; | 695 metrics::TestMetricsServiceClient client; |
782 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); | 696 TestMetricsLog log(kClientId, kSessionId, MetricsLog::ONGOING_LOG, &client); |
783 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), | 697 log.RecordEnvironment(std::vector<metrics::MetricsProvider*>(), |
784 std::vector<content::WebPluginInfo>(), | |
785 std::vector<variations::ActiveGroupId>()); | 698 std::vector<variations::ActiveGroupId>()); |
786 | 699 |
787 ASSERT_TRUE(log.system_profile().has_hardware()); | 700 ASSERT_TRUE(log.system_profile().has_hardware()); |
788 ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); | 701 ASSERT_TRUE(log.system_profile().hardware().has_bluetooth()); |
789 | 702 |
790 // Only two of the devices should appear. | 703 // Only two of the devices should appear. |
791 EXPECT_EQ(2, | 704 EXPECT_EQ(2, |
792 log.system_profile().hardware().bluetooth().paired_device_size()); | 705 log.system_profile().hardware().bluetooth().paired_device_size()); |
793 | 706 |
794 typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice | 707 typedef metrics::SystemProfileProto::Hardware::Bluetooth::PairedDevice |
(...skipping 18 matching lines...) Expand all Loading... |
813 PairedDevice device2 = | 726 PairedDevice device2 = |
814 log.system_profile().hardware().bluetooth().paired_device(1); | 727 log.system_profile().hardware().bluetooth().paired_device(1); |
815 | 728 |
816 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, | 729 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, |
817 device2.bluetooth_class()); | 730 device2.bluetooth_class()); |
818 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); | 731 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); |
819 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); | 732 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); |
820 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); | 733 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); |
821 } | 734 } |
822 #endif // OS_CHROMEOS | 735 #endif // OS_CHROMEOS |
OLD | NEW |