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" | |
19 #include "base/file_path.h" | 18 #include "base/file_path.h" |
20 #include "base/file_util.h" | 19 #include "base/file_util.h" |
21 #include "base/path_service.h" | 20 #include "base/path_service.h" |
22 #include "base/platform_thread.h" | 21 #include "base/platform_thread.h" |
23 #include "base/process_util.h" | 22 #include "base/process_util.h" |
24 #include "base/scoped_ptr.h" | 23 #include "base/scoped_ptr.h" |
25 #include "base/scoped_temp_dir.h" | 24 #include "base/scoped_temp_dir.h" |
26 #include "base/string_number_conversions.h" | 25 #include "base/string_number_conversions.h" |
27 #include "base/test/test_file_util.h" | 26 #include "base/test/test_file_util.h" |
28 #include "base/time.h" | 27 #include "base/time.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 void UITestBase::LaunchBrowser(const CommandLine& arguments, | 378 void UITestBase::LaunchBrowser(const CommandLine& arguments, |
380 bool clear_profile) { | 379 bool clear_profile) { |
381 if (clear_profile || !temp_profile_dir_->IsValid()) { | 380 if (clear_profile || !temp_profile_dir_->IsValid()) { |
382 temp_profile_dir_.reset(new ScopedTempDir()); | 381 temp_profile_dir_.reset(new ScopedTempDir()); |
383 ASSERT_TRUE(temp_profile_dir_->CreateUniqueTempDir()); | 382 ASSERT_TRUE(temp_profile_dir_->CreateUniqueTempDir()); |
384 | 383 |
385 // Update the information about user data directory location on the ui_test | 384 // Update the information about user data directory location on the ui_test |
386 // side. Using PathService seems to be the most reliable, consistent way | 385 // side. Using PathService seems to be the most reliable, consistent way |
387 // to do that. | 386 // to do that. |
388 ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, user_data_dir())); | 387 ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, user_data_dir())); |
389 | |
390 #if defined(OS_LINUX) | |
391 // Make sure the cache directory is inside our clear profile. Otherwise | |
392 // the cache may contain data from earlier tests that could break the | |
393 // current test. | |
394 // | |
395 // Note: we use an environment variable here, because we have to pass the | |
396 // value to the child process. This is the simplest way to do it. | |
397 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
398 env->SetVar("XDG_CACHE_HOME", user_data_dir().value()); | |
399 #endif | |
400 } | 388 } |
401 | 389 |
402 if (!template_user_data_.empty()) { | 390 if (!template_user_data_.empty()) { |
403 // Recursively copy the template directory to the user_data_dir. | 391 // Recursively copy the template directory to the user_data_dir. |
404 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache( | 392 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache( |
405 template_user_data_, | 393 template_user_data_, |
406 user_data_dir())); | 394 user_data_dir())); |
407 // If we're using the complex theme data, we need to write the | 395 // If we're using the complex theme data, we need to write the |
408 // user_data_dir_ to our preferences file. | 396 // user_data_dir_ to our preferences file. |
409 if (profile_type_ == UITestBase::COMPLEX_THEME) { | 397 if (profile_type_ == UITestBase::COMPLEX_THEME) { |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 PlatformTest::TearDown(); | 1540 PlatformTest::TearDown(); |
1553 } | 1541 } |
1554 | 1542 |
1555 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) { | 1543 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) { |
1556 // Make the AutomationProxy disconnect the channel on the first error, | 1544 // Make the AutomationProxy disconnect the channel on the first error, |
1557 // so that we avoid spending a lot of time in timeouts. The browser is likely | 1545 // so that we avoid spending a lot of time in timeouts. The browser is likely |
1558 // hosed if we hit those errors. | 1546 // hosed if we hit those errors. |
1559 return new AutomationProxy(execution_timeout, true); | 1547 return new AutomationProxy(execution_timeout, true); |
1560 } | 1548 } |
1561 | 1549 |
OLD | NEW |