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

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

Issue 10022008: Fix flakiness in MetricsServiceTest.CrashRenderers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Loop to avoid the race condition Created 8 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_service_browsertest.cc
diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc
index aee98aa62f370034e05b44b4377035a8665ccef4..af81a17b83275091af40c09acbdb01140a64786d 100644
--- a/chrome/browser/metrics/metrics_service_browsertest.cc
+++ b/chrome/browser/metrics/metrics_service_browsertest.cc
@@ -74,8 +74,7 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceTest, CloseRenderersNormally) {
// exits... it's not clear to me how to test that.
}
-// Flaky: http://crbug.com/18738
-IN_PROC_BROWSER_TEST_F(MetricsServiceTest, FLAKY_CrashRenderers) {
+IN_PROC_BROWSER_TEST_F(MetricsServiceTest, CrashRenderers) {
OpenTabs();
// Kill the process for one of the tabs.
@@ -85,8 +84,18 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceTest, FLAKY_CrashRenderers) {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUICrashURL));
observer.Wait();
- // Verify that the expected stability metrics were recorded.
+ // The MetricsService listens for the same notification, so the |observer|
+ // might finish waiting before the MetricsService has a chance to process the
+ // notification. To avoid racing here, we repeatedly run the message loop
+ // until the MetricsService catches up. This should happen "real soon now",
+ // since the notification is posted to all observers essentially
+ // simultaneously... so busy waiting here shouldn't be too bad.
const PrefService* prefs = g_browser_process->local_state();
+ while (!prefs->GetInteger(prefs::kStabilityRendererCrashCount)) {
+ ui_test_utils::RunAllPendingInMessageLoop();
+ }
+
+ // Verify that the expected stability metrics were recorded.
EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount));
#if defined(USE_VIRTUAL_KEYBOARD)
// The keyboard page loads.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698