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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 void OptionsUIBrowserTest::NavigateToSettingsSubpage( | 110 void OptionsUIBrowserTest::NavigateToSettingsSubpage( |
111 const std::string& sub_page) { | 111 const std::string& sub_page) { |
112 const GURL& url = chrome::GetSettingsUrl(sub_page); | 112 const GURL& url = chrome::GetSettingsUrl(sub_page); |
113 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, 0); | 113 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, 0); |
114 | 114 |
115 content::WebContents* web_contents = | 115 content::WebContents* web_contents = |
116 browser()->tab_strip_model()->GetActiveWebContents(); | 116 browser()->tab_strip_model()->GetActiveWebContents(); |
117 ASSERT_TRUE(web_contents); | 117 ASSERT_TRUE(web_contents); |
118 ASSERT_TRUE(web_contents->GetWebUI()); | 118 ASSERT_TRUE(web_contents->GetWebUI()); |
119 UberUI* uber_ui = static_cast<UberUI*>( | 119 |
120 web_contents->GetWebUI()->GetController()); | 120 content::WebUIController* controller = |
121 OptionsUI* options_ui = static_cast<OptionsUI*>( | 121 web_contents->GetWebUI()->GetController(); |
122 uber_ui->GetSubpage(chrome::kChromeUISettingsFrameURL)->GetController()); | 122 #if !defined(OS_CHROMEOS) |
| 123 controller = static_cast<UberUI*>(controller)-> |
| 124 GetSubpage(chrome::kChromeUISettingsFrameURL)->GetController(); |
| 125 #endif |
| 126 OptionsUI* options_ui = static_cast<OptionsUI*>(controller); |
123 | 127 |
124 // It is not possible to subscribe to the OnFinishedLoading event before the | 128 // It is not possible to subscribe to the OnFinishedLoading event before the |
125 // call to NavigateToURL(), because the WebUI does not yet exist at that time. | 129 // call to NavigateToURL(), because the WebUI does not yet exist at that time. |
126 // However, it is safe to subscribe afterwards, because the event will always | 130 // However, it is safe to subscribe afterwards, because the event will always |
127 // be posted asynchronously to the message loop. | 131 // be posted asynchronously to the message loop. |
128 scoped_refptr<MessageLoopRunner> message_loop_runner(new MessageLoopRunner); | 132 scoped_refptr<MessageLoopRunner> message_loop_runner(new MessageLoopRunner); |
129 scoped_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> | 133 scoped_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> |
130 subscription = options_ui->RegisterOnFinishedLoadingCallback( | 134 subscription = options_ui->RegisterOnFinishedLoadingCallback( |
131 message_loop_runner->QuitClosure()); | 135 message_loop_runner->QuitClosure()); |
132 message_loop_runner->Run(); | 136 message_loop_runner->Run(); |
133 | 137 |
134 // The OnFinishedLoading event, which indicates that all WebUI initialization | 138 // The OnFinishedLoading event, which indicates that all WebUI initialization |
135 // methods have been called on the JS side, is temporally unrelated to whether | 139 // methods have been called on the JS side, is temporally unrelated to whether |
136 // or not the WebContents considers itself to have finished loading. We want | 140 // or not the WebContents considers itself to have finished loading. We want |
137 // to wait for this too, however, because, e.g. this is a sufficient condition | 141 // to wait for this too, however, because, e.g. this is a sufficient condition |
138 // to get the focus properly placed on a form element. | 142 // to get the focus properly placed on a form element. |
139 content::WaitForLoadStop(web_contents); | 143 content::WaitForLoadStop(web_contents); |
140 } | 144 } |
141 | 145 |
142 void OptionsUIBrowserTest::NavigateToSettingsFrame() { | 146 void OptionsUIBrowserTest::NavigateToSettingsFrame() { |
143 const GURL& url = GURL(chrome::kChromeUISettingsFrameURL); | 147 const GURL& url = GURL(chrome::kChromeUISettingsFrameURL); |
144 ui_test_utils::NavigateToURL(browser(), url); | 148 ui_test_utils::NavigateToURL(browser(), url); |
145 } | 149 } |
146 | 150 |
147 void OptionsUIBrowserTest::VerifyNavbar() { | 151 void OptionsUIBrowserTest::VerifyNavbar() { |
148 bool navbar_exist = false; | 152 bool navbar_exist = false; |
| 153 #if defined(OS_CHROMEOS) |
| 154 bool should_navbar_exist = false; |
| 155 #else |
| 156 bool should_navbar_exist = true; |
| 157 #endif |
149 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 158 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
150 browser()->tab_strip_model()->GetActiveWebContents(), | 159 browser()->tab_strip_model()->GetActiveWebContents(), |
151 "domAutomationController.send(" | 160 "domAutomationController.send(" |
152 " !!document.getElementById('navigation'))", | 161 " !!document.getElementById('navigation'))", |
153 &navbar_exist)); | 162 &navbar_exist)); |
154 EXPECT_EQ(true, navbar_exist); | 163 EXPECT_EQ(should_navbar_exist, navbar_exist); |
155 } | 164 } |
156 | 165 |
157 void OptionsUIBrowserTest::VerifyTitle() { | 166 void OptionsUIBrowserTest::VerifyTitle() { |
158 base::string16 title = | 167 base::string16 title = |
159 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle(); | 168 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle(); |
160 base::string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); | 169 base::string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); |
161 EXPECT_NE(title.find(expected_title), base::string16::npos); | 170 EXPECT_NE(title.find(expected_title), base::string16::npos); |
162 } | 171 } |
163 | 172 |
164 content::RenderFrameHost* OptionsUIBrowserTest::GetSettingsFrame() { | 173 content::RenderFrameHost* OptionsUIBrowserTest::GetSettingsFrame() { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 run_loop.Run(); | 330 run_loop.Run(); |
322 | 331 |
323 // Verify that the settings page has updated and lists two profiles. | 332 // Verify that the settings page has updated and lists two profiles. |
324 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 333 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
325 contents, javascript, &profiles)); | 334 contents, javascript, &profiles)); |
326 EXPECT_EQ(2, profiles); | 335 EXPECT_EQ(2, profiles); |
327 } | 336 } |
328 #endif | 337 #endif |
329 | 338 |
330 } // namespace options | 339 } // namespace options |
OLD | NEW |