| 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/options/options_ui_browsertest.h" | 5 #include "chrome/browser/ui/webui/options/options_ui_browsertest.h" |
| 6 | 6 |
| 7 #include "base/scoped_observer.h" | 7 #include "base/scoped_observer.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 OptionsUIBrowserTest::OptionsUIBrowserTest() { | 107 OptionsUIBrowserTest::OptionsUIBrowserTest() { |
| 108 } | 108 } |
| 109 | 109 |
| 110 void OptionsUIBrowserTest::NavigateToSettings() { | 110 void OptionsUIBrowserTest::NavigateToSettings() { |
| 111 NavigateToSettingsSubpage(""); | 111 NavigateToSettingsSubpage(""); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void OptionsUIBrowserTest::NavigateToSettingsSubpage( | 114 void OptionsUIBrowserTest::NavigateToSettingsSubpage( |
| 115 const std::string& sub_page) { | 115 const std::string& sub_page) { |
| 116 const GURL& url = chrome::GetSettingsUrl(sub_page); | 116 const GURL& url = chrome::GetSettingsUrl(sub_page); |
| 117 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, 0); | 117 ui_test_utils::NavigateToURLWithDisposition( |
| 118 browser(), url, WindowOpenDisposition::CURRENT_TAB, 0); |
| 118 | 119 |
| 119 content::WebContents* web_contents = | 120 content::WebContents* web_contents = |
| 120 browser()->tab_strip_model()->GetActiveWebContents(); | 121 browser()->tab_strip_model()->GetActiveWebContents(); |
| 121 ASSERT_TRUE(web_contents); | 122 ASSERT_TRUE(web_contents); |
| 122 ASSERT_TRUE(web_contents->GetWebUI()); | 123 ASSERT_TRUE(web_contents->GetWebUI()); |
| 123 | 124 |
| 124 content::WebUIController* controller = | 125 content::WebUIController* controller = |
| 125 web_contents->GetWebUI()->GetController(); | 126 web_contents->GetWebUI()->GetController(); |
| 126 #if !defined(OS_CHROMEOS) | 127 #if !defined(OS_CHROMEOS) |
| 127 controller = static_cast<UberUI*>(controller)-> | 128 controller = static_cast<UberUI*>(controller)-> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 NavigateToSettingsFrame(); | 293 NavigateToSettingsFrame(); |
| 293 | 294 |
| 294 // Click a button that opens an overlay dialog. | 295 // Click a button that opens an overlay dialog. |
| 295 content::WebContents* contents = | 296 content::WebContents* contents = |
| 296 browser()->tab_strip_model()->GetActiveWebContents(); | 297 browser()->tab_strip_model()->GetActiveWebContents(); |
| 297 ASSERT_TRUE(content::ExecuteScript( | 298 ASSERT_TRUE(content::ExecuteScript( |
| 298 contents, "$('manage-default-search-engines').click();")); | 299 contents, "$('manage-default-search-engines').click();")); |
| 299 | 300 |
| 300 // Go back to the settings page. | 301 // Go back to the settings page. |
| 301 content::TestNavigationObserver observer(contents); | 302 content::TestNavigationObserver observer(contents); |
| 302 chrome::GoBack(browser(), CURRENT_TAB); | 303 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 303 observer.Wait(); | 304 observer.Wait(); |
| 304 | 305 |
| 305 // Verify that the settings page lists one profile. | 306 // Verify that the settings page lists one profile. |
| 306 const char javascript[] = | 307 const char javascript[] = |
| 307 "domAutomationController.send(" | 308 "domAutomationController.send(" |
| 308 " document.querySelectorAll('list#profiles-list > div[role=listitem]')" | 309 " document.querySelectorAll('list#profiles-list > div[role=listitem]')" |
| 309 " .length);"; | 310 " .length);"; |
| 310 int profiles; | 311 int profiles; |
| 311 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 312 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 312 contents, javascript, &profiles)); | 313 contents, javascript, &profiles)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 328 run_loop.Run(); | 329 run_loop.Run(); |
| 329 | 330 |
| 330 // Verify that the settings page has updated and lists two profiles. | 331 // Verify that the settings page has updated and lists two profiles. |
| 331 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 332 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 332 contents, javascript, &profiles)); | 333 contents, javascript, &profiles)); |
| 333 EXPECT_EQ(2, profiles); | 334 EXPECT_EQ(2, profiles); |
| 334 } | 335 } |
| 335 #endif | 336 #endif |
| 336 | 337 |
| 337 } // namespace options | 338 } // namespace options |
| OLD | NEW |