summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-09 03:28:14 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-09 03:28:14 +0000
commit145d5c9f3409ddd9619b82d5c472fcbf72877501 (patch)
tree14af5281dd899cfdd1b2e647bc9601605140054c /chrome/test
parent0a646946bcb2d40e003494ad32721d333f47382b (diff)
downloadchromium_src-145d5c9f3409ddd9619b82d5c472fcbf72877501.zip
chromium_src-145d5c9f3409ddd9619b82d5c472fcbf72877501.tar.gz
chromium_src-145d5c9f3409ddd9619b82d5c472fcbf72877501.tar.bz2
Adding a few commands to the automated UI test. It now supports:
ChangeEncoding, DuplicateTab, Home, RestoreTab, ShowBookmarksBar, ViewSource. These new commands are not used for the distributed tests/build bot tests, but hopefully that will change at some point. I also fixed an issue where we were trying to avoid hitting Enter or Space as the first thing as the dialog opens (but were instead always hitting Enter first). git-svn-id: svn://svn.chromium.org/chrome/trunk/src@621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc66
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.h33
2 files changed, 96 insertions, 3 deletions
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc
index b7aeafd..d682d9e 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -34,6 +34,7 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/character_encoding.h"
#include "chrome/browser/view_ids.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/libxml_utils.h"
@@ -76,9 +77,11 @@ 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[] = {
- "PressTabKey",
+ // See FuzzyTestDialog for details on why Enter and SpaceBar must appear first
+ // in this list.
"PressEnterKey",
"PressSpaceBar",
+ "PressTabKey",
"DownArrow"
};
@@ -281,6 +284,8 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = OpenAboutDialog();
} else if (LowerCaseEqualsASCII(action, "back")) {
did_complete_action = BackButton();
+ } else if (LowerCaseEqualsASCII(action, "changeencoding")) {
+ did_complete_action = ChangeEncoding();
} else if (LowerCaseEqualsASCII(action, "closetab")) {
did_complete_action = CloseActiveTab();
} else if (LowerCaseEqualsASCII(action, "clearbrowsingdata")) {
@@ -299,6 +304,8 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = DragActiveTab(false, true);
} else if (LowerCaseEqualsASCII(action, "dragtabright")) {
did_complete_action = DragActiveTab(true, false);
+ } else if (LowerCaseEqualsASCII(action, "duplicatetab")) {
+ did_complete_action = DuplicateTab();
} else if (LowerCaseEqualsASCII(action, "editsearchengines")) {
did_complete_action = OpenEditSearchEnginesDialog();
} else if (LowerCaseEqualsASCII(action, "findinpage")) {
@@ -309,6 +316,8 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = GoOffTheRecord();
} else if (LowerCaseEqualsASCII(action, "history")) {
did_complete_action = ShowHistory();
+ } else if (LowerCaseEqualsASCII(action, "home")) {
+ did_complete_action = Home();
} else if (LowerCaseEqualsASCII(action, "import")) {
did_complete_action = OpenImportSettingsDialog();
} else if (LowerCaseEqualsASCII(action, "javascriptconsole")) {
@@ -337,10 +346,14 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = PressTabKey();
} else if (LowerCaseEqualsASCII(action, "reload")) {
did_complete_action = ReloadPage();
+ } else if (LowerCaseEqualsASCII(action, "restoretab")) {
+ did_complete_action = RestoreTab();
} else if (LowerCaseEqualsASCII(action, "selectnexttab")) {
did_complete_action = SelectNextTab();
} else if (LowerCaseEqualsASCII(action, "selectprevtab")) {
did_complete_action = SelectPreviousTab();
+ } else if (LowerCaseEqualsASCII(action, "showbookmarks")) {
+ did_complete_action = ShowBookmarksBar();
} else if (LowerCaseEqualsASCII(action, "setup")) {
LaunchBrowserAndServer();
did_complete_action = true;
@@ -371,10 +384,15 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = PressUpArrow();
} else if (LowerCaseEqualsASCII(action, "viewpasswords")) {
did_complete_action = OpenViewPasswordsDialog();
+ } else if (LowerCaseEqualsASCII(action, "viewsource")) {
+ did_complete_action = ViewSource();
} else if (LowerCaseEqualsASCII(action, "zoomplus")) {
did_complete_action = ZoomPlus();
} else if (LowerCaseEqualsASCII(action, "zoomminus")) {
did_complete_action = ZoomMinus();
+ } else {
+ NOTREACHED() << "Unknown command passed into DoAction: "
+ << action.c_str();
}
if (!did_complete_action)
@@ -415,6 +433,25 @@ bool AutomatedUITest::BackButton() {
return RunCommand(IDC_BACK);
}
+bool AutomatedUITest::ChangeEncoding() {
+ // Get the encoding list that is used to populate the UI (encoding menu)
+ const std::vector<int>* encoding_ids =
+ CharacterEncoding::GetCurrentDisplayEncodings(
+ L"ISO-8859-1,windows-1252", L"");
+ DCHECK(encoding_ids);
+ DCHECK(!encoding_ids->empty());
+ unsigned len = static_cast<unsigned>(encoding_ids->size());
+
+ // The vector will contain mostly IDC values for encoding commands plus a few
+ // menu separators (0 values). If we hit a separator we just retry.
+ int index = rand_util::RandInt(0, len);
+ while ((*encoding_ids)[index] == 0) {
+ index = rand_util::RandInt(0, len);
+ }
+
+ return RunCommand((*encoding_ids)[index]);
+}
+
bool AutomatedUITest::CloseActiveTab() {
bool return_value = false;
scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
@@ -454,6 +491,10 @@ bool AutomatedUITest::CloseActiveTab() {
return return_value;
}
+bool AutomatedUITest::DuplicateTab() {
+ return RunCommand(IDC_DUPLICATE);
+}
+
bool AutomatedUITest::FindInPage() {
return RunCommand(IDC_FIND);
}
@@ -466,6 +507,10 @@ bool AutomatedUITest::GoOffTheRecord() {
return RunCommand(IDC_GOOFFTHERECORD);
}
+bool AutomatedUITest::Home() {
+ return RunCommand(IDC_HOME);
+}
+
bool AutomatedUITest::JavaScriptConsole() {
return RunCommand(IDC_SHOW_JS_CONSOLE);
}
@@ -592,6 +637,10 @@ bool AutomatedUITest::ReloadPage() {
return RunCommand(IDC_RELOAD);
}
+bool AutomatedUITest::RestoreTab() {
+ return RunCommand(IDC_RESTORE_TAB);
+}
+
bool AutomatedUITest::SelectNextTab() {
return RunCommand(IDC_SELECT_NEXT_TAB);
}
@@ -600,6 +649,10 @@ bool AutomatedUITest::SelectPreviousTab() {
return RunCommand(IDC_SELECT_PREV_TAB);
}
+bool AutomatedUITest::ShowBookmarksBar() {
+ return RunCommand(IDC_SHOW_BOOKMARKS_BAR);
+}
+
bool AutomatedUITest::ShowDownloads() {
return RunCommand(IDC_SHOW_DOWNLOADS);
}
@@ -612,6 +665,10 @@ bool AutomatedUITest::StarPage() {
return RunCommand(IDC_STAR);
}
+bool AutomatedUITest::ViewSource() {
+ return RunCommand(IDC_VIEWSOURCE);
+}
+
bool AutomatedUITest::ZoomMinus() {
return RunCommand(IDC_ZOOM_MINUS);
}
@@ -659,7 +716,12 @@ bool AutomatedUITest::FuzzyTestDialog(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,
+ // We want to make sure the first action performed on the dialog is not
+ // Space or Enter because focus is likely on the Close button. Both Space
+ // and Enter would close the dialog without performing more actions. We
+ // rely on the fact that those two actions are first in the array and set
+ // the lower bound to 2 if i == 0 to skip those two actions.
+ int action_index = rand_util::RandInt(i == 0 ? 2 : 0,
arraysize(kTestDialogPossibleActions)
- 1);
return_value = return_value &&
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.h b/chrome/test/automated_ui_tests/automated_ui_tests.h
index 307cba1..2a4fbf0 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.h
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.h
@@ -155,11 +155,22 @@ class AutomatedUITest : public UITest {
// XML element: <Back/>
bool BackButton();
+ // Changes the encoding of the page (the encoding is selected at random
+ // from a list of encodings).
+ // Returns true if call to activate the accelerator is successful.
+ // XML element: <ChangeEncoding/>
+ bool ChangeEncoding();
+
// Uses accelerator to close the active tab if it isn't the only tab.
// Returns false if active tab is the only tab, true otherwise.
// XML element: <CloseTab/>
bool CloseActiveTab();
+ // Duplicates the current tab.
+ // Returns true if call to activate the accelerator is successful.
+ // XML element: <DuplicateTab/>
+ bool DuplicateTab();
+
// Opens one of the dialogs (chosen randomly) and exercises it.
// XML element: <Dialog/>
bool ExerciseDialog();
@@ -177,6 +188,11 @@ class AutomatedUITest : public UITest {
// XML element: <GoOffTheRecord/>
bool GoOffTheRecord();
+ // Navigates to the Home page.
+ // Returns true if call to activate the accelerator is successful.
+ // XML element: <Home/>
+ bool Home();
+
// 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.
@@ -279,6 +295,11 @@ class AutomatedUITest : public UITest {
// XML element: <Reload/>
bool ReloadPage();
+ // Restores a previously closed tab.
+ // Returns true if call to activate the accelerator is successful.
+ // XML element: <RestoreTab/>
+ bool RestoreTab();
+
// Activates the next tab on the active browser window.
// XML element: <SelectNextTab/>
bool SelectNextTab();
@@ -287,6 +308,11 @@ class AutomatedUITest : public UITest {
// XML element: <SelectPrevTab/>
bool SelectPreviousTab();
+ // Displays the bookmark bar.
+ // Returns true if call to activate the accelerator is successful.
+ // XML element: <ShowBookmarks/>
+ bool ShowBookmarksBar();
+
// Opens the Downloads page in the current active browser window.
// XML element: <Downloads/>
bool ShowDownloads();
@@ -300,6 +326,11 @@ class AutomatedUITest : public UITest {
// XML element: <Star/>
bool StarPage();
+ // Views source of the current page.
+ // Returns true if call to activate the accelerator is successful.
+ // XML element: <ViewSource/>
+ bool ViewSource();
+
// Decreases the text size on the current active tab.
// XML element: <ZoomMinus/>
bool ZoomMinus();
@@ -480,7 +511,7 @@ class AutomatedUITest : public UITest {
// A delay in second we wait for after each action. Useful for debugging.
int post_action_delay_;
- DISALLOW_EVIL_CONSTRUCTORS(AutomatedUITest);
+ DISALLOW_COPY_AND_ASSIGN(AutomatedUITest);
};
#endif // CHROME_TEST_AUTOMATED_UI_TESTS_AUTOMATED_UI_TESTS_H_