Index: chrome/browser/metrics/plugin_metrics_provider_unittest.cc |
diff --git a/chrome/browser/metrics/plugin_metrics_provider_unittest.cc b/chrome/browser/metrics/plugin_metrics_provider_unittest.cc |
index dc961918faef9174469fa3a9df5fbfc382d1a409..e697eea313178f7128ca5cf58052d55e9957adb8 100644 |
--- a/chrome/browser/metrics/plugin_metrics_provider_unittest.cc |
+++ b/chrome/browser/metrics/plugin_metrics_provider_unittest.cc |
@@ -10,6 +10,7 @@ |
#include "base/prefs/pref_service.h" |
#include "base/prefs/scoped_user_pref_update.h" |
#include "base/prefs/testing_pref_service.h" |
+#include "base/run_loop.h" |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/common/pref_names.h" |
#include "components/metrics/proto/system_profile.pb.h" |
@@ -100,3 +101,41 @@ TEST(PluginMetricsProviderTest, Plugins) { |
EXPECT_EQ(3, stability.plugin_stability(0).instance_count()); |
EXPECT_EQ(4, stability.plugin_stability(0).loading_error_count()); |
} |
+ |
+TEST(PluginMetricsProviderTest, CheckDelayedRecordCurrentState) { |
+ content::TestBrowserThreadBundle thread_bundle; |
+ |
+ TestingPrefServiceSimple prefs; |
+ PluginMetricsProvider::RegisterPrefs(prefs.registry()); |
+ PluginMetricsProvider provider(&prefs); |
+ |
+ int delay_ms = 10; |
+ EXPECT_TRUE(provider.RecordCurrentStateWithDelay(delay_ms)); |
+ EXPECT_FALSE(provider.RecordCurrentStateWithDelay(delay_ms)); |
+ |
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(delay_ms)); |
+ base::RunLoop().RunUntilIdle(); |
+ |
+ EXPECT_TRUE(provider.RecordCurrentStateWithDelay(delay_ms)); |
+} |
+ |
+TEST(PluginMetricsProviderTest, CheckForcedRecordCurrentState) { |
Alexei Svitkine (slow)
2014/08/06 15:10:01
Can you also add a test that verifies that Provide
gayane -on leave until 09-2017
2014/08/06 19:38:27
Done.
|
+ content::TestBrowserThreadBundle thread_bundle; |
+ |
+ TestingPrefServiceSimple prefs; |
+ PluginMetricsProvider::RegisterPrefs(prefs.registry()); |
+ PluginMetricsProvider provider(&prefs); |
+ |
+ // First there should be now need to force RecordCurrentState. |
+ EXPECT_FALSE(provider.RecordCurrentStateIfPending()); |
+ |
+ // After delayed task is posted RecordCurrentStateIfPending should return |
+ // true. |
+ int delay_ms = 100000; |
+ EXPECT_TRUE(provider.RecordCurrentStateWithDelay(delay_ms)); |
+ EXPECT_TRUE(provider.RecordCurrentStateIfPending()); |
+ |
+ // If RecordCurrentStateIfPending was successful then we should be able to |
+ // post a new delayed task. |
+ EXPECT_TRUE(provider.RecordCurrentStateWithDelay(delay_ms)); |
+} |