Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: chrome/browser/metrics/plugin_metrics_provider_unittest.cc

Issue 441013002: Eliminate MetricsProvider::RecordCurrentState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes and name improvements Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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));
+}

Powered by Google App Engine
This is Rietveld 408576698