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

Side by Side Diff: chrome/browser/metrics/metrics_service_uitest.cc

Issue 7646008: Fix MetricsServiceTest.CloseRenderersNormally flakiness. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Tests the MetricsService stat recording to make sure that the numbers are 5 // Tests the MetricsService stat recording to make sure that the numbers are
6 // what we expect. 6 // what we expect.
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 21 matching lines...) Expand all
32 MetricsServiceTest() : UITest() { 32 MetricsServiceTest() : UITest() {
33 // We need to show the window so web content type tabs load. 33 // We need to show the window so web content type tabs load.
34 show_window_ = true; 34 show_window_ = true;
35 } 35 }
36 36
37 // Open a few tabs of random content 37 // Open a few tabs of random content
38 void OpenTabs() { 38 void OpenTabs() {
39 scoped_refptr<BrowserProxy> window = automation()->GetBrowserWindow(0); 39 scoped_refptr<BrowserProxy> window = automation()->GetBrowserWindow(0);
40 ASSERT_TRUE(window.get()); 40 ASSERT_TRUE(window.get());
41 41
42 // The Instant field trial causes a preload of the default search engine,
43 // which messes up the expected page load count. Setting this preference
44 // disables the field trial.
45 ASSERT_TRUE(window->SetBooleanPreference(prefs::kInstantEnabledOnce, true));
46
42 FilePath page1_path; 47 FilePath page1_path;
43 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page1_path)); 48 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page1_path));
44 page1_path = page1_path.AppendASCII("title2.html"); 49 page1_path = page1_path.AppendASCII("title2.html");
45 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page1_path))); 50 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page1_path)));
46 51
47 FilePath page2_path; 52 FilePath page2_path;
48 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page2_path)); 53 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &page2_path));
49 page2_path = page2_path.AppendASCII("iframe.html"); 54 page2_path = page2_path.AppendASCII("iframe.html");
50 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path))); 55 ASSERT_TRUE(window->AppendTab(net::FilePathToFileURL(page2_path)));
51 } 56 }
52 57
53 // Get a PrefService whose contents correspond to the Local State file 58 // Get a PrefService whose contents correspond to the Local State file
54 // that was saved by the app as it closed. The caller takes ownership of the 59 // that was saved by the app as it closed. The caller takes ownership of the
55 // returned PrefService object. 60 // returned PrefService object.
56 PrefService* GetLocalState() { 61 PrefService* GetLocalState() {
57 FilePath path = user_data_dir().Append(chrome::kLocalStateFilename); 62 FilePath path = user_data_dir().Append(chrome::kLocalStateFilename);
58 return PrefServiceMockBuilder().WithUserFilePrefs(path).Create(); 63 return PrefServiceMockBuilder().WithUserFilePrefs(path).Create();
59 } 64 }
60 #if defined(OS_WIN) || defined(OS_LINUX) 65 #if defined(OS_WIN) || defined(OS_LINUX)
61 // This is not really Windows-specific, the transition is just being done 66 // This is not really Windows-specific, the transition is just being done
62 // in stages, and Windows is first. See below for more info. 67 // in stages, and Windows is first. See below for more info.
63 // TODO(phajdan.jr): Remove #ifdef after fixing http://crbug.com/61062. 68 // TODO(phajdan.jr): Remove #ifdef after fixing http://crbug.com/61062.
64 private: 69 private:
65 NotificationService notification_service_; 70 NotificationService notification_service_;
66 #endif 71 #endif
67 }; 72 };
68 73
69 #if defined(OS_MACOSX) 74 TEST_F(MetricsServiceTest, CloseRenderersNormally) {
70 // Flaky across all Mac bots: http://crbug.com/92635
71 #define MAYBE_CloseRenderersNormally FLAKY_CloseRenderersNormally
72 #else
73 #define MAYBE_CloseRenderersNormally CloseRenderersNormally
74 #endif
75
76 TEST_F(MetricsServiceTest, MAYBE_CloseRenderersNormally) {
77 OpenTabs(); 75 OpenTabs();
78 QuitBrowser(); 76 QuitBrowser();
79 77
80 scoped_ptr<PrefService> local_state(GetLocalState()); 78 scoped_ptr<PrefService> local_state(GetLocalState());
81 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true); 79 local_state->RegisterBooleanPref(prefs::kStabilityExitedCleanly, true);
82 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0); 80 local_state->RegisterIntegerPref(prefs::kStabilityLaunchCount, 0);
83 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0); 81 local_state->RegisterIntegerPref(prefs::kStabilityPageLoadCount, 0);
84 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0); 82 local_state->RegisterIntegerPref(prefs::kStabilityRendererCrashCount, 0);
85 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); 83 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly));
86 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); 84 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly)); 131 EXPECT_TRUE(local_state->GetBoolean(prefs::kStabilityExitedCleanly));
134 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount)); 132 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityLaunchCount));
135 #if defined(TOUCH_UI) 133 #if defined(TOUCH_UI)
136 // The keyboard page loads for touchui. 134 // The keyboard page loads for touchui.
137 EXPECT_EQ(5, local_state->GetInteger(prefs::kStabilityPageLoadCount)); 135 EXPECT_EQ(5, local_state->GetInteger(prefs::kStabilityPageLoadCount));
138 #else 136 #else
139 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount)); 137 EXPECT_EQ(4, local_state->GetInteger(prefs::kStabilityPageLoadCount));
140 #endif 138 #endif
141 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount)); 139 EXPECT_EQ(1, local_state->GetInteger(prefs::kStabilityRendererCrashCount));
142 } 140 }
OLDNEW
« 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