OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/chrome/browser/passwords/password_controller.h" | 5 #import "ios/chrome/browser/passwords/password_controller.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // manager, giving the effect that password form fill failed. As soon as | 204 // manager, giving the effect that password form fill failed. As soon as |
205 // |failure_count| reaches |target_failure_count|, stop the partial mock | 205 // |failure_count| reaches |target_failure_count|, stop the partial mock |
206 // and let the original JavaScript manager execute. | 206 // and let the original JavaScript manager execute. |
207 void SetFillPasswordFormFailureCount(int target_failure_count) { | 207 void SetFillPasswordFormFailureCount(int target_failure_count) { |
208 id original_manager = [passwordController_ passwordJsManager]; | 208 id original_manager = [passwordController_ passwordJsManager]; |
209 OCPartialMockObject* failing_manager = | 209 OCPartialMockObject* failing_manager = |
210 [OCMockObject partialMockForObject:original_manager]; | 210 [OCMockObject partialMockForObject:original_manager]; |
211 __block int failure_count = 0; | 211 __block int failure_count = 0; |
212 void (^fail_invocation)(NSInvocation*) = ^(NSInvocation* invocation) { | 212 void (^fail_invocation)(NSInvocation*) = ^(NSInvocation* invocation) { |
213 if (failure_count >= target_failure_count) { | 213 if (failure_count >= target_failure_count) { |
214 [failing_manager stop]; | 214 [failing_manager stopMocking]; |
215 [invocation invokeWithTarget:original_manager]; | 215 [invocation invokeWithTarget:original_manager]; |
216 } else { | 216 } else { |
217 ++failure_count; | 217 ++failure_count; |
218 // Fetches the completion handler from |invocation| and calls it with | 218 // Fetches the completion handler from |invocation| and calls it with |
219 // failure status. | 219 // failure status. |
220 __unsafe_unretained void (^completionHandler)(BOOL); | 220 __unsafe_unretained void (^completionHandler)(BOOL); |
221 const NSInteger kArgOffset = 1; | 221 const NSInteger kArgOffset = 1; |
222 const NSInteger kCompletionHandlerArgIndex = 4; | 222 const NSInteger kCompletionHandlerArgIndex = 4; |
223 [invocation getArgument:&completionHandler | 223 [invocation getArgument:&completionHandler |
224 atIndex:(kCompletionHandlerArgIndex + kArgOffset)]; | 224 atIndex:(kCompletionHandlerArgIndex + kArgOffset)]; |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 // Tests that an HTTPS page with a password field does not update the SSL status | 1330 // Tests that an HTTPS page with a password field does not update the SSL status |
1331 // to indicate DISPLAYED_PASSWORD_FIELD_ON_HTTP. | 1331 // to indicate DISPLAYED_PASSWORD_FIELD_ON_HTTP. |
1332 TEST_F(PasswordControllerTest, HTTPSPassword) { | 1332 TEST_F(PasswordControllerTest, HTTPSPassword) { |
1333 LoadHtml(kHtmlWithPasswordForm, GURL("https://chromium.test")); | 1333 LoadHtml(kHtmlWithPasswordForm, GURL("https://chromium.test")); |
1334 | 1334 |
1335 web::SSLStatus ssl_status = | 1335 web::SSLStatus ssl_status = |
1336 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | 1336 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); |
1337 EXPECT_FALSE(ssl_status.content_status & | 1337 EXPECT_FALSE(ssl_status.content_status & |
1338 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 1338 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
1339 } | 1339 } |
OLD | NEW |