OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 "chrome/browser/ui/webui/options/options_ui_uitest.h" | |
6 | |
7 #include "base/string16.h" | |
8 #include "base/utf_string_conversions.h" | |
9 #include "chrome/common/url_constants.h" | |
10 #include "chrome/test/automation/automation_proxy.h" | |
11 #include "chrome/test/automation/browser_proxy.h" | |
12 #include "chrome/test/automation/tab_proxy.h" | |
13 #include "grit/generated_resources.h" | |
14 #include "ui/base/l10n/l10n_util.h" | |
15 | |
16 OptionsUITest::OptionsUITest() { | |
17 dom_automation_enabled_ = true; | |
18 } | |
19 | |
20 void OptionsUITest::NavigateToSettings(scoped_refptr<TabProxy> tab) { | |
21 const GURL& url = GURL(chrome::kChromeUISettingsURL); | |
22 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | |
23 tab->NavigateToURLBlockUntilNavigationsComplete(url, 1)) << url.spec(); | |
24 } | |
25 | |
26 void OptionsUITest::VerifyNavbar(scoped_refptr<TabProxy> tab) { | |
27 bool navbar_exist = false; | |
28 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", | |
29 L"domAutomationController.send(" | |
30 L"!!document.getElementById('navbar'))", &navbar_exist)); | |
31 EXPECT_EQ(true, navbar_exist); | |
32 } | |
33 | |
34 void OptionsUITest::VerifyTitle(scoped_refptr<TabProxy> tab) { | |
35 std::wstring title; | |
36 EXPECT_TRUE(tab->GetTabTitle(&title)); | |
37 string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); | |
38 EXPECT_NE(WideToUTF16Hack(title).find(expected_title), string16::npos); | |
39 } | |
40 | |
41 void OptionsUITest::VerifySections(scoped_refptr<TabProxy> tab) { | |
42 #if defined(OS_CHROMEOS) | |
43 const int kExpectedSections = 1 + 7; | |
44 #else | |
45 const int kExpectedSections = 1 + 4; | |
46 #endif | |
47 int num_of_sections = 0; | |
48 EXPECT_TRUE(tab->ExecuteAndExtractInt(L"", | |
49 L"domAutomationController.send(" | |
50 L"document.getElementById('navbar').children.length)", &num_of_sections)); | |
51 EXPECT_EQ(kExpectedSections, num_of_sections); | |
52 } | |
53 | |
54 TEST_F(OptionsUITest, LoadOptionsByURL) { | |
55 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
56 ASSERT_TRUE(browser.get()); | |
57 | |
58 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); | |
59 ASSERT_TRUE(tab.get()); | |
60 | |
61 NavigateToSettings(tab); | |
62 VerifyTitle(tab); | |
63 VerifyNavbar(tab); | |
64 VerifySections(tab); | |
65 } | |
OLD | NEW |