summaryrefslogtreecommitdiffstats
path: root/chrome/test/automated_ui_tests
diff options
context:
space:
mode:
authorjcampan@google.com <jcampan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 20:40:50 +0000
committerjcampan@google.com <jcampan@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-04 20:40:50 +0000
commit719ead5027772e9be7708cb2414a95df5499595f (patch)
treeff679301ac868278c5479ff2d2d75b7175699540 /chrome/test/automated_ui_tests
parentc783216a001ae7885730700a7d3a6d7fcf4fba97 (diff)
downloadchromium_src-719ead5027772e9be7708cb2414a95df5499595f.zip
chromium_src-719ead5027772e9be7708cb2414a95df5499595f.tar.gz
chromium_src-719ead5027772e9be7708cb2414a95df5499595f.tar.bz2
Reverting my last commit, it seems to cause regression on the page cycler tests.
TBR=beng git-svn-id: svn://svn.chromium.org/chrome/trunk/src@337 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automated_ui_tests')
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc141
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.h54
2 files changed, 40 insertions, 155 deletions
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc
index ef73355..0129e81 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -59,8 +59,6 @@ const wchar_t* const kOutputFilePathSwitch = L"output";
const wchar_t* const kDebugModeSwitch = L"debug";
-const wchar_t* const kWaitSwitch = L"wait-after-action";
-
const wchar_t* const kDefaultInputFilePath = L"C:\\automated_ui_tests.txt";
const wchar_t* const kDefaultOutputFilePath
@@ -75,43 +73,21 @@ const int kTestDialogActionsToRun = 7;
// This subset of commands is used to test dialog boxes, which aren't likely
// to respond to most other commands.
-const std::string kTestDialogPossibleActions[] = {
+std::string AutomatedUITest::test_dialog_possible_actions_[] = {
"PressTabKey",
"PressEnterKey",
"PressSpaceBar",
"DownArrow"
};
-// The list of dialogs that can be shown.
-const std::string kDialogs[] = {
- "About",
- "Options",
- "TaskManager",
- "JavaScriptDebugger",
- "JavaScriptConsole",
- "ClearBrowsingData",
- "Import",
- "EditSearchEngines",
- "ViewPasswords"
-};
-
AutomatedUITest::AutomatedUITest()
: total_crashes_(0),
- debug_logging_enabled_(false),
- post_action_delay_(0) {
+ debug_logging_enabled_(false) {
show_window_ = true;
GetSystemTimeAsFileTime(&test_start_time_);
CommandLine parsed_command_line;
if (parsed_command_line.HasSwitch(kDebugModeSwitch))
debug_logging_enabled_ = true;
- if (parsed_command_line.HasSwitch(kWaitSwitch)) {
- std::wstring str = parsed_command_line.GetSwitchValue(kWaitSwitch);
- if (str.empty()) {
- post_action_delay_ = 1;
- } else {
- post_action_delay_ = static_cast<int>(StringToInt64(str));
- }
- }
}
AutomatedUITest::~AutomatedUITest() {}
@@ -307,28 +283,14 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = ShowHistory();
} else if (LowerCaseEqualsASCII(action, "downloads")) {
did_complete_action = ShowDownloads();
- } else if (LowerCaseEqualsASCII(action, "dialog")) {
- did_complete_action = ExerciseDialog();
+ } else if (LowerCaseEqualsASCII(action, "importsettings")) {
+ did_complete_action = ImportSettings();
} else if (LowerCaseEqualsASCII(action, "viewpasswords")) {
did_complete_action = ViewPasswords();
- } else if (LowerCaseEqualsASCII(action, "about")) {
- did_complete_action = About();
- } else if (LowerCaseEqualsASCII(action, "options")) {
- did_complete_action = Options();
+ } else if (LowerCaseEqualsASCII(action, "clearbrowserdata")) {
+ did_complete_action = ClearBrowserData();
} else if (LowerCaseEqualsASCII(action, "taskmanager")) {
did_complete_action = TaskManager();
- } else if (LowerCaseEqualsASCII(action, "clearbrowsingdata")) {
- did_complete_action = ClearBrowserData();
- } else if (LowerCaseEqualsASCII(action, "javascriptdebugger")) {
- did_complete_action = JavaScriptDebugger();
- } else if (LowerCaseEqualsASCII(action, "javascriptconsole")) {
- did_complete_action = JavaScriptConsole();
- } else if (LowerCaseEqualsASCII(action, "import")) {
- did_complete_action = ImportSettings();
- } else if (LowerCaseEqualsASCII(action, "editsearchengines")) {
- did_complete_action = EditSearchEngines();
- } else if (LowerCaseEqualsASCII(action, "viewpasswords")) {
- did_complete_action = ViewPasswords();
} else if (LowerCaseEqualsASCII(action, "goofftherecord")) {
did_complete_action = GoOffTheRecord();
} else if (LowerCaseEqualsASCII(action, "pressescapekey")) {
@@ -353,14 +315,10 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = UpArrow();
} else if (LowerCaseEqualsASCII(action, "downarrow")) {
did_complete_action = DownArrow();
- } else if (LowerCaseEqualsASCII(action, "options")) {
- did_complete_action = Options();
} else if (LowerCaseEqualsASCII(action, "testeditkeywords")) {
did_complete_action = TestEditKeywords();
} else if (LowerCaseEqualsASCII(action, "testtaskmanager")) {
did_complete_action = TestTaskManager();
- } else if (LowerCaseEqualsASCII(action, "testoptions")) {
- did_complete_action = TestOptions();
} else if (LowerCaseEqualsASCII(action, "testviewpasswords")) {
did_complete_action = TestViewPasswords();
} else if (LowerCaseEqualsASCII(action, "testclearbrowserdata")) {
@@ -385,9 +343,6 @@ bool AutomatedUITest::DoAction(const std::string & action) {
xml_writer_.AddAttribute("failed_to_complete", "yes");
xml_writer_.EndElement();
- if (post_action_delay_)
- ::Sleep(1000 * post_action_delay_);
-
return did_complete_action;
}
@@ -436,7 +391,7 @@ bool AutomatedUITest::NewTab() {
&is_timeout);
// Apply accelerator and wait for a new tab to open, if either
// fails, return false. Apply Accelerator takes care of logging its failure.
- bool return_value = RunCommand(IDC_NEWTAB);
+ bool return_value = ApplyAccelerator(IDC_NEWTAB);
if (!browser->WaitForTabCountToChange(
old_tab_count, &new_tab_count, kWaitForActionMaxMsec)) {
AddWarningAttribute("tab_count_failed_to_change");
@@ -446,11 +401,11 @@ bool AutomatedUITest::NewTab() {
}
bool AutomatedUITest::BackButton() {
- return RunCommand(IDC_BACK);
+ return ApplyAccelerator(IDC_BACK);
}
bool AutomatedUITest::ForwardButton() {
- return RunCommand(IDC_FORWARD);
+ return ApplyAccelerator(IDC_FORWARD);
}
bool AutomatedUITest::CloseActiveTab() {
@@ -469,7 +424,7 @@ bool AutomatedUITest::CloseActiveTab() {
// Avoid quitting the application by not closing the last window.
if (tab_count > 1) {
int new_tab_count;
- return_value = browser->RunCommand(IDC_CLOSETAB);
+ return_value = browser->ApplyAccelerator(IDC_CLOSETAB);
// Wait for the tab to close before we continue.
if (!browser->WaitForTabCountToChange(
tab_count, &new_tab_count, kWaitForActionMaxMsec)) {
@@ -478,7 +433,7 @@ bool AutomatedUITest::CloseActiveTab() {
}
} else if (tab_count == 1 && browser_windows_count > 1) {
int new_window_count;
- return_value = browser->RunCommand(IDC_CLOSETAB);
+ return_value = browser->ApplyAccelerator(IDC_CLOSETAB);
// Wait for the window to close before we continue.
if (!automation()->WaitForWindowCountToChange(
browser_windows_count, &new_window_count, kWaitForActionMaxMsec)) {
@@ -517,79 +472,59 @@ bool AutomatedUITest::OpenAndActivateNewBrowserWindow() {
}
bool AutomatedUITest::ReloadPage() {
- return RunCommand(IDC_RELOAD);
+ return ApplyAccelerator(IDC_RELOAD);
}
bool AutomatedUITest::StarPage() {
- return RunCommand(IDC_STAR);
+ return ApplyAccelerator(IDC_STAR);
}
bool AutomatedUITest::FindInPage() {
- return RunCommand(IDC_FIND);
+ return ApplyAccelerator(IDC_FIND);
}
bool AutomatedUITest::SelectNextTab() {
- return RunCommand(IDC_SELECT_NEXT_TAB);
+ return ApplyAccelerator(IDC_SELECT_NEXT_TAB);
}
bool AutomatedUITest::SelectPreviousTab() {
- return RunCommand(IDC_SELECT_PREV_TAB);
+ return ApplyAccelerator(IDC_SELECT_PREV_TAB);
}
bool AutomatedUITest::ZoomPlus() {
- return RunCommand(IDC_ZOOM_PLUS);
+ return ApplyAccelerator(IDC_ZOOM_PLUS);
}
bool AutomatedUITest::ZoomMinus() {
- return RunCommand(IDC_ZOOM_MINUS);
+ return ApplyAccelerator(IDC_ZOOM_MINUS);
}
bool AutomatedUITest::ShowHistory() {
- return RunCommand(IDC_SHOW_HISTORY);
+ return ApplyAccelerator(IDC_SHOW_HISTORY);
}
bool AutomatedUITest::ShowDownloads() {
- return RunCommand(IDC_SHOW_DOWNLOADS);
+ return ApplyAccelerator(IDC_SHOW_DOWNLOADS);
}
bool AutomatedUITest::ImportSettings() {
- return RunCommand(IDC_IMPORT_SETTINGS);
-}
-
-bool AutomatedUITest::EditSearchEngines() {
- return RunCommand(IDC_EDIT_SEARCH_ENGINES);
+ return ApplyAccelerator(IDC_IMPORT_SETTINGS);
}
bool AutomatedUITest::ViewPasswords() {
- return RunCommand(IDC_VIEW_PASSWORDS);
+ return ApplyAccelerator(IDC_VIEW_PASSWORDS);
}
bool AutomatedUITest::ClearBrowserData() {
- return RunCommand(IDC_CLEAR_BROWSING_DATA);
+ return ApplyAccelerator(IDC_CLEAR_BROWSING_DATA);
}
bool AutomatedUITest::TaskManager() {
- return RunCommand(IDC_TASKMANAGER);
-}
-
-bool AutomatedUITest::Options() {
- return RunCommand(IDC_OPTIONS);
-}
-
-bool AutomatedUITest::JavaScriptConsole() {
- return RunCommand(IDC_SHOW_JS_CONSOLE);
-}
-
-bool AutomatedUITest::JavaScriptDebugger() {
- return RunCommand(IDC_DEBUGGER);
-}
-
-bool AutomatedUITest::About() {
- return RunCommand(IDC_ABOUT);
+ return ApplyAccelerator(IDC_TASKMANAGER);
}
bool AutomatedUITest::GoOffTheRecord() {
- return RunCommand(IDC_GOOFFTHERECORD);
+ return ApplyAccelerator(IDC_GOOFFTHERECORD);
}
bool AutomatedUITest::PressEscapeKey() {
@@ -635,11 +570,6 @@ bool AutomatedUITest::TestTaskManager() {
return TestDialog(kTestDialogActionsToRun);
}
-bool AutomatedUITest::TestOptions() {
- DoAction("Options");
- return TestDialog(kTestDialogActionsToRun);
-}
-
bool AutomatedUITest::TestViewPasswords() {
DoAction("ViewPasswords");
return TestDialog(kTestDialogActionsToRun);
@@ -655,20 +585,13 @@ bool AutomatedUITest::TestImportSettings() {
return TestDialog(kTestDialogActionsToRun);
}
-bool AutomatedUITest::ExerciseDialog() {
- int index = rand_util::RandInt(0, arraysize(kDialogs) - 1);
- return DoAction(kDialogs[index]) && TestDialog(kTestDialogActionsToRun);
-}
-
bool AutomatedUITest::TestDialog(int num_actions) {
bool return_value = true;
for (int i = 0; i < num_actions; i++) {
- int action_index = rand_util::RandInt(i == 0 ? 1 : 0,
- arraysize(kTestDialogPossibleActions)
- - 1);
+ int action_index = rand_util::RandInt(0, kNumTestDialogActions - 1);
return_value = return_value &&
- DoAction(kTestDialogPossibleActions[action_index]);
+ DoAction(test_dialog_possible_actions_[action_index]);
if (DidCrash(false))
break;
}
@@ -788,21 +711,23 @@ WindowProxy* AutomatedUITest::GetAndActivateWindowForBrowser(
return window;
}
-bool AutomatedUITest::RunCommand(int browser_command) {
+bool AutomatedUITest::ApplyAccelerator(int id) {
scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
if (browser.get() == NULL) {
AddErrorAttribute("browser_window_not_found");
return false;
}
- if (!browser->RunCommand(browser_command)) {
- AddWarningAttribute("failure_running_browser_command");
+ if (!browser->ApplyAccelerator(id)) {
+ AddWarningAttribute("failure_applying_accelerator");
return false;
}
return true;
}
bool AutomatedUITest::SimulateKeyPressInActiveWindow(wchar_t key, int flags) {
- scoped_ptr<WindowProxy> window(automation()->GetActiveWindow());
+ scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
+ scoped_ptr<WindowProxy> window(
+ GetAndActivateWindowForBrowser(browser.get()));
if (window.get() == NULL) {
AddErrorAttribute("active_window_not_found");
return false;
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.h b/chrome/test/automated_ui_tests/automated_ui_tests.h
index 9917b83..96475ee 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.h
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.h
@@ -121,13 +121,12 @@
// will be overwritten with the normal results. This flag is used to
// help debug the tests if they are crashing before they get a chance
// to write their results to file.
-//
-// --wait-after-action : waits the specified amount of time (1s by default)
-// after each action. Useful for debugging.
-//
#include "chrome/test/ui/ui_test.h"
+// Size of the array of possible actions to use when testing a dialog.
+const int kNumTestDialogActions = 4;
+
class AutomatedUITest : public UITest {
protected:
AutomatedUITest();
@@ -220,16 +219,6 @@ class AutomatedUITest : public UITest {
// XML element: <ImportSettings/>
bool ImportSettings();
- // Opens the Search Engines dialog. While it isn't modal, it takes focus from
- // the current browser window, so most of the test can't continue until it is
- // dismissed.
- // XML element: <EditSearchEngines/>
- bool EditSearchEngines();
-
- // Opens one of the dialogs (chosen randomly) and exercises it.
- // XML element: <Dialog/>
- bool ExerciseDialog();
-
// Opens the View Passwords dialog, this dialog is modal so a majority of
// the test can't be completed until it is dismissed.
// XML element: <ViewPasswords/>
@@ -241,34 +230,11 @@ class AutomatedUITest : public UITest {
bool ClearBrowserData();
// Opens the Task Manager dialog. While it isn't modal, it takes focus from
- // the current browser window, so most of the test can't continue until it is
+ // the current browser window, so most of the test can't continue until is
// dismissed.
// XML element: <TaskManager/>
bool TaskManager();
- // Opens the Options dialog. While it isn't modal, it takes focus from
- // the current browser window, so most of the test can't continue until it is
- // dismissed.
- // XML element: <Options/>
- bool Options();
-
- // Opens the About dialog. This dialog is modal so a majority of the test
- // can't be completed until it is dismissed.
- // XML element: <About/>
- bool About();
-
- // Opens the JavaScriptDebugger window. While it isn't modal, it takes focus
- // from the current browser window, so most of the test can't continue until
- // it is dismissed.
- // XML element: <JavaScriptDebugger/>
- bool JavaScriptDebugger();
-
- // Opens the JavaScriptConsole window. While it isn't modal, it takes focus
- // from the current browser window, so most of the test can't continue until
- // it is dismissed.
- // XML element: <JavaScriptConsole/>
- bool JavaScriptConsole();
-
// Opens and focuses an OffTheRecord browser window.
// XML element: <GoOffTheRecord/>
bool GoOffTheRecord();
@@ -328,10 +294,6 @@ class AutomatedUITest : public UITest {
// XML element: <TestTaskManager/>
bool TestTaskManager();
- // Opens Options dialog and runs random actions on it.
- // XML element: <TestOptions/>
- bool TestOptions();
-
// Opens View Passwords dialog and runs random actions on it.
// XML element: <TestViewPasswords/>
bool TestViewPasswords();
@@ -375,12 +337,11 @@ class AutomatedUITest : public UITest {
// window to the top.
WindowProxy* GetAndActivateWindowForBrowser(BrowserProxy* browser);
- // Runs the specified browser command in the current active browser.
- // See browser_commands.cc for the list of commands.
+ // Applies the accelerator with the given ID to the current active window.
// Returns true if the call is successful.
// Returns false if the active window is not a browser window or if the
// message to apply the accelerator fails.
- bool RunCommand(int browser_command);
+ bool ApplyAccelerator(int id);
// Calls SimulateOSKeyPress on the active window. Simulates a key press at
// the OS level. |key| is the key pressed and |flags| specifies which
@@ -474,8 +435,7 @@ class AutomatedUITest : public UITest {
// results.
bool debug_logging_enabled_;
- // A delay in second we wait for after each action. Useful for debugging.
- int post_action_delay_;
+ static std::string test_dialog_possible_actions_[kNumTestDialogActions];
DISALLOW_EVIL_CONSTRUCTORS(AutomatedUITest);
};