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

Unified Diff: chrome/test/startup/startup_test.cc

Issue 27240: Make startup_tests build and run on Linux (except reference tests). (Closed)
Patch Set: small bugfix in process_util Created 11 years, 10 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 | « chrome/test/automation/browser_proxy.cc ('k') | chrome/test/startup/startup_tests.scons » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/startup/startup_test.cc
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc
index c8cf02ae82c5897523fef93b890835328f8cc702..a07769ddd4d646ff0ad91ae7932d072534da267c 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(&times, 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)
+
« no previous file with comments | « chrome/test/automation/browser_proxy.cc ('k') | chrome/test/startup/startup_tests.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698