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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 controller = static_cast<UberUI*>(controller)-> | 127 controller = static_cast<UberUI*>(controller)-> |
128 GetSubpage(chrome::kChromeUISettingsFrameURL)->GetController(); | 128 GetSubpage(chrome::kChromeUISettingsFrameURL)->GetController(); |
129 #endif | 129 #endif |
130 OptionsUI* options_ui = static_cast<OptionsUI*>(controller); | 130 OptionsUI* options_ui = static_cast<OptionsUI*>(controller); |
131 | 131 |
132 // It is not possible to subscribe to the OnFinishedLoading event before the | 132 // It is not possible to subscribe to the OnFinishedLoading event before the |
133 // call to NavigateToURL(), because the WebUI does not yet exist at that time. | 133 // call to NavigateToURL(), because the WebUI does not yet exist at that time. |
134 // However, it is safe to subscribe afterwards, because the event will always | 134 // However, it is safe to subscribe afterwards, because the event will always |
135 // be posted asynchronously to the message loop. | 135 // be posted asynchronously to the message loop. |
136 scoped_refptr<MessageLoopRunner> message_loop_runner(new MessageLoopRunner); | 136 scoped_refptr<MessageLoopRunner> message_loop_runner(new MessageLoopRunner); |
137 scoped_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> | 137 std::unique_ptr<OptionsUI::OnFinishedLoadingCallbackList::Subscription> |
138 subscription = options_ui->RegisterOnFinishedLoadingCallback( | 138 subscription = options_ui->RegisterOnFinishedLoadingCallback( |
139 message_loop_runner->QuitClosure()); | 139 message_loop_runner->QuitClosure()); |
140 message_loop_runner->Run(); | 140 message_loop_runner->Run(); |
141 | 141 |
142 // The OnFinishedLoading event, which indicates that all WebUI initialization | 142 // The OnFinishedLoading event, which indicates that all WebUI initialization |
143 // methods have been called on the JS side, is temporally unrelated to whether | 143 // methods have been called on the JS side, is temporally unrelated to whether |
144 // or not the WebContents considers itself to have finished loading. We want | 144 // or not the WebContents considers itself to have finished loading. We want |
145 // to wait for this too, however, because, e.g. this is a sufficient condition | 145 // to wait for this too, however, because, e.g. this is a sufficient condition |
146 // to get the focus properly placed on a form element. | 146 // to get the focus properly placed on a form element. |
147 content::WaitForLoadStop(web_contents); | 147 content::WaitForLoadStop(web_contents); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 run_loop.Run(); | 328 run_loop.Run(); |
329 | 329 |
330 // Verify that the settings page has updated and lists two profiles. | 330 // Verify that the settings page has updated and lists two profiles. |
331 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 331 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
332 contents, javascript, &profiles)); | 332 contents, javascript, &profiles)); |
333 EXPECT_EQ(2, profiles); | 333 EXPECT_EQ(2, profiles); |
334 } | 334 } |
335 #endif | 335 #endif |
336 | 336 |
337 } // namespace options | 337 } // namespace options |
OLD | NEW |