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" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/path_service.h" | 13 #include "base/path_service.h" |
15 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
16 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
17 #include "base/string_split.h" | 16 #include "base/string_split.h" |
18 #include "base/string_util.h" | 17 #include "base/string_util.h" |
19 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
20 #include "base/time.h" | 19 #include "base/time.h" |
21 #include "chrome/app/chrome_command_ids.h" | 20 #include "chrome/app/chrome_command_ids.h" |
22 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/character_encoding.h" | 22 #include "chrome/browser/character_encoding.h" |
24 #include "chrome/browser/ui/view_ids.h" | 23 #include "chrome/browser/ui/view_ids.h" |
25 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
26 #include "chrome/common/env_vars.h" | 25 #include "chrome/common/env_vars.h" |
27 #include "chrome/common/libxml_utils.h" | 26 #include "chrome/common/libxml_utils.h" |
28 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
29 #include "chrome/test/automated_ui_tests/automated_ui_tests.h" | 28 #include "chrome/test/automated_ui_tests/automated_ui_tests.h" |
30 #include "chrome/test/automation/browser_proxy.h" | 29 #include "chrome/test/automation/browser_proxy.h" |
31 #include "chrome/test/automation/tab_proxy.h" | 30 #include "chrome/test/automation/tab_proxy.h" |
32 #include "chrome/test/automation/window_proxy.h" | 31 #include "chrome/test/automation/window_proxy.h" |
33 #include "chrome/test/ui/ui_test.h" | 32 #include "chrome/test/ui/ui_test.h" |
34 #include "googleurl/src/gurl.h" | 33 #include "googleurl/src/gurl.h" |
| 34 #include "ui/base/keycodes/keyboard_codes.h" |
35 | 35 |
36 #if defined(TOOLKIT_VIEWS) | 36 #if defined(TOOLKIT_VIEWS) |
37 #include "views/view.h" | 37 #include "views/view.h" |
38 #endif | 38 #endif |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 const char kReproSwitch[] = "key"; | 42 const char kReproSwitch[] = "key"; |
43 | 43 |
44 const char kReproRepeatSwitch[] = "num-reproductions"; | 44 const char kReproRepeatSwitch[] = "num-reproductions"; |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 480 |
481 bool AutomatedUITest::OpenViewPasswordsDialog() { | 481 bool AutomatedUITest::OpenViewPasswordsDialog() { |
482 return RunCommandAsync(IDC_VIEW_PASSWORDS); | 482 return RunCommandAsync(IDC_VIEW_PASSWORDS); |
483 } | 483 } |
484 | 484 |
485 bool AutomatedUITest::Options() { | 485 bool AutomatedUITest::Options() { |
486 return RunCommandAsync(IDC_OPTIONS); | 486 return RunCommandAsync(IDC_OPTIONS); |
487 } | 487 } |
488 | 488 |
489 bool AutomatedUITest::PressDownArrow() { | 489 bool AutomatedUITest::PressDownArrow() { |
490 return SimulateKeyPressInActiveWindow(app::VKEY_DOWN, 0); | 490 return SimulateKeyPressInActiveWindow(ui::VKEY_DOWN, 0); |
491 } | 491 } |
492 | 492 |
493 bool AutomatedUITest::PressEnterKey() { | 493 bool AutomatedUITest::PressEnterKey() { |
494 return SimulateKeyPressInActiveWindow(app::VKEY_RETURN, 0); | 494 return SimulateKeyPressInActiveWindow(ui::VKEY_RETURN, 0); |
495 } | 495 } |
496 | 496 |
497 bool AutomatedUITest::PressEscapeKey() { | 497 bool AutomatedUITest::PressEscapeKey() { |
498 return SimulateKeyPressInActiveWindow(app::VKEY_ESCAPE, 0); | 498 return SimulateKeyPressInActiveWindow(ui::VKEY_ESCAPE, 0); |
499 } | 499 } |
500 | 500 |
501 bool AutomatedUITest::PressPageDown() { | 501 bool AutomatedUITest::PressPageDown() { |
502 return SimulateKeyPressInActiveWindow(app::VKEY_PRIOR, 0); | 502 return SimulateKeyPressInActiveWindow(ui::VKEY_PRIOR, 0); |
503 } | 503 } |
504 | 504 |
505 bool AutomatedUITest::PressPageUp() { | 505 bool AutomatedUITest::PressPageUp() { |
506 return SimulateKeyPressInActiveWindow(app::VKEY_NEXT, 0); | 506 return SimulateKeyPressInActiveWindow(ui::VKEY_NEXT, 0); |
507 } | 507 } |
508 | 508 |
509 bool AutomatedUITest::PressSpaceBar() { | 509 bool AutomatedUITest::PressSpaceBar() { |
510 return SimulateKeyPressInActiveWindow(app::VKEY_SPACE, 0); | 510 return SimulateKeyPressInActiveWindow(ui::VKEY_SPACE, 0); |
511 } | 511 } |
512 | 512 |
513 bool AutomatedUITest::PressTabKey() { | 513 bool AutomatedUITest::PressTabKey() { |
514 return SimulateKeyPressInActiveWindow(app::VKEY_TAB, 0); | 514 return SimulateKeyPressInActiveWindow(ui::VKEY_TAB, 0); |
515 } | 515 } |
516 | 516 |
517 bool AutomatedUITest::PressUpArrow() { | 517 bool AutomatedUITest::PressUpArrow() { |
518 return SimulateKeyPressInActiveWindow(app::VKEY_UP, 0); | 518 return SimulateKeyPressInActiveWindow(ui::VKEY_UP, 0); |
519 } | 519 } |
520 | 520 |
521 bool AutomatedUITest::StarPage() { | 521 bool AutomatedUITest::StarPage() { |
522 return RunCommandAsync(IDC_BOOKMARK_PAGE); | 522 return RunCommandAsync(IDC_BOOKMARK_PAGE); |
523 } | 523 } |
524 | 524 |
525 bool AutomatedUITest::ViewSource() { | 525 bool AutomatedUITest::ViewSource() { |
526 return RunCommandAsync(IDC_VIEW_SOURCE); | 526 return RunCommandAsync(IDC_VIEW_SOURCE); |
527 } | 527 } |
528 | 528 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 scoped_refptr<TabProxy> tab(GetActiveTab()); | 598 scoped_refptr<TabProxy> tab(GetActiveTab()); |
599 GURL test_url(chrome::kAboutCrashURL); | 599 GURL test_url(chrome::kAboutCrashURL); |
600 AutomationMsg_NavigationResponseValues result = tab->NavigateToURL(test_url); | 600 AutomationMsg_NavigationResponseValues result = tab->NavigateToURL(test_url); |
601 if (result != AUTOMATION_MSG_NAVIGATION_SUCCESS) { | 601 if (result != AUTOMATION_MSG_NAVIGATION_SUCCESS) { |
602 AddErrorAttribute("navigation_failed"); | 602 AddErrorAttribute("navigation_failed"); |
603 return false; | 603 return false; |
604 } | 604 } |
605 return true; | 605 return true; |
606 } | 606 } |
607 | 607 |
608 bool AutomatedUITest::SimulateKeyPressInActiveWindow(app::KeyboardCode key, | 608 bool AutomatedUITest::SimulateKeyPressInActiveWindow(ui::KeyboardCode key, |
609 int flags) { | 609 int flags) { |
610 scoped_refptr<WindowProxy> window(automation()->GetActiveWindow()); | 610 scoped_refptr<WindowProxy> window(automation()->GetActiveWindow()); |
611 if (window.get() == NULL) { | 611 if (window.get() == NULL) { |
612 AddErrorAttribute("active_window_not_found"); | 612 AddErrorAttribute("active_window_not_found"); |
613 return false; | 613 return false; |
614 } | 614 } |
615 if (!window->SimulateOSKeyPress(key, flags)) { | 615 if (!window->SimulateOSKeyPress(key, flags)) { |
616 AddWarningAttribute("failure_simulating_key_press"); | 616 AddWarningAttribute("failure_simulating_key_press"); |
617 return false; | 617 return false; |
618 } | 618 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { | 748 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { |
749 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 749 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
750 if (parsed_command_line.HasSwitch(kReproSwitch)) | 750 if (parsed_command_line.HasSwitch(kReproSwitch)) |
751 RunReproduction(); | 751 RunReproduction(); |
752 else | 752 else |
753 RunAutomatedUITest(); | 753 RunAutomatedUITest(); |
754 } | 754 } |
OLD | NEW |