Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/plugin_metrics_provider.h" | 5 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "base/prefs/testing_pref_service.h" | 12 #include "base/prefs/testing_pref_service.h" |
| 13 #include "base/run_loop.h" | |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "components/metrics/proto/system_profile.pb.h" | 16 #include "components/metrics/proto/system_profile.pb.h" |
| 16 #include "content/public/common/process_type.h" | 17 #include "content/public/common/process_type.h" |
| 17 #include "content/public/common/webplugininfo.h" | 18 #include "content/public/common/webplugininfo.h" |
| 18 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 ASSERT_EQ(1, stability.plugin_stability_size()); | 94 ASSERT_EQ(1, stability.plugin_stability_size()); |
| 94 EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name()); | 95 EXPECT_EQ("p2", stability.plugin_stability(0).plugin().name()); |
| 95 EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename()); | 96 EXPECT_EQ("p2.plugin", stability.plugin_stability(0).plugin().filename()); |
| 96 EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version()); | 97 EXPECT_EQ("2.0", stability.plugin_stability(0).plugin().version()); |
| 97 EXPECT_FALSE(stability.plugin_stability(0).plugin().is_pepper()); | 98 EXPECT_FALSE(stability.plugin_stability(0).plugin().is_pepper()); |
| 98 EXPECT_EQ(1, stability.plugin_stability(0).launch_count()); | 99 EXPECT_EQ(1, stability.plugin_stability(0).launch_count()); |
| 99 EXPECT_EQ(2, stability.plugin_stability(0).crash_count()); | 100 EXPECT_EQ(2, stability.plugin_stability(0).crash_count()); |
| 100 EXPECT_EQ(3, stability.plugin_stability(0).instance_count()); | 101 EXPECT_EQ(3, stability.plugin_stability(0).instance_count()); |
| 101 EXPECT_EQ(4, stability.plugin_stability(0).loading_error_count()); | 102 EXPECT_EQ(4, stability.plugin_stability(0).loading_error_count()); |
| 102 } | 103 } |
| 104 | |
| 105 TEST(PluginMetricsProviderTest, CheckDelayedTask) { | |
| 106 content::TestBrowserThreadBundle thread_bundle; | |
| 107 | |
| 108 TestingPrefServiceSimple prefs; | |
| 109 PluginMetricsProvider::RegisterPrefs(prefs.registry()); | |
| 110 PluginMetricsProvider provider(&prefs); | |
| 111 | |
| 112 int delay_sec = 1; | |
| 113 EXPECT_EQ(true, provider.DelayedRecordCurrentState(delay_sec)); | |
|
Alexei Svitkine (slow)
2014/08/05 20:13:12
Nit: use EXPECT_TRUE and EXPECT_FALSE
gayane -on leave until 09-2017
2014/08/05 21:24:56
Done.
| |
| 114 EXPECT_EQ(false, provider.DelayedRecordCurrentState(delay_sec)); | |
| 115 | |
| 116 sleep(delay_sec); | |
|
Alexei Svitkine (slow)
2014/08/05 20:13:12
Use base::PlatformThread::Sleep() instead.
gayane -on leave until 09-2017
2014/08/05 21:24:55
Done.
| |
| 117 base::RunLoop().RunUntilIdle(); | |
| 118 | |
| 119 EXPECT_EQ(true, provider.DelayedRecordCurrentState(delay_sec)); | |
| 120 } | |
| OLD | NEW |