OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/environment.h" | 5 #include "base/environment.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 ASSERT_TRUE(file_util::PathExists(test_cases[i])); | 59 ASSERT_TRUE(file_util::PathExists(test_cases[i])); |
60 for (size_t j = 0; j < 5; j++) { | 60 for (size_t j = 0; j < 5; j++) { |
61 ASSERT_TRUE(browser_proxy->AppendTab( | 61 ASSERT_TRUE(browser_proxy->AppendTab( |
62 net::FilePathToFileURL(test_cases[i]))); | 62 net::FilePathToFileURL(test_cases[i]))); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void RunShutdownTest(const char* graph, const char* trace, | 67 void RunShutdownTest(const char* graph, const char* trace, |
68 bool important, TestSize test_size, | 68 bool important, TestSize test_size, |
69 UITest::ShutdownType shutdown_type) { | 69 ProxyLauncher::ShutdownType shutdown_type) { |
70 const int kNumCyclesMax = 20; | 70 const int kNumCyclesMax = 20; |
71 int numCycles = kNumCyclesMax; | 71 int numCycles = kNumCyclesMax; |
72 scoped_ptr<base::Environment> env(base::Environment::Create()); | 72 scoped_ptr<base::Environment> env(base::Environment::Create()); |
73 std::string numCyclesEnv; | 73 std::string numCyclesEnv; |
74 if (env->GetVar(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && | 74 if (env->GetVar(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && |
75 base::StringToInt(numCyclesEnv, &numCycles)) { | 75 base::StringToInt(numCyclesEnv, &numCycles)) { |
76 if (numCycles <= kNumCyclesMax) { | 76 if (numCycles <= kNumCyclesMax) { |
77 VLOG(1) << env_vars::kStartupTestsNumCycles | 77 VLOG(1) << env_vars::kStartupTestsNumCycles |
78 << " set in environment, so setting numCycles to " << numCycles; | 78 << " set in environment, so setting numCycles to " << numCycles; |
79 } else { | 79 } else { |
80 VLOG(1) << env_vars::kStartupTestsNumCycles | 80 VLOG(1) << env_vars::kStartupTestsNumCycles |
81 << " is higher than the max, setting numCycles to " | 81 << " is higher than the max, setting numCycles to " |
82 << kNumCyclesMax; | 82 << kNumCyclesMax; |
83 numCycles = kNumCyclesMax; | 83 numCycles = kNumCyclesMax; |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 TimeDelta timings[kNumCyclesMax]; | 87 TimeDelta timings[kNumCyclesMax]; |
88 for (int i = 0; i < numCycles; ++i) { | 88 for (int i = 0; i < numCycles; ++i) { |
89 UITest::SetUp(); | 89 UITest::SetUp(); |
90 if (test_size == TWENTY_TABS) { | 90 if (test_size == TWENTY_TABS) { |
91 SetUpTwentyTabs(); | 91 SetUpTwentyTabs(); |
92 } | 92 } |
93 set_shutdown_type(shutdown_type); | 93 set_shutdown_type(shutdown_type); |
94 UITest::TearDown(); | 94 UITest::TearDown(); |
95 timings[i] = browser_quit_time_; | 95 timings[i] = browser_quit_time(); |
96 | 96 |
97 if (i == 0) { | 97 if (i == 0) { |
98 // Re-use the profile data after first run so that the noise from | 98 // Re-use the profile data after first run so that the noise from |
99 // creating databases doesn't impact all the runs. | 99 // creating databases doesn't impact all the runs. |
100 clear_profile_ = false; | 100 clear_profile_ = false; |
101 // Clear template_user_data_ so we don't try to copy it over each time | 101 // Clear template_user_data_ so we don't try to copy it over each time |
102 // through. | 102 // through. |
103 set_template_user_data(FilePath()); | 103 set_template_user_data(FilePath()); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 std::string times; | 107 std::string times; |
108 for (int i = 0; i < numCycles; ++i) | 108 for (int i = 0; i < numCycles; ++i) |
109 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); | 109 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); |
110 PrintResultList(graph, "", trace, times, "ms", important); | 110 PrintResultList(graph, "", trace, times, "ms", important); |
111 } | 111 } |
112 }; | 112 }; |
113 | 113 |
114 TEST_F(ShutdownTest, SimpleWindowClose) { | 114 TEST_F(ShutdownTest, SimpleWindowClose) { |
115 RunShutdownTest("shutdown", "simple-window-close", | 115 RunShutdownTest("shutdown", "simple-window-close", |
116 true, /* important */ SIMPLE, UITest::WINDOW_CLOSE); | 116 true, /* important */ SIMPLE, ProxyLauncher::WINDOW_CLOSE); |
117 } | 117 } |
118 | 118 |
119 TEST_F(ShutdownTest, SimpleUserQuit) { | 119 TEST_F(ShutdownTest, SimpleUserQuit) { |
120 RunShutdownTest("shutdown", "simple-user-quit", | 120 RunShutdownTest("shutdown", "simple-user-quit", |
121 true, /* important */ SIMPLE, UITest::USER_QUIT); | 121 true, /* important */ SIMPLE, ProxyLauncher::USER_QUIT); |
122 } | 122 } |
123 | 123 |
124 TEST_F(ShutdownTest, SimpleSessionEnding) { | 124 TEST_F(ShutdownTest, SimpleSessionEnding) { |
125 RunShutdownTest("shutdown", "simple-session-ending", | 125 RunShutdownTest("shutdown", "simple-session-ending", |
126 true, /* important */ SIMPLE, UITest::SESSION_ENDING); | 126 true, /* important */ SIMPLE, ProxyLauncher::SESSION_ENDING); |
127 } | 127 } |
128 | 128 |
129 TEST_F(ShutdownTest, TwentyTabsWindowClose) { | 129 TEST_F(ShutdownTest, TwentyTabsWindowClose) { |
130 RunShutdownTest("shutdown", "twentytabs-window-close", | 130 RunShutdownTest("shutdown", "twentytabs-window-close", |
131 true, /* important */ TWENTY_TABS, UITest::WINDOW_CLOSE); | 131 true, /* important */ TWENTY_TABS, |
| 132 ProxyLauncher::WINDOW_CLOSE); |
132 } | 133 } |
133 | 134 |
134 TEST_F(ShutdownTest, TwentyTabsUserQuit) { | 135 TEST_F(ShutdownTest, TwentyTabsUserQuit) { |
135 RunShutdownTest("shutdown", "twentytabs-user-quit", | 136 RunShutdownTest("shutdown", "twentytabs-user-quit", |
136 true, /* important */ TWENTY_TABS, UITest::USER_QUIT); | 137 true, /* important */ TWENTY_TABS, ProxyLauncher::USER_QUIT); |
137 } | 138 } |
138 | 139 |
139 // http://crbug.com/40671 | 140 // http://crbug.com/40671 |
140 #if defined(OS_WIN) && !defined(NDEBUG) | 141 #if defined(OS_WIN) && !defined(NDEBUG) |
141 #define MAYBE_TwentyTabsSessionEnding DISABLED_TwentyTabsSessionEnding | 142 #define MAYBE_TwentyTabsSessionEnding DISABLED_TwentyTabsSessionEnding |
142 #else | 143 #else |
143 #define MAYBE_TwentyTabsSessionEnding TwentyTabsSessionEnding | 144 #define MAYBE_TwentyTabsSessionEnding TwentyTabsSessionEnding |
144 #endif | 145 #endif |
145 | 146 |
146 TEST_F(ShutdownTest, MAYBE_TwentyTabsSessionEnding) { | 147 TEST_F(ShutdownTest, MAYBE_TwentyTabsSessionEnding) { |
147 RunShutdownTest("shutdown", "twentytabs-session-ending", | 148 RunShutdownTest("shutdown", "twentytabs-session-ending", |
148 true, /* important */ TWENTY_TABS, UITest::SESSION_ENDING); | 149 true, /* important */ TWENTY_TABS, |
| 150 ProxyLauncher::SESSION_ENDING); |
149 } | 151 } |
150 | 152 |
151 } // namespace | 153 } // namespace |
OLD | NEW |