diff options
author | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-26 23:55:29 +0000 |
---|---|---|
committer | initial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-26 23:55:29 +0000 |
commit | 09911bf300f1a419907a9412154760efd0b7abc3 (patch) | |
tree | f131325fb4e2ad12c6d3504ab75b16dd92facfed /chrome/test/startup | |
parent | 586acc5fe142f498261f52c66862fa417c3d52d2 (diff) | |
download | chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.zip chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.gz chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.bz2 |
Add chrome to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/startup')
-rw-r--r-- | chrome/test/startup/SConscript | 121 | ||||
-rw-r--r-- | chrome/test/startup/feature_startup_test.cc | 159 | ||||
-rw-r--r-- | chrome/test/startup/startup_test.cc | 152 | ||||
-rw-r--r-- | chrome/test/startup/startup_tests.vcproj | 206 |
4 files changed, 638 insertions, 0 deletions
diff --git a/chrome/test/startup/SConscript b/chrome/test/startup/SConscript new file mode 100644 index 0000000..4f48ee5 --- /dev/null +++ b/chrome/test/startup/SConscript @@ -0,0 +1,121 @@ +# Copyright 2008, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Import('env_test')
+
+env_test = env_test.Clone()
+
+env_test.Prepend(
+ CPPDEFINES = [
+ 'UI_TEST',
+ 'UNIT_TEST',
+ 'CERT_CHAIN_PARA_HAS_EXTRA_FIELDS',
+ 'WIN32_LEAN_AND_MEAN',
+ ],
+ CPPPATH = [
+ '$GTEST_DIR/include',
+ '$GTEST_DIR',
+ '$SKIA_DIR/include',
+ '$SKIA_DIR/include/corecg',
+ '$SKIA_DIR/platform',
+ '#/..',
+ ],
+ LINKFLAGS = [
+ '/INCREMENTAL',
+ '/DEBUG',
+
+ '/DELAYLOAD:"dwmapi.dll"',
+ '/DELAYLOAD:"uxtheme.dll"',
+
+ '/MACHINE:X86',
+ '/FIXED:No',
+
+ '/safeseh',
+ '/dynamicbase',
+ '/ignore:4199',
+ '/nxcompat',
+ ],
+ LIBS = [
+ 'winmm.lib',
+ 'rpcrt4.lib',
+ 'oleacc.lib',
+ 'comsupp.lib',
+
+ 'wininet.lib',
+ 'version.lib',
+ 'msimg32.lib',
+ 'ws2_32.lib',
+ 'usp10.lib',
+ 'psapi.lib',
+ 'kernel32.lib',
+ 'user32.lib',
+ 'gdi32.lib',
+ 'winspool.lib',
+ 'comdlg32.lib',
+ 'advapi32.lib',
+ 'shell32.lib',
+ 'ole32.lib',
+ 'oleaut32.lib',
+ 'uuid.lib',
+ 'odbc32.lib',
+ 'odbccp32.lib',
+
+ 'DelayImp.lib',
+ ],
+)
+
+input_files = [
+ '$CHROME_DIR/test/ui/run_all_unittests$OBJSUFFIX',
+ '$CHROME_DIR/test/ui/ui_test$OBJSUFFIX',
+ '$CHROME_DIR/test/ui/ui_test_suite$OBJSUFFIX',
+ '$CHROME_DIR/test/test_file_util$OBJSUFFIX',
+ 'feature_startup_test.cc',
+ 'startup_test.cc',
+]
+
+libs = [
+ '$GOOGLEURL_DIR/googleurl.lib',
+ '$SKIA_DIR/skia.lib',
+ '$LIBPNG_DIR/libpng.lib',
+ '$TESTING_DIR/gtest.lib',
+ '$BASE_DIR/gfx/base_gfx.lib',
+ '$ICU38_DIR/icuuc.lib',
+ '$CHROME_DIR/common/common.lib',
+ '$ZLIB_DIR/zlib.lib',
+ '$CHROME_DIR/browser/browser.lib',
+ '$BASE_DIR/base.lib',
+ '$CHROME_DIR/test/automation/automation.lib',
+]
+
+exe = env_test.Program(['startup_tests',
+ 'startup_tests.pdb'],
+ input_files + libs)
+i = env_test.Install('$TARGET_ROOT', exe)
+
+env_test.Alias('chrome', i)
diff --git a/chrome/test/startup/feature_startup_test.cc b/chrome/test/startup/feature_startup_test.cc new file mode 100644 index 0000000..3173fca --- /dev/null +++ b/chrome/test/startup/feature_startup_test.cc @@ -0,0 +1,159 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include <windows.h> + +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/perftimer.h" +#include "base/time.h" +#include "chrome/app/chrome_dll_resource.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/common/win_util.h" +#include "chrome/test/automation/browser_proxy.h" +#include "chrome/test/ui/ui_test.h" +#include "net/base/net_util.h" + +namespace { + +// Returns the directory name where the "typical" user data is that we use for +// testing. +std::wstring ComputeTypicalUserDataSource() { + std::wstring source_history_file; + EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, + &source_history_file)); + file_util::AppendToPath(&source_history_file, L"profiles"); + file_util::AppendToPath(&source_history_file, L"typical_history"); + return source_history_file; +} + +class NewTabUIStartupTest : public UITest { + public: + NewTabUIStartupTest() { + show_window_ = true; + } + + void SetUp() {} + void TearDown() {} + + static const int kNumCycles = 5; + + void PrintTimings(const char* label, TimeDelta timings[kNumCycles]) { + printf("\n%s = [", label); + for (int i = 0; i < kNumCycles; ++i) { + if (i > 0) + printf(","); + printf("%.2f", timings[i].InMillisecondsF()); + } + printf("]\n"); + } + + // Run the test, by bringing up a browser and timing the new tab startup. + // |want_warm| is true if we should output warm-disk timings, false if + // we should report cold timings. + void RunStartupTest(bool want_warm) { + // Install the location of the test profile file. + set_template_user_data(ComputeTypicalUserDataSource()); + + TimeDelta timings[kNumCycles]; + for (int i = 0; i < kNumCycles; ++i) { + UITest::SetUp(); + + // Switch to the "new tab" tab, which should be any new tab after the + // first (the first is about:blank). + BrowserProxy* window = automation()->GetBrowserWindow(0); + ASSERT_TRUE(window); + int old_tab_count = -1; + ASSERT_TRUE(window->GetTabCount(&old_tab_count)); + ASSERT_EQ(1, old_tab_count); + + // Hit ctl-t and wait for the tab to load. + window->ApplyAccelerator(IDC_NEWTAB); + int new_tab_count = -1; + ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, + 5000)); + ASSERT_EQ(2, new_tab_count); + int load_time; + ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); + timings[i] = TimeDelta::FromMilliseconds(load_time); + + if (want_warm) { + // Bring up a second tab, now that we've already shown one tab. + old_tab_count = new_tab_count; + new_tab_count = -1; + window->ApplyAccelerator(IDC_NEWTAB); + ASSERT_TRUE(window->WaitForTabCountToChange(old_tab_count, &new_tab_count, + 5000)); + ASSERT_EQ(3, new_tab_count); + ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); + timings[i] = TimeDelta::FromMilliseconds(load_time); + } + + delete window; + UITest::TearDown(); + } + + // The buildbot log-scraper looks for this "__.._pages" line to tell when + // the test has completed and how many pages it loaded. + printf("\n__ts_pages = [about:blank]\n"); + PrintTimings("__ts_timings", timings); + } +}; + +// The name of this test is important, since the buildbot runs with a gTest +// filter. +typedef NewTabUIStartupTest NewTabUIStartupTestReference; + +} // namespace + +TEST_F(NewTabUIStartupTest, PerfCold) { + RunStartupTest(false); +} + +TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { + RunStartupTest(true); +} + +TEST_F(NewTabUIStartupTestReference, FakePerfForLogScraperCold) { + // Print an empty reference-test result line so the log-scraper is happy. + // TODO(pamg): really run the test with a reference build? + TimeDelta timings[kNumCycles]; + for (int i = 0; i < kNumCycles; ++i) + timings[i] = TimeDelta::FromMilliseconds(0); + PrintTimings("__ts_reference_timings", timings); +} + +TEST_F(NewTabUIStartupTestReference, FakePerfForLogScraperWarm) { + // Print an empty reference-test result line so the log-scraper is happy. + // TODO(pamg): really run the test with a reference build? + TimeDelta timings[kNumCycles]; + for (int i = 0; i < kNumCycles; ++i) + timings[i] = TimeDelta::FromMilliseconds(0); + PrintTimings("__ts_reference_timings", timings); +}
\ No newline at end of file diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc new file mode 100644 index 0000000..018faf8 --- /dev/null +++ b/chrome/test/startup/startup_test.cc @@ -0,0 +1,152 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/time.h" +#include "chrome/common/chrome_paths.h" +#include "chrome/test/ui/ui_test.h" +#include "net/base/net_util.h" + +namespace { + +class StartupTest : public UITest { + public: + StartupTest() { + show_window_ = true; + pages_ = "about:blank"; + } + void SetUp() {} + void TearDown() {} + + void RunStartupTest(const char* label, bool test_cold) { + 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(file_util::CopyFile(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(file_util::CopyFile(gears_dll, gears_dll_copy)); + + TimeDelta timings[kNumCycles]; + for (int i = 0; i < kNumCycles; ++i) { + if (test_cold) { + ASSERT_TRUE(file_util::CopyFile(chrome_dll_copy, chrome_dll)); + ASSERT_TRUE(file_util::CopyFile(gears_dll_copy, gears_dll)); + } + + UITest::SetUp(); + TimeTicks end_time = TimeTicks::Now(); + timings[i] = end_time - browser_launch_time_; + // TODO(beng): Can't shut down so quickly. Figure out why, and fix. If we + // do, we crash. + Sleep(50); + UITest::TearDown(); + + if (i == 0) { + // Re-use the profile data after first run so that the noise from + // creating databases doesn't impact all the runs. + clear_profile_ = false; + } + } + + ASSERT_TRUE(file_util::Delete(chrome_dll_copy, false)); + ASSERT_TRUE(file_util::Delete(gears_dll_copy, false)); + + printf("\n__ts_pages = [%s]\n", pages_.c_str()); + printf("\n%s = [", label); + for (int i = 0; i < kNumCycles; ++i) { + if (i > 0) + printf(","); + printf("%.2f", timings[i].InMillisecondsF()); + } + printf("]\n"); + } + + protected: + std::string pages_; +}; + +class StartupReferenceTest : public StartupTest { + public: + // override the browser directory that is used by UITest::SetUp to cause it + // to use the reference build instead. + void SetUp() { + std::wstring dir; + PathService::Get(chrome::DIR_TEST_TOOLS, &dir); + file_util::AppendToPath(&dir, L"reference_build"); + file_util::AppendToPath(&dir, L"chrome"); + browser_directory_ = dir; + } +}; + +class StartupFileTest : public StartupTest { + public: + // Load a file on startup rather than about:blank. This tests a longer + // startup path, including resource loading and the loading of gears.dll. + void SetUp() { + std::wstring file_url; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &file_url)); + file_util::AppendToPath(&file_url, L"empty.html"); + ASSERT_TRUE(file_util::PathExists(file_url)); + launch_arguments_ += file_url; + + pages_ = WideToUTF8(file_url); + } +}; +} // namespace + +TEST_F(StartupTest, Perf) { + RunStartupTest("__ts_timings", false); +} + +TEST_F(StartupReferenceTest, Perf) { + RunStartupTest("__ts_reference_timings", false); +} + +// TODO(mpcomplete): Should we have reference timings for all these? + +TEST_F(StartupTest, PerfCold) { + RunStartupTest("__ts_cold_timings", true); +} + +TEST_F(StartupFileTest, PerfGears) { + RunStartupTest("__ts_gears_timings", false); +} + +TEST_F(StartupFileTest, PerfColdGears) { + RunStartupTest("__ts_cold_gears_timings", true); +} diff --git a/chrome/test/startup/startup_tests.vcproj b/chrome/test/startup/startup_tests.vcproj new file mode 100644 index 0000000..e7f38a2 --- /dev/null +++ b/chrome/test/startup/startup_tests.vcproj @@ -0,0 +1,206 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="startup_tests" + ProjectGUID="{D3E6C0FD-54C7-4FF2-9AE1-72F2DAFD820C}" + RootNamespace="startup_tests" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + ConfigurationType="1" + InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;..\..\tools\build\win\precompiled.vsprops;..\..\tools\build\win\unit_test.vsprops;..\..\tools\build\win\ui_test.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="winmm.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + ConfigurationType="1" + InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;..\..\tools\build\win\unit_test.vsprops;..\..\tools\build\win\ui_test.vsprops;$(SolutionDir)..\skia\using_skia.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="winmm.lib" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Common" + > + <File + RelativePath="..\..\tools\build\win\precompiled.cc" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="1" + /> + </FileConfiguration> + </File> + <File + RelativePath="..\..\tools\build\win\precompiled.h" + > + </File> + <File + RelativePath="..\ui\run_all_unittests.cc" + > + </File> + <File + RelativePath="..\test_file_util.cc" + > + </File> + <File + RelativePath="..\test_file_util.h" + > + </File> + <File + RelativePath="..\testing_browser_process.h" + > + </File> + <File + RelativePath="..\ui\ui_test.cc" + > + </File> + <File + RelativePath="..\ui\ui_test.h" + > + </File> + <File + RelativePath="..\ui\ui_test_suite.cc" + > + </File> + </Filter> + <Filter + Name="TestStartup" + > + <File + RelativePath=".\feature_startup_test.cc" + > + </File> + <File + RelativePath=".\startup_test.cc" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |