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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include <set> | 12 #include <set> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "app/app_switches.h" | 15 #include "app/app_switches.h" |
16 #include "app/gfx/gl/gl_implementation.h" | 16 #include "app/gfx/gl/gl_implementation.h" |
17 #include "app/sql/connection.h" | 17 #include "app/sql/connection.h" |
18 #include "base/base_switches.h" | 18 #include "base/base_switches.h" |
19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
20 #include "base/environment.h" | 20 #include "base/environment.h" |
21 #include "base/file_path.h" | 21 #include "base/file_path.h" |
22 #include "base/file_util.h" | 22 #include "base/file_util.h" |
23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
24 #include "base/platform_thread.h" | |
25 #include "base/process_util.h" | 24 #include "base/process_util.h" |
26 #include "base/scoped_ptr.h" | 25 #include "base/scoped_ptr.h" |
27 #include "base/scoped_temp_dir.h" | 26 #include "base/scoped_temp_dir.h" |
28 #include "base/string_number_conversions.h" | 27 #include "base/string_number_conversions.h" |
29 #include "base/string_split.h" | 28 #include "base/string_split.h" |
30 #include "base/test/test_file_util.h" | 29 #include "base/test/test_file_util.h" |
| 30 #include "base/threading/platform_thread.h" |
31 #include "base/time.h" | 31 #include "base/time.h" |
32 #include "base/utf_string_conversions.h" | 32 #include "base/utf_string_conversions.h" |
33 #include "chrome/app/chrome_command_ids.h" | 33 #include "chrome/app/chrome_command_ids.h" |
34 #include "chrome/browser/net/url_fixer_upper.h" | 34 #include "chrome/browser/net/url_fixer_upper.h" |
35 #include "chrome/common/automation_messages.h" | 35 #include "chrome/common/automation_messages.h" |
36 #include "chrome/common/chrome_constants.h" | 36 #include "chrome/common/chrome_constants.h" |
37 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/debug_flags.h" | 39 #include "chrome/common/debug_flags.h" |
40 #include "chrome/common/logging_chrome.h" | 40 #include "chrome/common/logging_chrome.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 TestTimeouts::command_execution_timeout_ms())); | 205 TestTimeouts::command_execution_timeout_ms())); |
206 WaitForBrowserLaunch(); | 206 WaitForBrowserLaunch(); |
207 } | 207 } |
208 | 208 |
209 void UITestBase::WaitForBrowserLaunch() { | 209 void UITestBase::WaitForBrowserLaunch() { |
210 ASSERT_EQ(AUTOMATION_SUCCESS, automation_proxy_->WaitForAppLaunch()) | 210 ASSERT_EQ(AUTOMATION_SUCCESS, automation_proxy_->WaitForAppLaunch()) |
211 << "Error while awaiting automation ping from browser process"; | 211 << "Error while awaiting automation ping from browser process"; |
212 if (wait_for_initial_loads_) | 212 if (wait_for_initial_loads_) |
213 ASSERT_TRUE(automation_proxy_->WaitForInitialLoads()); | 213 ASSERT_TRUE(automation_proxy_->WaitForInitialLoads()); |
214 else | 214 else |
215 PlatformThread::Sleep(sleep_timeout_ms()); | 215 base::PlatformThread::Sleep(sleep_timeout_ms()); |
216 | 216 |
217 EXPECT_TRUE(automation()->SetFilteredInet(ShouldFilterInet())); | 217 EXPECT_TRUE(automation()->SetFilteredInet(ShouldFilterInet())); |
218 } | 218 } |
219 | 219 |
220 void UITestBase::CloseBrowserAndServer() { | 220 void UITestBase::CloseBrowserAndServer() { |
221 QuitBrowser(); | 221 QuitBrowser(); |
222 CleanupAppProcesses(); | 222 CleanupAppProcesses(); |
223 | 223 |
224 // Suppress spammy failures that seem to be occurring when running | 224 // Suppress spammy failures that seem to be occurring when running |
225 // the UI tests in single-process mode. | 225 // the UI tests in single-process mode. |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 std::string cookie_value = WaitUntilCookieNonEmpty(tab.get(), url, | 1014 std::string cookie_value = WaitUntilCookieNonEmpty(tab.get(), url, |
1015 cookie_name.c_str(), | 1015 cookie_name.c_str(), |
1016 wait_time); | 1016 wait_time); |
1017 EXPECT_EQ(expected_cookie_value, cookie_value); | 1017 EXPECT_EQ(expected_cookie_value, cookie_value); |
1018 } | 1018 } |
1019 | 1019 |
1020 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { | 1020 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { |
1021 for (int i = 0; i < 10; i++) { | 1021 for (int i = 0; i < 10; i++) { |
1022 if (file_util::EvictFileFromSystemCache(path)) | 1022 if (file_util::EvictFileFromSystemCache(path)) |
1023 return true; | 1023 return true; |
1024 PlatformThread::Sleep(sleep_timeout_ms() / 10); | 1024 base::PlatformThread::Sleep(sleep_timeout_ms() / 10); |
1025 } | 1025 } |
1026 return false; | 1026 return false; |
1027 } | 1027 } |
1028 | 1028 |
1029 void UITest::WaitForGeneratedFileAndCheck( | 1029 void UITest::WaitForGeneratedFileAndCheck( |
1030 const FilePath& generated_file, | 1030 const FilePath& generated_file, |
1031 const FilePath& original_file, | 1031 const FilePath& original_file, |
1032 bool compare_files, | 1032 bool compare_files, |
1033 bool need_equal, | 1033 bool need_equal, |
1034 bool delete_generated_file) { | 1034 bool delete_generated_file) { |
1035 // Check whether the target file has been generated. | 1035 // Check whether the target file has been generated. |
1036 base::PlatformFileInfo previous, current; | 1036 base::PlatformFileInfo previous, current; |
1037 bool exist = false; | 1037 bool exist = false; |
1038 const int kCycles = 20; | 1038 const int kCycles = 20; |
1039 for (int i = 0; i < kCycles; ++i) { | 1039 for (int i = 0; i < kCycles; ++i) { |
1040 if (exist) { | 1040 if (exist) { |
1041 file_util::GetFileInfo(generated_file, ¤t); | 1041 file_util::GetFileInfo(generated_file, ¤t); |
1042 if (current.size == previous.size) | 1042 if (current.size == previous.size) |
1043 break; | 1043 break; |
1044 previous = current; | 1044 previous = current; |
1045 } else if (file_util::PathExists(generated_file)) { | 1045 } else if (file_util::PathExists(generated_file)) { |
1046 file_util::GetFileInfo(generated_file, &previous); | 1046 file_util::GetFileInfo(generated_file, &previous); |
1047 exist = true; | 1047 exist = true; |
1048 } | 1048 } |
1049 PlatformThread::Sleep(sleep_timeout_ms() / kCycles); | 1049 base::PlatformThread::Sleep(sleep_timeout_ms() / kCycles); |
1050 } | 1050 } |
1051 EXPECT_TRUE(exist); | 1051 EXPECT_TRUE(exist); |
1052 | 1052 |
1053 if (compare_files) { | 1053 if (compare_files) { |
1054 // Check whether the generated file is equal with original file according to | 1054 // Check whether the generated file is equal with original file according to |
1055 // parameter: need_equal. | 1055 // parameter: need_equal. |
1056 int64 generated_file_size = 0; | 1056 int64 generated_file_size = 0; |
1057 int64 original_file_size = 0; | 1057 int64 original_file_size = 0; |
1058 | 1058 |
1059 EXPECT_TRUE(file_util::GetFileSize(generated_file, &generated_file_size)); | 1059 EXPECT_TRUE(file_util::GetFileSize(generated_file, &generated_file_size)); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 incorrect_state_count++; | 1208 incorrect_state_count++; |
1209 } | 1209 } |
1210 | 1210 |
1211 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() | 1211 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() |
1212 << " seconds" | 1212 << " seconds" |
1213 << " call failed " << fail_count << " times" | 1213 << " call failed " << fail_count << " times" |
1214 << " state was incorrect " << incorrect_state_count << " times"; | 1214 << " state was incorrect " << incorrect_state_count << " times"; |
1215 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; | 1215 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; |
1216 return false; | 1216 return false; |
1217 } | 1217 } |
OLD | NEW |