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

Side by Side Diff: chrome/browser/ui/webui/options/options_ui_browsertest.cc

Issue 449623003: Integrate About page into Settings for Chrome OS settings in a window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: About in Settings Created 6 years, 4 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
OLDNEW
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
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 bool should_navbar_exist;
154 #if defined(OS_CHROMEOS)
155 should_navbar_exist = false;
156 #else
157 should_navbar_exist = true;
158 #endif
Dan Beam 2014/08/07 22:36:16 #if defined(OS_CHROMEOS) bool should_navbar_exis
michaelpg 2014/08/08 01:10:46 Done.
149 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 159 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
150 browser()->tab_strip_model()->GetActiveWebContents(), 160 browser()->tab_strip_model()->GetActiveWebContents(),
151 "domAutomationController.send(" 161 "domAutomationController.send("
152 " !!document.getElementById('navigation'))", 162 " !!document.getElementById('navigation'))",
153 &navbar_exist)); 163 &navbar_exist));
154 EXPECT_EQ(true, navbar_exist); 164 EXPECT_EQ(should_navbar_exist, navbar_exist);
155 } 165 }
156 166
157 void OptionsUIBrowserTest::VerifyTitle() { 167 void OptionsUIBrowserTest::VerifyTitle() {
158 base::string16 title = 168 base::string16 title =
159 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle(); 169 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle();
160 base::string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE); 170 base::string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE);
161 EXPECT_NE(title.find(expected_title), base::string16::npos); 171 EXPECT_NE(title.find(expected_title), base::string16::npos);
162 } 172 }
163 173
164 content::RenderFrameHost* OptionsUIBrowserTest::GetSettingsFrame() { 174 content::RenderFrameHost* OptionsUIBrowserTest::GetSettingsFrame() {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 run_loop.Run(); 331 run_loop.Run();
322 332
323 // Verify that the settings page has updated and lists two profiles. 333 // Verify that the settings page has updated and lists two profiles.
324 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( 334 ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
325 contents, javascript, &profiles)); 335 contents, javascript, &profiles));
326 EXPECT_EQ(2, profiles); 336 EXPECT_EQ(2, profiles);
327 } 337 }
328 #endif 338 #endif
329 339
330 } // namespace options 340 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698