OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/lock/screen_locker_tester.h" | 5 #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 void WebUIScreenLockerTester::SetPassword(const std::string& password) { | 121 void WebUIScreenLockerTester::SetPassword(const std::string& password) { |
122 webui()->GetWebContents()->GetMainFrame()->ExecuteJavaScriptForTests( | 122 webui()->GetWebContents()->GetMainFrame()->ExecuteJavaScriptForTests( |
123 base::ASCIIToUTF16(base::StringPrintf( | 123 base::ASCIIToUTF16(base::StringPrintf( |
124 "$('pod-row').pods[0].passwordElement.value = '%s';", | 124 "$('pod-row').pods[0].passwordElement.value = '%s';", |
125 password.c_str()))); | 125 password.c_str()))); |
126 } | 126 } |
127 | 127 |
128 std::string WebUIScreenLockerTester::GetPassword() { | 128 std::string WebUIScreenLockerTester::GetPassword() { |
129 std::string result; | 129 std::string result; |
130 scoped_ptr<base::Value> v = content::ExecuteScriptAndGetValue( | 130 std::unique_ptr<base::Value> v = content::ExecuteScriptAndGetValue( |
131 RenderViewHost()->GetMainFrame(), | 131 RenderViewHost()->GetMainFrame(), |
132 "$('pod-row').pods[0].passwordElement.value;"); | 132 "$('pod-row').pods[0].passwordElement.value;"); |
133 CHECK(v->GetAsString(&result)); | 133 CHECK(v->GetAsString(&result)); |
134 return result; | 134 return result; |
135 } | 135 } |
136 | 136 |
137 void WebUIScreenLockerTester::EnterPassword(const std::string& password) { | 137 void WebUIScreenLockerTester::EnterPassword(const std::string& password) { |
138 bool result; | 138 bool result; |
139 SetPassword(password); | 139 SetPassword(password); |
140 | 140 |
141 // Verify password is set. | 141 // Verify password is set. |
142 ASSERT_EQ(password, GetPassword()); | 142 ASSERT_EQ(password, GetPassword()); |
143 | 143 |
144 // Verify that "reauth" warning is hidden. | 144 // Verify that "reauth" warning is hidden. |
145 scoped_ptr<base::Value> v = content::ExecuteScriptAndGetValue( | 145 std::unique_ptr<base::Value> v = content::ExecuteScriptAndGetValue( |
146 RenderViewHost()->GetMainFrame(), | 146 RenderViewHost()->GetMainFrame(), |
147 "window.getComputedStyle(" | 147 "window.getComputedStyle(" |
148 " $('pod-row').pods[0].querySelector('.reauth-hint-container'))" | 148 " $('pod-row').pods[0].querySelector('.reauth-hint-container'))" |
149 " .display == 'none'"); | 149 " .display == 'none'"); |
150 ASSERT_TRUE(v->GetAsBoolean(&result)); | 150 ASSERT_TRUE(v->GetAsBoolean(&result)); |
151 ASSERT_TRUE(result); | 151 ASSERT_TRUE(result); |
152 | 152 |
153 // Attempt to sign in. | 153 // Attempt to sign in. |
154 LoginAttemptObserver login; | 154 LoginAttemptObserver login; |
155 v = content::ExecuteScriptAndGetValue( | 155 v = content::ExecuteScriptAndGetValue( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 new FakeExtendedAuthenticator(ScreenLocker::screen_locker_, user_context); | 210 new FakeExtendedAuthenticator(ScreenLocker::screen_locker_, user_context); |
211 } | 211 } |
212 | 212 |
213 } // namespace test | 213 } // namespace test |
214 | 214 |
215 test::ScreenLockerTester* ScreenLocker::GetTester() { | 215 test::ScreenLockerTester* ScreenLocker::GetTester() { |
216 return new test::WebUIScreenLockerTester(); | 216 return new test::WebUIScreenLockerTester(); |
217 } | 217 } |
218 | 218 |
219 } // namespace chromeos | 219 } // namespace chromeos |
OLD | NEW |