diff options
author | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 00:07:21 +0000 |
---|---|---|
committer | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 00:07:21 +0000 |
commit | d067bf8a255b5d032bec58a7d64544f6c1133ad9 (patch) | |
tree | e2380bf2ae3170c92f31d1e6cc7ab9b5615f43ac /chrome | |
parent | 3915295a2bcfd1c8f72cd5bf4c5c23fb8bc87789 (diff) | |
download | chromium_src-d067bf8a255b5d032bec58a7d64544f6c1133ad9.zip chromium_src-d067bf8a255b5d032bec58a7d64544f6c1133ad9.tar.gz chromium_src-d067bf8a255b5d032bec58a7d64544f6c1133ad9.tar.bz2 |
Add basic UI tests for dom_ui/options.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2848012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50672 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 1 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options_ui_uitest.cc | 103 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 |
3 files changed, 105 insertions, 0 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 0aa6488..a59e8d1 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -682,6 +682,7 @@ const struct CommandNotification command_notifications[] = { // For the following commands, we need to wait for a new tab to be created, // load to finish, and title to change. {IDC_MANAGE_EXTENSIONS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, + {IDC_OPTIONS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, {IDC_SHOW_DOWNLOADS, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, {IDC_SHOW_HISTORY, NotificationType::TAB_CONTENTS_TITLE_UPDATED}, }; diff --git a/chrome/browser/dom_ui/options_ui_uitest.cc b/chrome/browser/dom_ui/options_ui_uitest.cc new file mode 100644 index 0000000..546d258 --- /dev/null +++ b/chrome/browser/dom_ui/options_ui_uitest.cc @@ -0,0 +1,103 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/command_line.h" +#include "chrome/app/chrome_dll_resource.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/url_constants.h" +#include "chrome/test/automation/browser_proxy.h" +#include "chrome/test/automation/tab_proxy.h" +#include "chrome/test/automation/window_proxy.h" +#include "chrome/test/ui/ui_test.h" + +namespace { + +class OptionsUITest : public UITest { + public: + OptionsUITest() { + dom_automation_enabled_ = true; + // TODO(csilv): Remove when dom-ui options is enabled by default. + launch_arguments_.AppendSwitch(switches::kEnableTabbedOptions); + } + + void AssertIsOptionsPage(TabProxy* tab) { + std::wstring title; + ASSERT_TRUE(tab->GetTabTitle(&title)); + ASSERT_EQ(L"Chromium Options", title); + } +}; + +TEST_F(OptionsUITest, LoadOptionsByURL) { + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + + scoped_refptr<TabProxy> tab = browser->GetActiveTab(); + ASSERT_TRUE(tab.get()); + + // Go to the options tab via URL. + NavigateToURL(GURL(chrome::kChromeUIOptionsURL)); + AssertIsOptionsPage(tab); +} + +TEST_F(OptionsUITest, CommandOpensOptionsTab) { + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + + int tab_count = -1; + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(1, tab_count); + + // Bring up the options tab via command. + ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS)); + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(2, tab_count); + + scoped_refptr<TabProxy> tab = browser->GetActiveTab(); + ASSERT_TRUE(tab.get()); + AssertIsOptionsPage(tab); +} + +TEST_F(OptionsUITest, CommandAgainGoesBackToOptionsTab) { + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + + int tab_count = -1; + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(1, tab_count); + + // Bring up the options tab via command. + ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS)); + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(2, tab_count); + + scoped_refptr<TabProxy> tab = browser->GetActiveTab(); + ASSERT_TRUE(tab.get()); + AssertIsOptionsPage(tab); + + // Switch to first tab and run command again. + ASSERT_TRUE(browser->ActivateTab(0)); + ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms())); + ASSERT_TRUE(browser->RunCommandAsync(IDC_OPTIONS)); + + // Ensure the options ui tab is active. + ASSERT_TRUE(browser->WaitForTabToBecomeActive(1, action_max_timeout_ms())); + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(2, tab_count); +} + +TEST_F(OptionsUITest, TwoCommandsOneTab) { + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + + int tab_count = -1; + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(1, tab_count); + + ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS)); + ASSERT_TRUE(browser->RunCommandAsync(IDC_OPTIONS)); + ASSERT_TRUE(browser->GetTabCount(&tab_count)); + ASSERT_EQ(2, tab_count); +} + +} // namespace diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 562ff9b..4e1fcb1 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -303,6 +303,7 @@ 'browser/cookie_modal_dialog_uitest.cc', 'browser/dom_ui/bookmarks_ui_uitest.cc', 'browser/dom_ui/new_tab_ui_uitest.cc', + 'browser/dom_ui/options_ui_uitest.cc', 'browser/download/download_uitest.cc', 'browser/download/save_page_uitest.cc', 'browser/errorpage_uitest.cc', |