OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 - 1); | 584 - 1); |
585 return_value = return_value && | 585 return_value = return_value && |
586 DoAction(kTestDialogPossibleActions[action_index]); | 586 DoAction(kTestDialogPossibleActions[action_index]); |
587 if (DidCrash(false)) | 587 if (DidCrash(false)) |
588 break; | 588 break; |
589 } | 589 } |
590 return DoAction("PressEscapeKey") && return_value; | 590 return DoAction("PressEscapeKey") && return_value; |
591 } | 591 } |
592 | 592 |
593 bool AutomatedUITest::ForceCrash() { | 593 bool AutomatedUITest::ForceCrash() { |
594 scoped_ptr<TabProxy> tab(GetActiveTab()); | 594 scoped_refptr<TabProxy> tab(GetActiveTab()); |
595 GURL test_url("about:crash"); | 595 GURL test_url("about:crash"); |
596 bool did_timeout; | 596 bool did_timeout; |
597 tab->NavigateToURLWithTimeout(test_url, kDebuggingTimeoutMsec, &did_timeout); | 597 tab->NavigateToURLWithTimeout(test_url, kDebuggingTimeoutMsec, &did_timeout); |
598 if (!did_timeout) { | 598 if (!did_timeout) { |
599 AddInfoAttribute("expected_crash"); | 599 AddInfoAttribute("expected_crash"); |
600 return false; | 600 return false; |
601 } | 601 } |
602 return true; | 602 return true; |
603 } | 603 } |
604 | 604 |
605 bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) { | 605 bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) { |
606 BrowserProxy* browser = active_browser(); | 606 BrowserProxy* browser = active_browser(); |
607 if (browser == NULL) { | 607 if (browser == NULL) { |
608 AddErrorAttribute("browser_window_not_found"); | 608 AddErrorAttribute("browser_window_not_found"); |
609 return false; | 609 return false; |
610 } | 610 } |
611 | 611 |
612 scoped_ptr<WindowProxy> window( | 612 scoped_refptr<WindowProxy> window( |
613 GetAndActivateWindowForBrowser(browser)); | 613 GetAndActivateWindowForBrowser(browser)); |
614 if (window.get() == NULL) { | 614 if (window.get() == NULL) { |
615 AddErrorAttribute("active_window_not_found"); | 615 AddErrorAttribute("active_window_not_found"); |
616 return false; | 616 return false; |
617 } | 617 } |
618 bool is_timeout; | 618 bool is_timeout; |
619 | 619 |
620 int tab_count; | 620 int tab_count; |
621 browser->GetTabCountWithTimeout(&tab_count, | 621 browser->GetTabCountWithTimeout(&tab_count, |
622 action_max_timeout_ms(), | 622 action_max_timeout_ms(), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 int new_window_count; | 681 int new_window_count; |
682 automation()->GetBrowserWindowCount(&new_window_count); | 682 automation()->GetBrowserWindowCount(&new_window_count); |
683 if (new_window_count == window_count) { | 683 if (new_window_count == window_count) { |
684 AddInfoAttribute("no_new_browser_window"); | 684 AddInfoAttribute("no_new_browser_window"); |
685 return false; | 685 return false; |
686 } | 686 } |
687 } | 687 } |
688 return true; | 688 return true; |
689 } | 689 } |
690 | 690 |
691 WindowProxy* AutomatedUITest::GetAndActivateWindowForBrowser( | 691 scoped_refptr<WindowProxy> AutomatedUITest::GetAndActivateWindowForBrowser( |
692 BrowserProxy* browser) { | 692 BrowserProxy* browser) { |
693 bool did_timeout; | 693 bool did_timeout; |
694 if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), | 694 if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), |
695 &did_timeout)) { | 695 &did_timeout)) { |
696 AddWarningAttribute("failed_to_bring_window_to_front"); | 696 AddWarningAttribute("failed_to_bring_window_to_front"); |
697 return NULL; | 697 return NULL; |
698 } | 698 } |
699 | 699 |
700 WindowProxy* window = browser->GetWindow(); | 700 return browser->GetWindow(); |
701 return window; | |
702 } | 701 } |
703 | 702 |
704 | 703 |
705 bool AutomatedUITest::SimulateKeyPressInActiveWindow(wchar_t key, int flags) { | 704 bool AutomatedUITest::SimulateKeyPressInActiveWindow(wchar_t key, int flags) { |
706 scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); | 705 scoped_refptr<WindowProxy> window(automation()->GetActiveWindow()); |
707 if (window.get() == NULL) { | 706 if (window.get() == NULL) { |
708 AddErrorAttribute("active_window_not_found"); | 707 AddErrorAttribute("active_window_not_found"); |
709 return false; | 708 return false; |
710 } | 709 } |
711 if (!window->SimulateOSKeyPress(key, flags)) { | 710 if (!window->SimulateOSKeyPress(key, flags)) { |
712 AddWarningAttribute("failure_simulating_key_press"); | 711 AddWarningAttribute("failure_simulating_key_press"); |
713 return false; | 712 return false; |
714 } | 713 } |
715 return true; | 714 return true; |
716 } | 715 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 } | 865 } |
867 } | 866 } |
868 | 867 |
869 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { | 868 TEST_F(AutomatedUITest, TheOneAndOnlyTest) { |
870 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 869 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
871 if (parsed_command_line.HasSwitch(kReproSwitch)) | 870 if (parsed_command_line.HasSwitch(kReproSwitch)) |
872 RunReproduction(); | 871 RunReproduction(); |
873 else | 872 else |
874 RunAutomatedUITest(); | 873 RunAutomatedUITest(); |
875 } | 874 } |
OLD | NEW |