| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/login/screen_locker_tester.h" | 5 #include "chrome/browser/chromeos/login/screen_locker_tester.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 13 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
| 14 #include "chrome/browser/chromeos/login/mock_authenticator.h" | 14 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
| 15 #include "chrome/browser/chromeos/login/screen_locker.h" | 15 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 16 #include "chrome/browser/chromeos/login/webui_screen_locker.h" | 16 #include "chrome/browser/chromeos/login/webui_screen_locker.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "content/browser/renderer_host/render_view_host.h" | 18 #include "content/browser/renderer_host/render_view_host.h" |
| 19 #include "content/browser/tab_contents/tab_contents.h" | |
| 20 #include "content/browser/webui/web_ui.h" | 19 #include "content/browser/webui/web_ui.h" |
| 20 #include "content/public/browser/web_contents.h" |
| 21 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
| 22 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
| 23 #include "ui/views/controls/textfield/textfield.h" | 23 #include "ui/views/controls/textfield/textfield.h" |
| 24 #include "ui/views/events/event.h" | 24 #include "ui/views/events/event.h" |
| 25 #include "ui/views/widget/root_view.h" | 25 #include "ui/views/widget/root_view.h" |
| 26 | 26 |
| 27 | 27 |
| 28 #if defined(TOOLKIT_USES_GTK) | 28 #if defined(TOOLKIT_USES_GTK) |
| 29 #include "chrome/browser/chromeos/login/lock_window_gtk.h" | 29 #include "chrome/browser/chromeos/login/lock_window_gtk.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 using content::WebContents; |
| 33 |
| 32 namespace { | 34 namespace { |
| 33 | 35 |
| 34 class LoginAttemptObserver : public chromeos::LoginStatusConsumer { | 36 class LoginAttemptObserver : public chromeos::LoginStatusConsumer { |
| 35 public: | 37 public: |
| 36 explicit LoginAttemptObserver(chromeos::ScreenLocker* locker); | 38 explicit LoginAttemptObserver(chromeos::ScreenLocker* locker); |
| 37 virtual ~LoginAttemptObserver(); | 39 virtual ~LoginAttemptObserver(); |
| 38 | 40 |
| 39 void WaitForAttempt(); | 41 void WaitForAttempt(); |
| 40 | 42 |
| 41 // Overridden from LoginStatusConsumer: | 43 // Overridden from LoginStatusConsumer: |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 views::Widget* WebUIScreenLockerTester::GetWidget() const { | 163 views::Widget* WebUIScreenLockerTester::GetWidget() const { |
| 162 return webui_screen_locker()->lock_window_; | 164 return webui_screen_locker()->lock_window_; |
| 163 } | 165 } |
| 164 | 166 |
| 165 views::Widget* WebUIScreenLockerTester::GetChildWidget() const { | 167 views::Widget* WebUIScreenLockerTester::GetChildWidget() const { |
| 166 return webui_screen_locker()->lock_window_; | 168 return webui_screen_locker()->lock_window_; |
| 167 } | 169 } |
| 168 | 170 |
| 169 base::Value* WebUIScreenLockerTester::ExecuteJavascriptAndGetValue( | 171 base::Value* WebUIScreenLockerTester::ExecuteJavascriptAndGetValue( |
| 170 const std::string& js_text) { | 172 const std::string& js_text) { |
| 171 RenderViewHost* rvh = webui()->tab_contents()->GetRenderViewHost(); | 173 RenderViewHost* rvh = webui()->web_contents()->GetRenderViewHost(); |
| 172 return rvh->ExecuteJavascriptAndGetValue(string16(), | 174 return rvh->ExecuteJavascriptAndGetValue(string16(), |
| 173 ASCIIToUTF16(js_text)); | 175 ASCIIToUTF16(js_text)); |
| 174 } | 176 } |
| 175 | 177 |
| 176 WebUIScreenLocker* WebUIScreenLockerTester::webui_screen_locker() const { | 178 WebUIScreenLocker* WebUIScreenLockerTester::webui_screen_locker() const { |
| 177 DCHECK(ScreenLocker::screen_locker_); | 179 DCHECK(ScreenLocker::screen_locker_); |
| 178 return static_cast<WebUIScreenLocker*>( | 180 return static_cast<WebUIScreenLocker*>( |
| 179 ScreenLocker::screen_locker_->delegate_.get()); | 181 ScreenLocker::screen_locker_->delegate_.get()); |
| 180 } | 182 } |
| 181 | 183 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 204 new MockAuthenticator(ScreenLocker::screen_locker_, user, password)); | 206 new MockAuthenticator(ScreenLocker::screen_locker_, user, password)); |
| 205 } | 207 } |
| 206 | 208 |
| 207 } // namespace test | 209 } // namespace test |
| 208 | 210 |
| 209 test::ScreenLockerTester* ScreenLocker::GetTester() { | 211 test::ScreenLockerTester* ScreenLocker::GetTester() { |
| 210 return new test::WebUIScreenLockerTester(); | 212 return new test::WebUIScreenLockerTester(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 } // namespace chromeos | 215 } // namespace chromeos |
| OLD | NEW |