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 <fstream> | 5 #include <fstream> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "app/keyboard_codes.h" | 9 #include "app/keyboard_codes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "base/threading/platform_thread.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 #include "chrome/app/chrome_command_ids.h" | 21 #include "chrome/app/chrome_command_ids.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/character_encoding.h" | 23 #include "chrome/browser/character_encoding.h" |
23 #include "chrome/browser/ui/view_ids.h" | 24 #include "chrome/browser/ui/view_ids.h" |
24 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/env_vars.h" | 26 #include "chrome/common/env_vars.h" |
26 #include "chrome/common/libxml_utils.h" | 27 #include "chrome/common/libxml_utils.h" |
27 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
28 #include "chrome/test/automated_ui_tests/automated_ui_tests.h" | 29 #include "chrome/test/automated_ui_tests/automated_ui_tests.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 did_complete_action = SelectNextTab(); | 377 did_complete_action = SelectNextTab(); |
377 } else if (LowerCaseEqualsASCII(action, "selectprevtab")) { | 378 } else if (LowerCaseEqualsASCII(action, "selectprevtab")) { |
378 did_complete_action = SelectPreviousTab(); | 379 did_complete_action = SelectPreviousTab(); |
379 } else if (LowerCaseEqualsASCII(action, "showbookmarks")) { | 380 } else if (LowerCaseEqualsASCII(action, "showbookmarks")) { |
380 did_complete_action = ShowBookmarkBar(); | 381 did_complete_action = ShowBookmarkBar(); |
381 } else if (LowerCaseEqualsASCII(action, "setup")) { | 382 } else if (LowerCaseEqualsASCII(action, "setup")) { |
382 AutomatedUITestBase::SetUp(); | 383 AutomatedUITestBase::SetUp(); |
383 did_complete_action = true; | 384 did_complete_action = true; |
384 } else if (LowerCaseEqualsASCII(action, "sleep")) { | 385 } else if (LowerCaseEqualsASCII(action, "sleep")) { |
385 // This is for debugging, it probably shouldn't be used real tests. | 386 // This is for debugging, it probably shouldn't be used real tests. |
386 PlatformThread::Sleep(kDebuggingTimeoutMsec); | 387 base::PlatformThread::Sleep(kDebuggingTimeoutMsec); |
387 did_complete_action = true; | 388 did_complete_action = true; |
388 } else if (LowerCaseEqualsASCII(action, "star")) { | 389 } else if (LowerCaseEqualsASCII(action, "star")) { |
389 did_complete_action = StarPage(); | 390 did_complete_action = StarPage(); |
390 } else if (LowerCaseEqualsASCII(action, "taskmanager")) { | 391 } else if (LowerCaseEqualsASCII(action, "taskmanager")) { |
391 did_complete_action = OpenTaskManagerDialog(); | 392 did_complete_action = OpenTaskManagerDialog(); |
392 } else if (LowerCaseEqualsASCII(action, "teardown")) { | 393 } else if (LowerCaseEqualsASCII(action, "teardown")) { |
393 CloseBrowserAndServer(); | 394 CloseBrowserAndServer(); |
394 did_complete_action = true; | 395 did_complete_action = true; |
395 } else if (LowerCaseEqualsASCII(action, "testaboutchrome")) { | 396 } else if (LowerCaseEqualsASCII(action, "testaboutchrome")) { |
396 did_complete_action = TestAboutChrome(); | 397 did_complete_action = TestAboutChrome(); |
(...skipping 24 matching lines...) Expand all Loading... |
421 << action.c_str(); | 422 << action.c_str(); |
422 } | 423 } |
423 | 424 |
424 EXPECT_TRUE(did_complete_action) << action; | 425 EXPECT_TRUE(did_complete_action) << action; |
425 | 426 |
426 if (!did_complete_action) | 427 if (!did_complete_action) |
427 xml_writer_.AddAttribute("failed_to_complete", "yes"); | 428 xml_writer_.AddAttribute("failed_to_complete", "yes"); |
428 xml_writer_.EndElement(); | 429 xml_writer_.EndElement(); |
429 | 430 |
430 if (post_action_delay_) | 431 if (post_action_delay_) |
431 PlatformThread::Sleep(1000 * post_action_delay_); | 432 base::PlatformThread::Sleep(1000 * post_action_delay_); |
432 | 433 |
433 return did_complete_action; | 434 return did_complete_action; |
434 } | 435 } |
435 | 436 |
436 bool AutomatedUITest::ChangeEncoding() { | 437 bool AutomatedUITest::ChangeEncoding() { |
437 // Get the encoding list that is used to populate the UI (encoding menu) | 438 // Get the encoding list that is used to populate the UI (encoding menu) |
438 std::string cur_locale = g_browser_process->GetApplicationLocale(); | 439 std::string cur_locale = g_browser_process->GetApplicationLocale(); |
439 const std::vector<CharacterEncoding::EncodingInfo>* encodings = | 440 const std::vector<CharacterEncoding::EncodingInfo>* encodings = |
440 CharacterEncoding::GetCurrentDisplayEncodings( | 441 CharacterEncoding::GetCurrentDisplayEncodings( |
441 cur_locale, "ISO-8859-1,windows-1252", ""); | 442 cur_locale, "ISO-8859-1,windows-1252", ""); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 745 } |
745 } | 746 } |
746 | 747 |
747 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { | 748 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { |
748 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 749 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
749 if (parsed_command_line.HasSwitch(kReproSwitch)) | 750 if (parsed_command_line.HasSwitch(kReproSwitch)) |
750 RunReproduction(); | 751 RunReproduction(); |
751 else | 752 else |
752 RunAutomatedUITest(); | 753 RunAutomatedUITest(); |
753 } | 754 } |
OLD | NEW |