OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <AVFoundation/AVFoundation.h> | 5 #import <AVFoundation/AVFoundation.h> |
6 #import <EarlGrey/EarlGrey.h> | 6 #import <EarlGrey/EarlGrey.h> |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } | 389 } |
390 | 390 |
391 #pragma mark - | 391 #pragma mark - |
392 #pragma mark Helpers for mocks | 392 #pragma mark Helpers for mocks |
393 | 393 |
394 // Swizzles the CameraController method cameraControllerWithDelegate: to return | 394 // Swizzles the CameraController method cameraControllerWithDelegate: to return |
395 // |cameraControllerMock| instead of a new instance of CameraController. | 395 // |cameraControllerMock| instead of a new instance of CameraController. |
396 - (void)swizzleCameraController:(id)cameraControllerMock { | 396 - (void)swizzleCameraController:(id)cameraControllerMock { |
397 CameraController* (^swizzleCameraControllerBlock)( | 397 CameraController* (^swizzleCameraControllerBlock)( |
398 id<CameraControllerDelegate>) = ^(id<CameraControllerDelegate> delegate) { | 398 id<CameraControllerDelegate>) = ^(id<CameraControllerDelegate> delegate) { |
399 // |initWithDelegate:| must return an object with a return count of 1 | 399 return cameraControllerMock; |
400 // because it is preceded by a call to |alloc|. | |
401 return [cameraControllerMock retain]; | |
402 }; | 400 }; |
403 | 401 |
404 camera_controller_swizzler_.reset(new ScopedBlockSwizzler( | 402 camera_controller_swizzler_.reset(new ScopedBlockSwizzler( |
405 [CameraController class], @selector(initWithDelegate:), | 403 [CameraController class], @selector(cameraControllerWithDelegate:), |
406 swizzleCameraControllerBlock)); | 404 swizzleCameraControllerBlock)); |
407 } | 405 } |
408 | 406 |
409 // Swizzles the WebToolbarController loadGURLFromLocationBarBlock:transition: | 407 // Swizzles the WebToolbarController loadGURLFromLocationBarBlock:transition: |
410 // method to load |searchURL| instead of the generated search URL. | 408 // method to load |searchURL| instead of the generated search URL. |
411 - (void)swizzleWebToolbarControllerLoadGURLFromLocationBar: | 409 - (void)swizzleWebToolbarControllerLoadGURLFromLocationBar: |
412 (const GURL&)searchURL { | 410 (const GURL&)searchURL { |
413 void (^loadGURLFromLocationBarBlock)(WebToolbarController*, const GURL&, | 411 void (^loadGURLFromLocationBarBlock)(WebToolbarController*, const GURL&, |
414 ui::PageTransition) = | 412 ui::PageTransition) = |
415 ^void(WebToolbarController* self, const GURL& url, | 413 ^void(WebToolbarController* self, const GURL& url, |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 // Test that the correct page is loaded if the scanner result is a search query | 816 // Test that the correct page is loaded if the scanner result is a search query |
819 // which is then manually edited. | 817 // which is then manually edited. |
820 - (void)testReceivingQRScannerSearchQueryResultAndEditingTheQuery { | 818 - (void)testReceivingQRScannerSearchQueryResultAndEditingTheQuery { |
821 [self swizzleWebToolbarControllerLoadGURLFromLocationBar:_testQueryEdited]; | 819 [self swizzleWebToolbarControllerLoadGURLFromLocationBar:_testQueryEdited]; |
822 [self doTestReceivingResult:kTestQuery | 820 [self doTestReceivingResult:kTestQuery |
823 response:kTestQueryEditedResponse | 821 response:kTestQueryEditedResponse |
824 edit:@"\bedited"]; | 822 edit:@"\bedited"]; |
825 } | 823 } |
826 | 824 |
827 @end | 825 @end |
OLD | NEW |