Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: chrome/browser/dom_ui/options_ui_uitest.cc

Issue 2848012: Add basic UI tests for dom_ui/options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "chrome/app/chrome_dll_resource.h"
7 #include "chrome/common/chrome_switches.h"
8 #include "chrome/common/url_constants.h"
9 #include "chrome/test/automation/browser_proxy.h"
10 #include "chrome/test/automation/tab_proxy.h"
11 #include "chrome/test/automation/window_proxy.h"
12 #include "chrome/test/ui/ui_test.h"
13
14 namespace {
15
16 class OptionsUITest : public UITest {
17 public:
18 OptionsUITest() {
19 dom_automation_enabled_ = true;
20 // TODO(csilv): Remove when dom-ui options is enabled by default.
21 launch_arguments_.AppendSwitch(switches::kEnableTabbedOptions);
22 }
23
24 void AssertIsOptionsPage(TabProxy* tab) {
25 std::wstring title;
26 ASSERT_TRUE(tab->GetTabTitle(&title));
27 ASSERT_EQ(L"Chromium Options", title);
28 }
29 };
30
31 TEST_F(OptionsUITest, LoadOptionsByURL) {
32 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
33 ASSERT_TRUE(browser.get());
34
35 scoped_refptr<TabProxy> tab = browser->GetActiveTab();
36 ASSERT_TRUE(tab.get());
37
38 // Go to the options tab via URL.
39 NavigateToURL(GURL(chrome::kChromeUIOptionsURL));
40 AssertIsOptionsPage(tab);
41 }
42
43 TEST_F(OptionsUITest, CommandOpensOptionsTab) {
44 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
45 ASSERT_TRUE(browser.get());
46
47 int tab_count = -1;
48 ASSERT_TRUE(browser->GetTabCount(&tab_count));
49 ASSERT_EQ(1, tab_count);
50
51 // Bring up the options tab via command.
52 ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
53 ASSERT_TRUE(browser->GetTabCount(&tab_count));
54 ASSERT_EQ(2, tab_count);
55
56 scoped_refptr<TabProxy> tab = browser->GetActiveTab();
57 ASSERT_TRUE(tab.get());
58 AssertIsOptionsPage(tab);
59 }
60
61 TEST_F(OptionsUITest, CommandAgainGoesBackToOptionsTab) {
62 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
63 ASSERT_TRUE(browser.get());
64
65 int tab_count = -1;
66 ASSERT_TRUE(browser->GetTabCount(&tab_count));
67 ASSERT_EQ(1, tab_count);
68
69 // Bring up the options tab via command.
70 ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
71 ASSERT_TRUE(browser->GetTabCount(&tab_count));
72 ASSERT_EQ(2, tab_count);
73
74 scoped_refptr<TabProxy> tab = browser->GetActiveTab();
75 ASSERT_TRUE(tab.get());
76 AssertIsOptionsPage(tab);
77
78 // Switch to first tab and run command again.
79 ASSERT_TRUE(browser->ActivateTab(0));
80 ASSERT_TRUE(browser->WaitForTabToBecomeActive(0, action_max_timeout_ms()));
81 ASSERT_TRUE(browser->RunCommandAsync(IDC_OPTIONS));
82
83 // Ensure the options ui tab is active.
84 ASSERT_TRUE(browser->WaitForTabToBecomeActive(1, action_max_timeout_ms()));
85 ASSERT_TRUE(browser->GetTabCount(&tab_count));
86 ASSERT_EQ(2, tab_count);
87 }
88
89 TEST_F(OptionsUITest, TwoCommandsOneTab) {
90 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
91 ASSERT_TRUE(browser.get());
92
93 int tab_count = -1;
94 ASSERT_TRUE(browser->GetTabCount(&tab_count));
95 ASSERT_EQ(1, tab_count);
96
97 ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
98 ASSERT_TRUE(browser->RunCommandAsync(IDC_OPTIONS));
99 ASSERT_TRUE(browser->GetTabCount(&tab_count));
100 ASSERT_EQ(2, tab_count);
101 }
102
103 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698