| OLD | NEW |
| 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_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/platform_thread.h" | 7 #include "base/platform_thread.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/test_file_util.h" | 9 #include "base/test_file_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class StartupTest : public UITest { | 21 class StartupTest : public UITest { |
| 22 public: | 22 public: |
| 23 StartupTest() { | 23 StartupTest() { |
| 24 show_window_ = true; | 24 show_window_ = true; |
| 25 pages_ = "about:blank"; | 25 pages_ = "about:blank"; |
| 26 } | 26 } |
| 27 void SetUp() {} | 27 void SetUp() {} |
| 28 void TearDown() {} | 28 void TearDown() {} |
| 29 | 29 |
| 30 void RunStartupTest(const char* graph, const char* trace, | 30 void RunStartupTest(const char* graph, const char* trace, |
| 31 bool test_cold, bool important) { | 31 bool test_cold, bool important, int profile_type) { |
| 32 const int kNumCyclesMax = 20; | 32 const int kNumCyclesMax = 20; |
| 33 int numCycles = kNumCyclesMax; | 33 int numCycles = kNumCyclesMax; |
| 34 // It's ok for unit test code to use getenv(), isn't it? | 34 // It's ok for unit test code to use getenv(), isn't it? |
| 35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 36 #pragma warning( disable : 4996 ) | 36 #pragma warning( disable : 4996 ) |
| 37 #endif | 37 #endif |
| 38 const char* numCyclesEnv = getenv("STARTUP_TESTS_NUMCYCLES"); | 38 const char* numCyclesEnv = getenv("STARTUP_TESTS_NUMCYCLES"); |
| 39 if (numCyclesEnv && StringToInt(numCyclesEnv, &numCycles)) | 39 if (numCyclesEnv && StringToInt(numCyclesEnv, &numCycles)) |
| 40 LOG(INFO) << "STARTUP_TESTS_NUMCYCLES set in environment, " | 40 LOG(INFO) << "STARTUP_TESTS_NUMCYCLES set in environment, " |
| 41 << "so setting numCycles to " << numCycles; | 41 << "so setting numCycles to " << numCycles; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 59 // TODO(port): Re-enable once gears is working on mac/linux. | 59 // TODO(port): Re-enable once gears is working on mac/linux. |
| 60 FilePath gears_dll; | 60 FilePath gears_dll; |
| 61 ASSERT_TRUE(PathService::Get(chrome::FILE_GEARS_PLUGIN, &gears_dll)); | 61 ASSERT_TRUE(PathService::Get(chrome::FILE_GEARS_PLUGIN, &gears_dll)); |
| 62 ASSERT_TRUE(EvictFileFromSystemCacheWrapper(gears_dll)); | 62 ASSERT_TRUE(EvictFileFromSystemCacheWrapper(gears_dll)); |
| 63 #else | 63 #else |
| 64 NOTIMPLEMENTED() << "gears not enabled yet"; | 64 NOTIMPLEMENTED() << "gears not enabled yet"; |
| 65 #endif | 65 #endif |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Sets the profile data for the run. For now, this is only used for |
| 69 // the complex theme test. |
| 70 if (profile_type == UITest::COMPLEX_THEME) |
| 71 set_template_user_data(UITest::ComputeTypicalUserDataSource( |
| 72 profile_type).ToWStringHack()); |
| 73 |
| 68 UITest::SetUp(); | 74 UITest::SetUp(); |
| 69 TimeTicks end_time = TimeTicks::Now(); | 75 TimeTicks end_time = TimeTicks::Now(); |
| 70 timings[i] = end_time - browser_launch_time_; | 76 timings[i] = end_time - browser_launch_time_; |
| 71 // TODO(beng): Can't shut down so quickly. Figure out why, and fix. If we | 77 // TODO(beng): Can't shut down so quickly. Figure out why, and fix. If we |
| 72 // do, we crash. | 78 // do, we crash. |
| 73 PlatformThread::Sleep(50); | 79 PlatformThread::Sleep(50); |
| 74 UITest::TearDown(); | 80 UITest::TearDown(); |
| 75 | 81 |
| 76 if (i == 0) { | 82 if (i == 0) { |
| 77 // Re-use the profile data after first run so that the noise from | 83 // Re-use the profile data after first run so that the noise from |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &file_url)); | 124 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &file_url)); |
| 119 file_url = file_url.AppendASCII("empty.html"); | 125 file_url = file_url.AppendASCII("empty.html"); |
| 120 ASSERT_TRUE(file_util::PathExists(file_url)); | 126 ASSERT_TRUE(file_util::PathExists(file_url)); |
| 121 launch_arguments_.AppendLooseValue(file_url.ToWStringHack()); | 127 launch_arguments_.AppendLooseValue(file_url.ToWStringHack()); |
| 122 | 128 |
| 123 pages_ = WideToUTF8(file_url.ToWStringHack()); | 129 pages_ = WideToUTF8(file_url.ToWStringHack()); |
| 124 } | 130 } |
| 125 }; | 131 }; |
| 126 | 132 |
| 127 TEST_F(StartupTest, Perf) { | 133 TEST_F(StartupTest, Perf) { |
| 128 RunStartupTest("warm", "t", false /* not cold */, true /* important */); | 134 RunStartupTest("warm", "t", false /* not cold */, true /* important */, |
| 135 UITest::DEFAULT_THEME); |
| 129 } | 136 } |
| 130 | 137 |
| 131 // TODO(port): We need a mac reference build checked in for this. | 138 // TODO(port): We need a mac reference build checked in for this. |
| 132 TEST_F(StartupReferenceTest, Perf) { | 139 TEST_F(StartupReferenceTest, Perf) { |
| 133 RunStartupTest("warm", "t_ref", false /* not cold */, | 140 RunStartupTest("warm", "t_ref", false /* not cold */, |
| 134 true /* important */); | 141 true /* important */, UITest::DEFAULT_THEME); |
| 135 } | 142 } |
| 136 | 143 |
| 137 // TODO(mpcomplete): Should we have reference timings for all these? | 144 // TODO(mpcomplete): Should we have reference timings for all these? |
| 138 | 145 |
| 139 TEST_F(StartupTest, PerfCold) { | 146 TEST_F(StartupTest, PerfCold) { |
| 140 RunStartupTest("cold", "t", true /* cold */, false /* not important */); | 147 RunStartupTest("cold", "t", true /* cold */, false /* not important */, |
| 148 UITest::DEFAULT_THEME); |
| 141 } | 149 } |
| 142 | 150 |
| 143 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
| 144 // TODO(port): Enable gears tests on linux/mac once gears is working. | 152 // TODO(port): Enable gears tests on linux/mac once gears is working. |
| 145 TEST_F(StartupFileTest, PerfGears) { | 153 TEST_F(StartupFileTest, PerfGears) { |
| 146 RunStartupTest("warm", "gears", false /* not cold */, | 154 RunStartupTest("warm", "gears", false /* not cold */, |
| 147 false /* not important */); | 155 false /* not important */, UITest::DEFAULT_THEME); |
| 148 } | 156 } |
| 149 | 157 |
| 150 TEST_F(StartupFileTest, PerfColdGears) { | 158 TEST_F(StartupFileTest, PerfColdGears) { |
| 151 RunStartupTest("cold", "gears", true /* cold */, | 159 RunStartupTest("cold", "gears", true /* cold */, |
| 152 false /* not important */); | 160 false /* not important */, UITest::DEFAULT_THEME); |
| 153 } | 161 } |
| 154 #endif | 162 #endif |
| 155 | 163 |
| 164 TEST_F(StartupTest, PerfColdComplexTheme) { |
| 165 RunStartupTest("warm", "t-theme", false /* warm */, |
| 166 false /* not important */, UITest::COMPLEX_THEME); |
| 167 } |
| 168 |
| 156 } // namespace | 169 } // namespace |
| OLD | NEW |