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" | |
10 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
12 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
13 #include "components/version_info/version_info.h" | 12 #include "components/version_info/version_info.h" |
14 #import "ios/chrome/app/main_controller.h" | 13 #import "ios/chrome/app/main_controller.h" |
15 #include "ios/chrome/browser/chrome_switches.h" | 14 #include "ios/chrome/browser/chrome_switches.h" |
16 #import "ios/chrome/browser/ui/browser_view_controller.h" | 15 #import "ios/chrome/browser/ui/browser_view_controller.h" |
17 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 16 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
18 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 17 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
19 #include "ios/chrome/browser/ui/icons/chrome_icon.h" | 18 #include "ios/chrome/browser/ui/icons/chrome_icon.h" |
20 #include "ios/chrome/browser/ui/qr_scanner/camera_controller.h" | 19 #include "ios/chrome/browser/ui/qr_scanner/camera_controller.h" |
21 #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view.h" | 20 #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view.h" |
22 #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view_controller.h" | 21 #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view_controller.h" |
23 #include "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" | 22 #include "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" |
24 #include "ios/chrome/grit/ios_chromium_strings.h" | 23 #include "ios/chrome/grit/ios_chromium_strings.h" |
25 #include "ios/chrome/grit/ios_strings.h" | 24 #include "ios/chrome/grit/ios_strings.h" |
26 #import "ios/chrome/test/app/chrome_test_util.h" | 25 #import "ios/chrome/test/app/chrome_test_util.h" |
27 #import "ios/chrome/test/base/scoped_block_swizzler.h" | 26 #import "ios/chrome/test/base/scoped_block_swizzler.h" |
28 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 27 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
29 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 28 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
30 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_delegate.h" | 29 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_delegate.h" |
31 #import "ios/web/public/test/http_server/http_server.h" | 30 #import "ios/web/public/test/http_server/http_server.h" |
32 #include "ios/web/public/test/http_server/http_server_util.h" | 31 #include "ios/web/public/test/http_server/http_server_util.h" |
33 #import "third_party/ocmock/OCMock/OCMock.h" | 32 #import "third_party/ocmock/OCMock/OCMock.h" |
34 #import "ui/base/l10n/l10n_util.h" | 33 #import "ui/base/l10n/l10n_util.h" |
35 #import "ui/base/l10n/l10n_util_mac.h" | 34 #import "ui/base/l10n/l10n_util_mac.h" |
36 | 35 |
| 36 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 37 #error "This file requires ARC support." |
| 38 #endif |
| 39 |
37 using namespace chrome_test_util; | 40 using namespace chrome_test_util; |
38 using namespace qr_scanner; | 41 using namespace qr_scanner; |
39 | 42 |
40 namespace { | 43 namespace { |
41 | 44 |
42 char kTestURL[] = "http://testurl"; | 45 char kTestURL[] = "http://testurl"; |
43 char kTestURLResponse[] = "Test URL page"; | 46 char kTestURLResponse[] = "Test URL page"; |
44 char kTestQuery[] = "testquery"; | 47 char kTestQuery[] = "testquery"; |
45 char kTestQueryURL[] = "http://searchurl/testquery"; | 48 char kTestQueryURL[] = "http://searchurl/testquery"; |
46 char kTestQueryResponse[] = "Test query page"; | 49 char kTestQueryResponse[] = "Test query page"; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Returns the GREYMatcher for the Cancel button to dismiss a UIAlertController. | 106 // Returns the GREYMatcher for the Cancel button to dismiss a UIAlertController. |
104 id<GREYMatcher> DialogCancelButton() { | 107 id<GREYMatcher> DialogCancelButton() { |
105 return grey_allOf( | 108 return grey_allOf( |
106 grey_text(l10n_util::GetNSString(IDS_IOS_QR_SCANNER_ALERT_CANCEL)), | 109 grey_text(l10n_util::GetNSString(IDS_IOS_QR_SCANNER_ALERT_CANCEL)), |
107 grey_accessibilityTrait(UIAccessibilityTraitStaticText), nil); | 110 grey_accessibilityTrait(UIAccessibilityTraitStaticText), nil); |
108 } | 111 } |
109 | 112 |
110 // Opens the QR Scanner view using a command. | 113 // Opens the QR Scanner view using a command. |
111 // TODO(crbug.com/629776): Replace the command call with a UI action. | 114 // TODO(crbug.com/629776): Replace the command call with a UI action. |
112 void ShowQRScannerWithCommand() { | 115 void ShowQRScannerWithCommand() { |
113 base::scoped_nsobject<GenericChromeCommand> command( | 116 GenericChromeCommand* command = |
114 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_QR_SCANNER]); | 117 [[GenericChromeCommand alloc] initWithTag:IDC_SHOW_QR_SCANNER]; |
115 chrome_test_util::RunCommandWithActiveViewController(command); | 118 chrome_test_util::RunCommandWithActiveViewController(command); |
116 } | 119 } |
117 | 120 |
118 // Taps the |button|. | 121 // Taps the |button|. |
119 void TapButton(id<GREYMatcher> button) { | 122 void TapButton(id<GREYMatcher> button) { |
120 [[EarlGrey selectElementWithMatcher:button] performAction:grey_tap()]; | 123 [[EarlGrey selectElementWithMatcher:button] performAction:grey_tap()]; |
121 } | 124 } |
122 | 125 |
123 // Appends the given |editText| to the |text| already in the omnibox and presses | 126 // Appends the given |editText| to the |text| already in the omnibox and presses |
124 // the keyboard return key. | 127 // the keyboard return key. |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 // Test that the correct page is loaded if the scanner result is a search query | 819 // Test that the correct page is loaded if the scanner result is a search query |
817 // which is then manually edited. | 820 // which is then manually edited. |
818 - (void)testReceivingQRScannerSearchQueryResultAndEditingTheQuery { | 821 - (void)testReceivingQRScannerSearchQueryResultAndEditingTheQuery { |
819 [self swizzleWebToolbarControllerLoadGURLFromLocationBar:_testQueryEdited]; | 822 [self swizzleWebToolbarControllerLoadGURLFromLocationBar:_testQueryEdited]; |
820 [self doTestReceivingResult:kTestQuery | 823 [self doTestReceivingResult:kTestQuery |
821 response:kTestQueryEditedResponse | 824 response:kTestQueryEditedResponse |
822 edit:@"\bedited"]; | 825 edit:@"\bedited"]; |
823 } | 826 } |
824 | 827 |
825 @end | 828 @end |
OLD | NEW |