| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/options2/options_ui2_browsertest.h" | 5 #include "chrome/browser/ui/webui/options2/options_ui2_browsertest.h" |
| 6 | 6 |
| 7 #include "base/string16.h" | 7 #include "base/string16.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
| 12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 namespace options2 { | 16 namespace options2 { |
| 17 | 17 |
| 18 OptionsBrowserTest::OptionsBrowserTest() { | 18 OptionsBrowserTest::OptionsBrowserTest() { |
| 19 EnableDOMAutomation(); | 19 EnableDOMAutomation(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void OptionsBrowserTest::NavigateToSettings() { | 22 void OptionsBrowserTest::NavigateToSettings() { |
| 23 const GURL& url = GURL(chrome::kChromeUISettingsURL); | 23 const GURL& url = GURL(chrome::kChromeUISettingsURL); |
| 24 ui_test_utils::NavigateToURL(browser(), url); | 24 ui_test_utils::NavigateToURL(browser(), url); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void OptionsBrowserTest::VerifyNavbar() { | 27 void OptionsBrowserTest::VerifyNavbar() { |
| 28 bool navbar_exist = false; | 28 bool navbar_exist = false; |
| 29 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 29 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 30 browser()->GetSelectedWebContents()->GetRenderViewHost(), | 30 browser()->GetActiveWebContents()->GetRenderViewHost(), |
| 31 L"", | 31 L"", |
| 32 L"domAutomationController.send(" | 32 L"domAutomationController.send(" |
| 33 L"!!document.getElementById('navigation'))", &navbar_exist)); | 33 L"!!document.getElementById('navigation'))", &navbar_exist)); |
| 34 EXPECT_EQ(true, navbar_exist); | 34 EXPECT_EQ(true, navbar_exist); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void OptionsBrowserTest::VerifyTitle() { | 37 void OptionsBrowserTest::VerifyTitle() { |
| 38 string16 title = browser()->GetSelectedWebContents()->GetTitle(); | 38 string16 title = browser()->GetActiveWebContents()->GetTitle(); |
| 39 string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); | 39 string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); |
| 40 EXPECT_NE(title.find(expected_title), string16::npos); | 40 EXPECT_NE(title.find(expected_title), string16::npos); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Flaky, see http://crbug.com/119671. | 43 // Flaky, see http://crbug.com/119671. |
| 44 IN_PROC_BROWSER_TEST_F(OptionsBrowserTest, FLAKY_LoadOptionsByURL) { | 44 IN_PROC_BROWSER_TEST_F(OptionsBrowserTest, FLAKY_LoadOptionsByURL) { |
| 45 NavigateToSettings(); | 45 NavigateToSettings(); |
| 46 VerifyTitle(); | 46 VerifyTitle(); |
| 47 VerifyNavbar(); | 47 VerifyNavbar(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace options2 | 50 } // namespace options2 |
| OLD | NEW |