diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 09:38:38 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 09:38:38 +0000 |
commit | 71cbd00ce4c63af41f3d9a3c2acffc301600813b (patch) | |
tree | b9b790d01e4af1a61c22342126996d13911e901c /chrome/test/startup/startup_test.cc | |
parent | bd7105a8391c87c2c3e443392f58aa2b1a61dcbf (diff) | |
download | chromium_src-71cbd00ce4c63af41f3d9a3c2acffc301600813b.zip chromium_src-71cbd00ce4c63af41f3d9a3c2acffc301600813b.tar.gz chromium_src-71cbd00ce4c63af41f3d9a3c2acffc301600813b.tar.bz2 |
Make startup_tests build and run on Linux (except reference tests).
Review URL: http://codereview.chromium.org/27240
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10978 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/startup/startup_test.cc')
-rw-r--r-- | chrome/test/startup/startup_test.cc | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc index c8cf02ae..a07769d 100644 --- a/chrome/test/startup/startup_test.cc +++ b/chrome/test/startup/startup_test.cc @@ -2,11 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/platform_thread.h" #include "base/string_util.h" +#include "base/test_file_util.h" #include "base/time.h" +#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/ui/ui_test.h" #include "net/base/net_util.h" @@ -16,18 +19,6 @@ using base::TimeTicks; namespace { -// Wrapper around CopyFile to retry 10 times if there is an error. -// For some reasons on buildbot it happens quite often that -// the test fails because the dll is still in use. -bool CopyFileWrapper(const std::wstring &src, const std::wstring &dest) { - for (int i = 0; i < 10; ++i) { - if (file_util::CopyFile(src, dest)) - return true; - Sleep(1000); - } - return false; -} - class StartupTest : public UITest { public: StartupTest() { @@ -41,24 +32,26 @@ class StartupTest : public UITest { bool test_cold, bool important) { const int kNumCycles = 20; - // Make a backup of gears.dll so we can overwrite the original, which - // flushes the disk cache for that file. - std::wstring chrome_dll, chrome_dll_copy; - ASSERT_TRUE(PathService::Get(chrome::DIR_APP, &chrome_dll)); - file_util::AppendToPath(&chrome_dll, L"chrome.dll"); - chrome_dll_copy = chrome_dll + L".copy"; - ASSERT_TRUE(CopyFileWrapper(chrome_dll, chrome_dll_copy)); - - std::wstring gears_dll, gears_dll_copy; - ASSERT_TRUE(PathService::Get(chrome::FILE_GEARS_PLUGIN, &gears_dll)); - gears_dll_copy = gears_dll + L".copy"; - ASSERT_TRUE(CopyFileWrapper(gears_dll, gears_dll_copy)); - TimeDelta timings[kNumCycles]; for (int i = 0; i < kNumCycles; ++i) { if (test_cold) { - ASSERT_TRUE(CopyFileWrapper(chrome_dll_copy, chrome_dll)); - ASSERT_TRUE(CopyFileWrapper(gears_dll_copy, gears_dll)); + FilePath dir_app; + ASSERT_TRUE(PathService::Get(chrome::DIR_APP, &dir_app)); + + FilePath chrome_exe(dir_app.Append( + FilePath::FromWStringHack(chrome::kBrowserProcessExecutableName))); + ASSERT_TRUE(file_util::EvictFileFromSystemCache(chrome_exe)); +#if defined(OS_WIN) + // TODO(port): these files do not exist on other platforms. + // Decide what to do. + + FilePath chrome_dll(dir_app.Append(FILE_PATH_LITERAL("chrome.dll"))); + ASSERT_TRUE(file_util::EvictFileFromSystemCache(chrome_dll)); + + FilePath gears_dll; + ASSERT_TRUE(PathService::Get(chrome::FILE_GEARS_PLUGIN, &gears_dll)); + ASSERT_TRUE(file_util::EvictFileFromSystemCache(gears_dll)); +#endif // defined(OS_WIN) } UITest::SetUp(); @@ -76,9 +69,6 @@ class StartupTest : public UITest { } } - ASSERT_TRUE(file_util::Delete(chrome_dll_copy, false)); - ASSERT_TRUE(file_util::Delete(gears_dll_copy, false)); - std::wstring times; for (int i = 0; i < kNumCycles; ++i) StringAppendF(×, L"%.2f,", timings[i].InMillisecondsF()); @@ -116,12 +106,16 @@ class StartupFileTest : public StartupTest { pages_ = WideToUTF8(file_url); } }; + } // namespace TEST_F(StartupTest, Perf) { RunStartupTest(L"warm", L"t", false /* not cold */, true /* important */); } +#if defined(OS_WIN) +// TODO(port): Enable reference tests on other platforms. + TEST_F(StartupReferenceTest, Perf) { RunStartupTest(L"warm", L"t_ref", false /* not cold */, true /* important */); @@ -143,3 +137,5 @@ TEST_F(StartupFileTest, PerfColdGears) { false /* not important */); } +#endif // defined(OS_WIN) + |