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

Side by Side Diff: chrome/test/startup/startup_test.cc

Issue 40160: Fix startup_test failures on Windows buildbot. (Closed)
Patch Set: Created 11 years, 9 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
« 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/test_file_util.h" 10 #include "base/test_file_util.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "chrome/common/chrome_constants.h" 12 #include "chrome/common/chrome_constants.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/test/ui/ui_test.h" 14 #include "chrome/test/ui/ui_test.h"
15 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
16 16
17 using base::TimeDelta; 17 using base::TimeDelta;
18 using base::TimeTicks; 18 using base::TimeTicks;
19 19
20 namespace { 20 namespace {
21 21
22 // Wrapper around EvictFileFromSystemCache to retry 10 times in case of error.
23 // Apparently needed for Windows buildbots (to workaround an error when
24 // file is in use).
25 // TODO(phajdan.jr): Move to test_file_util if we need it in more places.
26 bool EvictFileFromSystemCacheWrapper(const FilePath& path) {
27 for (int i = 0; i < 10; i++) {
28 if (file_util::EvictFileFromSystemCache(path))
29 return true;
30 PlatformThread::Sleep(1000);
31 }
32 return false;
33 }
34
22 class StartupTest : public UITest { 35 class StartupTest : public UITest {
23 public: 36 public:
24 StartupTest() { 37 StartupTest() {
25 show_window_ = true; 38 show_window_ = true;
26 pages_ = "about:blank"; 39 pages_ = "about:blank";
27 } 40 }
28 void SetUp() {} 41 void SetUp() {}
29 void TearDown() {} 42 void TearDown() {}
30 43
31 void RunStartupTest(const wchar_t* graph, const wchar_t* trace, 44 void RunStartupTest(const wchar_t* graph, const wchar_t* trace,
32 bool test_cold, bool important) { 45 bool test_cold, bool important) {
33 const int kNumCycles = 20; 46 const int kNumCycles = 20;
34 47
35 TimeDelta timings[kNumCycles]; 48 TimeDelta timings[kNumCycles];
36 for (int i = 0; i < kNumCycles; ++i) { 49 for (int i = 0; i < kNumCycles; ++i) {
37 if (test_cold) { 50 if (test_cold) {
38 FilePath dir_app; 51 FilePath dir_app;
39 ASSERT_TRUE(PathService::Get(chrome::DIR_APP, &dir_app)); 52 ASSERT_TRUE(PathService::Get(chrome::DIR_APP, &dir_app));
40 53
41 FilePath chrome_exe(dir_app.Append( 54 FilePath chrome_exe(dir_app.Append(
42 FilePath::FromWStringHack(chrome::kBrowserProcessExecutableName))); 55 FilePath::FromWStringHack(chrome::kBrowserProcessExecutableName)));
43 ASSERT_TRUE(file_util::EvictFileFromSystemCache(chrome_exe)); 56 ASSERT_TRUE(EvictFileFromSystemCacheWrapper(chrome_exe));
44 #if defined(OS_WIN) 57 #if defined(OS_WIN)
45 // TODO(port): these files do not exist on other platforms. 58 // TODO(port): these files do not exist on other platforms.
46 // Decide what to do. 59 // Decide what to do.
47 60
48 FilePath chrome_dll(dir_app.Append(FILE_PATH_LITERAL("chrome.dll"))); 61 FilePath chrome_dll(dir_app.Append(FILE_PATH_LITERAL("chrome.dll")));
49 ASSERT_TRUE(file_util::EvictFileFromSystemCache(chrome_dll)); 62 ASSERT_TRUE(EvictFileFromSystemCacheWrapper(chrome_dll));
50 63
51 FilePath gears_dll; 64 FilePath gears_dll;
52 ASSERT_TRUE(PathService::Get(chrome::FILE_GEARS_PLUGIN, &gears_dll)); 65 ASSERT_TRUE(PathService::Get(chrome::FILE_GEARS_PLUGIN, &gears_dll));
53 ASSERT_TRUE(file_util::EvictFileFromSystemCache(gears_dll)); 66 ASSERT_TRUE(EvictFileFromSystemCacheWrapper(gears_dll));
54 #endif // defined(OS_WIN) 67 #endif // defined(OS_WIN)
55 } 68 }
56 69
57 UITest::SetUp(); 70 UITest::SetUp();
58 TimeTicks end_time = TimeTicks::Now(); 71 TimeTicks end_time = TimeTicks::Now();
59 timings[i] = end_time - browser_launch_time_; 72 timings[i] = end_time - browser_launch_time_;
60 // TODO(beng): Can't shut down so quickly. Figure out why, and fix. If we 73 // TODO(beng): Can't shut down so quickly. Figure out why, and fix. If we
61 // do, we crash. 74 // do, we crash.
62 PlatformThread::Sleep(50); 75 PlatformThread::Sleep(50);
63 UITest::TearDown(); 76 UITest::TearDown();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 false /* not important */); 145 false /* not important */);
133 } 146 }
134 147
135 TEST_F(StartupFileTest, PerfColdGears) { 148 TEST_F(StartupFileTest, PerfColdGears) {
136 RunStartupTest(L"cold", L"gears", true /* cold */, 149 RunStartupTest(L"cold", L"gears", true /* cold */,
137 false /* not important */); 150 false /* not important */);
138 } 151 }
139 152
140 #endif // defined(OS_WIN) 153 #endif // defined(OS_WIN)
141 154
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