summaryrefslogtreecommitdiffstats
path: root/chrome/test/startup
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 09:38:38 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 09:38:38 +0000
commit71cbd00ce4c63af41f3d9a3c2acffc301600813b (patch)
treeb9b790d01e4af1a61c22342126996d13911e901c /chrome/test/startup
parentbd7105a8391c87c2c3e443392f58aa2b1a61dcbf (diff)
downloadchromium_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')
-rw-r--r--chrome/test/startup/startup_test.cc56
-rw-r--r--chrome/test/startup/startup_tests.scons23
2 files changed, 45 insertions, 34 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(&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)
+
diff --git a/chrome/test/startup/startup_tests.scons b/chrome/test/startup/startup_tests.scons
index 29c0421..81eefa9 100644
--- a/chrome/test/startup/startup_tests.scons
+++ b/chrome/test/startup/startup_tests.scons
@@ -10,6 +10,7 @@ env.ApplySConscript([
'$BASE_DIR/using_base.scons',
'$BASE_DIR/gfx/using_base_gfx.scons',
'$CHROME_SRC_DIR/build/using_googleurl.scons',
+ '$CHROME_SRC_DIR/tools/grit/build/using_generated_resources.scons',
'$GTEST_DIR/../using_gtest.scons',
'$ICU38_DIR/using_icu38.scons',
'$LIBPNG_DIR/using_libpng.scons',
@@ -29,8 +30,9 @@ env.Prepend(
LIBS = [
'automation',
'browser',
- 'browser_views',
'common',
+ 'glue',
+ 'WTF',
],
)
@@ -52,6 +54,7 @@ if env.Bit('windows'):
'/nxcompat',
],
LIBS = [
+ 'browser_views',
'comsupp',
'oleacc',
'rpcrt4',
@@ -78,9 +81,21 @@ input_files = ChromeFileList([
]),
])
-# TODO(port):
-if env.Bit('windows'):
- env.ChromeTestProgram('startup_tests', input_files)
+if not env.Bit('windows'):
+ # TODO(port): port.
+ input_files.Remove(
+ 'feature_startup_test.cc',
+ )
+
+ # Windows-specific files
+ input_files.Remove(
+ '$CHROME_DIR/tools/build/win/precompiled.cc',
+ )
+
+# Please note that currently you have to manually ensure that Hammer/chrome
+# is up to date when you build startup_tests.
+# TODO(sgk): Proper dependency tracking for startup_tests.
+startup_tests = env.ChromeTestProgram('startup_tests', input_files)
p = env.ChromeMSVSProject('startup_tests.vcproj',
dest=('$CHROME_SRC_DIR/chrome/'