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/sql/connection.h" | 15 #include "app/sql/connection.h" |
16 #include "base/base_switches.h" | 16 #include "base/base_switches.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/environment.h" |
18 #include "base/file_path.h" | 19 #include "base/file_path.h" |
19 #include "base/file_util.h" | 20 #include "base/file_util.h" |
20 #include "base/path_service.h" | 21 #include "base/path_service.h" |
21 #include "base/platform_thread.h" | 22 #include "base/platform_thread.h" |
22 #include "base/process_util.h" | 23 #include "base/process_util.h" |
23 #include "base/scoped_ptr.h" | 24 #include "base/scoped_ptr.h" |
24 #include "base/scoped_temp_dir.h" | 25 #include "base/scoped_temp_dir.h" |
25 #include "base/string_number_conversions.h" | 26 #include "base/string_number_conversions.h" |
26 #include "base/test/test_file_util.h" | 27 #include "base/test/test_file_util.h" |
27 #include "base/time.h" | 28 #include "base/time.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 void UITestBase::LaunchBrowser(const CommandLine& arguments, | 408 void UITestBase::LaunchBrowser(const CommandLine& arguments, |
408 bool clear_profile) { | 409 bool clear_profile) { |
409 if (clear_profile || !temp_profile_dir_->IsValid()) { | 410 if (clear_profile || !temp_profile_dir_->IsValid()) { |
410 temp_profile_dir_.reset(new ScopedTempDir()); | 411 temp_profile_dir_.reset(new ScopedTempDir()); |
411 ASSERT_TRUE(temp_profile_dir_->CreateUniqueTempDir()); | 412 ASSERT_TRUE(temp_profile_dir_->CreateUniqueTempDir()); |
412 | 413 |
413 // Update the information about user data directory location on the ui_test | 414 // Update the information about user data directory location on the ui_test |
414 // side. Using PathService seems to be the most reliable, consistent way | 415 // side. Using PathService seems to be the most reliable, consistent way |
415 // to do that. | 416 // to do that. |
416 ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, user_data_dir())); | 417 ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, user_data_dir())); |
| 418 |
| 419 #if defined(OS_LINUX) |
| 420 // Make sure the cache directory is inside our clear profile. Otherwise |
| 421 // the cache may contain data from earlier tests that could break the |
| 422 // current test. |
| 423 // |
| 424 // Note: we use an environment variable here, because we have to pass the |
| 425 // value to the child process. This is the simplest way to do it. |
| 426 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 427 env->SetVar("XDG_CACHE_HOME", user_data_dir().value()); |
| 428 #endif |
417 } | 429 } |
418 | 430 |
419 if (!template_user_data_.empty()) { | 431 if (!template_user_data_.empty()) { |
420 // Recursively copy the template directory to the user_data_dir. | 432 // Recursively copy the template directory to the user_data_dir. |
421 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache( | 433 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache( |
422 template_user_data_, | 434 template_user_data_, |
423 user_data_dir())); | 435 user_data_dir())); |
424 // If we're using the complex theme data, we need to write the | 436 // If we're using the complex theme data, we need to write the |
425 // user_data_dir_ to our preferences file. | 437 // user_data_dir_ to our preferences file. |
426 if (profile_type_ == UITestBase::COMPLEX_THEME) { | 438 if (profile_type_ == UITestBase::COMPLEX_THEME) { |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 UITestBase::TearDown(); | 1268 UITestBase::TearDown(); |
1257 PlatformTest::TearDown(); | 1269 PlatformTest::TearDown(); |
1258 } | 1270 } |
1259 | 1271 |
1260 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) { | 1272 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) { |
1261 // Make the AutomationProxy disconnect the channel on the first error, | 1273 // Make the AutomationProxy disconnect the channel on the first error, |
1262 // so that we avoid spending a lot of time in timeouts. The browser is likely | 1274 // so that we avoid spending a lot of time in timeouts. The browser is likely |
1263 // hosed if we hit those errors. | 1275 // hosed if we hit those errors. |
1264 return new AutomationProxy(execution_timeout, true); | 1276 return new AutomationProxy(execution_timeout, true); |
1265 } | 1277 } |
OLD | NEW |