OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 UITestBase::UITestBase() | 81 UITestBase::UITestBase() |
82 : launch_arguments_(CommandLine::NO_PROGRAM), | 82 : launch_arguments_(CommandLine::NO_PROGRAM), |
83 expected_errors_(0), | 83 expected_errors_(0), |
84 expected_crashes_(0), | 84 expected_crashes_(0), |
85 homepage_(chrome::kAboutBlankURL), | 85 homepage_(chrome::kAboutBlankURL), |
86 wait_for_initial_loads_(true), | 86 wait_for_initial_loads_(true), |
87 dom_automation_enabled_(false), | 87 dom_automation_enabled_(false), |
88 show_window_(false), | 88 show_window_(false), |
89 clear_profile_(true), | 89 clear_profile_(true), |
90 include_testing_id_(true), | 90 include_testing_id_(true), |
91 enable_file_cookies_(true), | 91 enable_file_cookies_(true) { |
92 profile_type_(UITestBase::DEFAULT_THEME) { | |
93 PathService::Get(chrome::DIR_APP, &browser_directory_); | 92 PathService::Get(chrome::DIR_APP, &browser_directory_); |
94 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); | 93 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); |
95 } | 94 } |
96 | 95 |
97 UITestBase::UITestBase(MessageLoop::Type msg_loop_type) | 96 UITestBase::UITestBase(MessageLoop::Type msg_loop_type) |
98 : launch_arguments_(CommandLine::NO_PROGRAM), | 97 : launch_arguments_(CommandLine::NO_PROGRAM), |
99 expected_errors_(0), | 98 expected_errors_(0), |
100 expected_crashes_(0), | 99 expected_crashes_(0), |
101 wait_for_initial_loads_(true), | 100 wait_for_initial_loads_(true), |
102 dom_automation_enabled_(false), | 101 dom_automation_enabled_(false), |
103 show_window_(false), | 102 show_window_(false), |
104 clear_profile_(true), | 103 clear_profile_(true), |
105 include_testing_id_(true), | 104 include_testing_id_(true), |
106 enable_file_cookies_(true), | 105 enable_file_cookies_(true) { |
107 profile_type_(UITestBase::DEFAULT_THEME) { | |
108 PathService::Get(chrome::DIR_APP, &browser_directory_); | 106 PathService::Get(chrome::DIR_APP, &browser_directory_); |
109 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); | 107 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); |
110 } | 108 } |
111 | 109 |
112 UITestBase::~UITestBase() {} | 110 UITestBase::~UITestBase() {} |
113 | 111 |
114 void UITestBase::SetUp() { | 112 void UITestBase::SetUp() { |
115 // Tests that do a session restore (e.g. SessionRestoreUITest, StartupTest) | 113 // Tests that do a session restore (e.g. SessionRestoreUITest, StartupTest) |
116 // call SetUp() multiple times because they restart the browser mid-test. | 114 // call SetUp() multiple times because they restart the browser mid-test. |
117 // We don't want to reset the ProxyLauncher's state in those cases. | 115 // We don't want to reset the ProxyLauncher's state in those cases. |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 if (*application_closed) { | 405 if (*application_closed) { |
408 int exit_code = -1; | 406 int exit_code = -1; |
409 EXPECT_TRUE(launcher_->WaitForBrowserProcessToQuit( | 407 EXPECT_TRUE(launcher_->WaitForBrowserProcessToQuit( |
410 TestTimeouts::action_max_timeout(), &exit_code)); | 408 TestTimeouts::action_max_timeout(), &exit_code)); |
411 EXPECT_EQ(0, exit_code); // Expect a clean shutown. | 409 EXPECT_EQ(0, exit_code); // Expect a clean shutown. |
412 } | 410 } |
413 | 411 |
414 return result; | 412 return result; |
415 } | 413 } |
416 | 414 |
417 // static | |
418 base::FilePath UITestBase::ComputeTypicalUserDataSource( | |
419 UITestBase::ProfileType profile_type) { | |
420 base::FilePath source_history_file; | |
421 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, | |
422 &source_history_file)); | |
423 source_history_file = source_history_file.AppendASCII("profiles"); | |
424 switch (profile_type) { | |
425 case UITestBase::DEFAULT_THEME: | |
426 source_history_file = source_history_file.AppendASCII( | |
427 "profile_with_default_theme"); | |
428 break; | |
429 case UITestBase::COMPLEX_THEME: | |
430 source_history_file = source_history_file.AppendASCII( | |
431 "profile_with_complex_theme"); | |
432 break; | |
433 default: | |
434 NOTREACHED(); | |
435 } | |
436 | |
437 return source_history_file; | |
438 } | |
439 | |
440 int UITestBase::GetCrashCount() const { | 415 int UITestBase::GetCrashCount() const { |
441 base::FilePath crash_dump_path; | 416 base::FilePath crash_dump_path; |
442 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); | 417 PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); |
443 | 418 |
444 int files_found = 0; | 419 int files_found = 0; |
445 file_util::FileEnumerator en(crash_dump_path, false, | 420 file_util::FileEnumerator en(crash_dump_path, false, |
446 file_util::FileEnumerator::FILES); | 421 file_util::FileEnumerator::FILES); |
447 while (!en.Next().empty()) { | 422 while (!en.Next().empty()) { |
448 file_util::FileEnumerator::FindInfo info; | 423 file_util::FileEnumerator::FindInfo info; |
449 if (file_util::FileEnumerator::GetLastModifiedTime(info) > test_start_time_) | 424 if (file_util::FileEnumerator::GetLastModifiedTime(info) > test_start_time_) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 ASSERT_TRUE(session_end_completed); | 696 ASSERT_TRUE(session_end_completed); |
722 | 697 |
723 // Make sure session restore says we didn't crash. | 698 // Make sure session restore says we didn't crash. |
724 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); | 699 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); |
725 ASSERT_TRUE(profile_prefs.get()); | 700 ASSERT_TRUE(profile_prefs.get()); |
726 std::string exit_type; | 701 std::string exit_type; |
727 ASSERT_TRUE(profile_prefs->GetString(prefs::kSessionExitedCleanly, | 702 ASSERT_TRUE(profile_prefs->GetString(prefs::kSessionExitedCleanly, |
728 &exit_type)); | 703 &exit_type)); |
729 EXPECT_EQ(ProfileImpl::kPrefExitTypeNormal, exit_type); | 704 EXPECT_EQ(ProfileImpl::kPrefExitTypeNormal, exit_type); |
730 } | 705 } |
OLD | NEW |