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" | |
10 #include "base/command_line.h" | 9 #include "base/command_line.h" |
11 #include "base/environment.h" | 10 #include "base/environment.h" |
12 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/keyboard_codes.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_util.h" | 17 #include "base/string_util.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "chrome/app/chrome_dll_resource.h" | 19 #include "chrome/app/chrome_dll_resource.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/character_encoding.h" | 21 #include "chrome/browser/character_encoding.h" |
22 #include "chrome/browser/view_ids.h" | 22 #include "chrome/browser/view_ids.h" |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 bool AutomatedUITest::OpenViewPasswordsDialog() { | 480 bool AutomatedUITest::OpenViewPasswordsDialog() { |
481 return RunCommandAsync(IDC_VIEW_PASSWORDS); | 481 return RunCommandAsync(IDC_VIEW_PASSWORDS); |
482 } | 482 } |
483 | 483 |
484 bool AutomatedUITest::Options() { | 484 bool AutomatedUITest::Options() { |
485 return RunCommandAsync(IDC_OPTIONS); | 485 return RunCommandAsync(IDC_OPTIONS); |
486 } | 486 } |
487 | 487 |
488 bool AutomatedUITest::PressDownArrow() { | 488 bool AutomatedUITest::PressDownArrow() { |
489 return SimulateKeyPressInActiveWindow(app::VKEY_DOWN, 0); | 489 return SimulateKeyPressInActiveWindow(base::VKEY_DOWN, 0); |
490 } | 490 } |
491 | 491 |
492 bool AutomatedUITest::PressEnterKey() { | 492 bool AutomatedUITest::PressEnterKey() { |
493 return SimulateKeyPressInActiveWindow(app::VKEY_RETURN, 0); | 493 return SimulateKeyPressInActiveWindow(base::VKEY_RETURN, 0); |
494 } | 494 } |
495 | 495 |
496 bool AutomatedUITest::PressEscapeKey() { | 496 bool AutomatedUITest::PressEscapeKey() { |
497 return SimulateKeyPressInActiveWindow(app::VKEY_ESCAPE, 0); | 497 return SimulateKeyPressInActiveWindow(base::VKEY_ESCAPE, 0); |
498 } | 498 } |
499 | 499 |
500 bool AutomatedUITest::PressPageDown() { | 500 bool AutomatedUITest::PressPageDown() { |
501 return SimulateKeyPressInActiveWindow(app::VKEY_PRIOR, 0); | 501 return SimulateKeyPressInActiveWindow(base::VKEY_PRIOR, 0); |
502 } | 502 } |
503 | 503 |
504 bool AutomatedUITest::PressPageUp() { | 504 bool AutomatedUITest::PressPageUp() { |
505 return SimulateKeyPressInActiveWindow(app::VKEY_NEXT, 0); | 505 return SimulateKeyPressInActiveWindow(base::VKEY_NEXT, 0); |
506 } | 506 } |
507 | 507 |
508 bool AutomatedUITest::PressSpaceBar() { | 508 bool AutomatedUITest::PressSpaceBar() { |
509 return SimulateKeyPressInActiveWindow(app::VKEY_SPACE, 0); | 509 return SimulateKeyPressInActiveWindow(base::VKEY_SPACE, 0); |
510 } | 510 } |
511 | 511 |
512 bool AutomatedUITest::PressTabKey() { | 512 bool AutomatedUITest::PressTabKey() { |
513 return SimulateKeyPressInActiveWindow(app::VKEY_TAB, 0); | 513 return SimulateKeyPressInActiveWindow(base::VKEY_TAB, 0); |
514 } | 514 } |
515 | 515 |
516 bool AutomatedUITest::PressUpArrow() { | 516 bool AutomatedUITest::PressUpArrow() { |
517 return SimulateKeyPressInActiveWindow(app::VKEY_UP, 0); | 517 return SimulateKeyPressInActiveWindow(base::VKEY_UP, 0); |
518 } | 518 } |
519 | 519 |
520 bool AutomatedUITest::StarPage() { | 520 bool AutomatedUITest::StarPage() { |
521 return RunCommandAsync(IDC_BOOKMARK_PAGE); | 521 return RunCommandAsync(IDC_BOOKMARK_PAGE); |
522 } | 522 } |
523 | 523 |
524 bool AutomatedUITest::ViewSource() { | 524 bool AutomatedUITest::ViewSource() { |
525 return RunCommandAsync(IDC_VIEW_SOURCE); | 525 return RunCommandAsync(IDC_VIEW_SOURCE); |
526 } | 526 } |
527 | 527 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 scoped_refptr<TabProxy> tab(GetActiveTab()); | 597 scoped_refptr<TabProxy> tab(GetActiveTab()); |
598 GURL test_url(chrome::kAboutCrashURL); | 598 GURL test_url(chrome::kAboutCrashURL); |
599 AutomationMsg_NavigationResponseValues result = tab->NavigateToURL(test_url); | 599 AutomationMsg_NavigationResponseValues result = tab->NavigateToURL(test_url); |
600 if (result != AUTOMATION_MSG_NAVIGATION_SUCCESS) { | 600 if (result != AUTOMATION_MSG_NAVIGATION_SUCCESS) { |
601 AddErrorAttribute("navigation_failed"); | 601 AddErrorAttribute("navigation_failed"); |
602 return false; | 602 return false; |
603 } | 603 } |
604 return true; | 604 return true; |
605 } | 605 } |
606 | 606 |
607 bool AutomatedUITest::SimulateKeyPressInActiveWindow(app::KeyboardCode key, | 607 bool AutomatedUITest::SimulateKeyPressInActiveWindow(base::KeyboardCode key, |
608 int flags) { | 608 int flags) { |
609 scoped_refptr<WindowProxy> window(automation()->GetActiveWindow()); | 609 scoped_refptr<WindowProxy> window(automation()->GetActiveWindow()); |
610 if (window.get() == NULL) { | 610 if (window.get() == NULL) { |
611 AddErrorAttribute("active_window_not_found"); | 611 AddErrorAttribute("active_window_not_found"); |
612 return false; | 612 return false; |
613 } | 613 } |
614 if (!window->SimulateOSKeyPress(key, flags)) { | 614 if (!window->SimulateOSKeyPress(key, flags)) { |
615 AddWarningAttribute("failure_simulating_key_press"); | 615 AddWarningAttribute("failure_simulating_key_press"); |
616 return false; | 616 return false; |
617 } | 617 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 } | 748 } |
749 } | 749 } |
750 | 750 |
751 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { | 751 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { |
752 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 752 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
753 if (parsed_command_line.HasSwitch(kReproSwitch)) | 753 if (parsed_command_line.HasSwitch(kReproSwitch)) |
754 RunReproduction(); | 754 RunReproduction(); |
755 else | 755 else |
756 RunAutomatedUITest(); | 756 RunAutomatedUITest(); |
757 } | 757 } |
OLD | NEW |