Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Side by Side Diff: ios/chrome/browser/ui/qr_scanner/qr_scanner_view_controller_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: review comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/strings/grit/components_strings.h" 11 #include "components/strings/grit/components_strings.h"
12 #include "components/version_info/version_info.h" 12 #include "components/version_info/version_info.h"
13 #import "ios/chrome/app/main_controller.h" 13 #import "ios/chrome/app/main_controller.h"
14 #include "ios/chrome/browser/chrome_switches.h" 14 #include "ios/chrome/browser/chrome_switches.h"
15 #import "ios/chrome/browser/ui/browser_view_controller.h" 15 #import "ios/chrome/browser/ui/browser_view_controller.h"
16 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 16 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
17 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 17 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
18 #include "ios/chrome/browser/ui/icons/chrome_icon.h" 18 #include "ios/chrome/browser/ui/icons/chrome_icon.h"
19 #include "ios/chrome/browser/ui/qr_scanner/camera_controller.h" 19 #include "ios/chrome/browser/ui/qr_scanner/camera_controller.h"
20 #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view.h" 20 #include "ios/chrome/browser/ui/qr_scanner/qr_scanner_view.h"
21 #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"
22 #include "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h" 22 #include "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
23 #include "ios/chrome/grit/ios_chromium_strings.h" 23 #include "ios/chrome/grit/ios_chromium_strings.h"
24 #include "ios/chrome/grit/ios_strings.h" 24 #include "ios/chrome/grit/ios_strings.h"
25 #import "ios/chrome/test/app/chrome_test_util.h" 25 #import "ios/chrome/test/app/chrome_test_util.h"
26 #import "ios/chrome/test/base/scoped_block_swizzler.h" 26 #import "ios/chrome/test/base/scoped_block_swizzler.h"
27 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
27 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 28 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
28 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 29 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
29 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_delegate.h" 30 #include "ios/shared/chrome/browser/ui/omnibox/location_bar_delegate.h"
30 #import "ios/web/public/test/http_server/http_server.h" 31 #import "ios/web/public/test/http_server/http_server.h"
31 #include "ios/web/public/test/http_server/http_server_util.h" 32 #include "ios/web/public/test/http_server/http_server_util.h"
32 #import "third_party/ocmock/OCMock/OCMock.h" 33 #import "third_party/ocmock/OCMock/OCMock.h"
33 #import "ui/base/l10n/l10n_util.h" 34 #import "ui/base/l10n/l10n_util.h"
34 #import "ui/base/l10n/l10n_util_mac.h" 35 #import "ui/base/l10n/l10n_util_mac.h"
35 36
36 #if !defined(__has_feature) || !__has_feature(objc_arc) 37 #if !defined(__has_feature) || !__has_feature(objc_arc)
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 MainController* mainController = chrome_test_util::GetMainController(); 274 MainController* mainController = chrome_test_util::GetMainController();
274 return [[mainController browserViewInformation] currentBVC]; 275 return [[mainController browserViewInformation] currentBVC];
275 } 276 }
276 277
277 // Checks that the omnibox is visible and contains |text|. 278 // Checks that the omnibox is visible and contains |text|.
278 - (void)assertOmniboxIsVisibleWithText:(std::string)text { 279 - (void)assertOmniboxIsVisibleWithText:(std::string)text {
279 [[EarlGrey selectElementWithMatcher:OmniboxText(text)] 280 [[EarlGrey selectElementWithMatcher:OmniboxText(text)]
280 assertWithMatcher:grey_notNil()]; 281 assertWithMatcher:grey_notNil()];
281 } 282 }
282 283
283 // Checks that the page that is currently loaded contains the |response|.
284 - (void)assertTestURLIsLoaded:(std::string)response {
285 id<GREYMatcher> testURLResponseMatcher =
286 chrome_test_util::WebViewContainingText(response);
287 [[EarlGrey selectElementWithMatcher:testURLResponseMatcher]
288 assertWithMatcher:grey_notNil()];
289 }
290
291 #pragma mark helpers for dialogs 284 #pragma mark helpers for dialogs
292 285
293 // Checks that the modal presented by |viewController| is of class |klass|. 286 // Checks that the modal presented by |viewController| is of class |klass|.
294 - (void)assertModalOfClass:(Class)klass 287 - (void)assertModalOfClass:(Class)klass
295 isPresentedBy:(UIViewController*)viewController { 288 isPresentedBy:(UIViewController*)viewController {
296 UIViewController* modal = [viewController presentedViewController]; 289 UIViewController* modal = [viewController presentedViewController];
297 NSString* errorString = [NSString 290 NSString* errorString = [NSString
298 stringWithFormat:@"A modal of class %@ should be presented by %@.", klass, 291 stringWithFormat:@"A modal of class %@ should be presented by %@.", klass,
299 [viewController class]]; 292 [viewController class]];
300 GREYAssertTrue(modal && [modal isKindOfClass:klass], errorString); 293 GREYAssertTrue(modal && [modal isKindOfClass:klass], errorString);
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 toDisappearFromAbove:[self currentBVC]]; 773 toDisappearFromAbove:[self currentBVC]];
781 [cameraControllerMock verify]; 774 [cameraControllerMock verify];
782 775
783 // Optionally edit the text in the omnibox before pressing return. 776 // Optionally edit the text in the omnibox before pressing return.
784 [self assertOmniboxIsVisibleWithText:result]; 777 [self assertOmniboxIsVisibleWithText:result];
785 if (editString != nil) { 778 if (editString != nil) {
786 EditOmniboxTextAndTapKeyboardReturn(result, editString); 779 EditOmniboxTextAndTapKeyboardReturn(result, editString);
787 } else { 780 } else {
788 TapKeyboardReturnKeyInOmniboxWithText(result); 781 TapKeyboardReturnKeyInOmniboxWithText(result);
789 } 782 }
790 [self assertTestURLIsLoaded:response]; 783 [ChromeEarlGrey waitForWebViewContainingText:response];
791 784
792 // Press the back button to get back to the NTP. 785 // Press the back button to get back to the NTP.
793 TapButton(WebToolbarBackButton()); 786 TapButton(WebToolbarBackButton());
794 [self assertModalOfClass:[QRScannerViewController class] 787 [self assertModalOfClass:[QRScannerViewController class]
795 isNotPresentedBy:[self currentBVC]]; 788 isNotPresentedBy:[self currentBVC]];
796 } 789 }
797 790
798 // Test that the correct page is loaded if the scanner result is a URL. 791 // Test that the correct page is loaded if the scanner result is a URL.
799 - (void)testReceivingQRScannerURLResult { 792 - (void)testReceivingQRScannerURLResult {
800 [self doTestReceivingResult:_testURL.GetContent() 793 [self doTestReceivingResult:_testURL.GetContent()
(...skipping 18 matching lines...) Expand all
819 // Test that the correct page is loaded if the scanner result is a search query 812 // Test that the correct page is loaded if the scanner result is a search query
820 // which is then manually edited. 813 // which is then manually edited.
821 - (void)testReceivingQRScannerSearchQueryResultAndEditingTheQuery { 814 - (void)testReceivingQRScannerSearchQueryResultAndEditingTheQuery {
822 [self swizzleWebToolbarControllerLoadGURLFromLocationBar:_testQueryEdited]; 815 [self swizzleWebToolbarControllerLoadGURLFromLocationBar:_testQueryEdited];
823 [self doTestReceivingResult:kTestQuery 816 [self doTestReceivingResult:kTestQuery
824 response:kTestQueryEditedResponse 817 response:kTestQueryEditedResponse
825 edit:@"\bedited"]; 818 edit:@"\bedited"];
826 } 819 }
827 820
828 @end 821 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/print/print_controller_egtest.mm ('k') | ios/chrome/browser/ui/reading_list/reading_list_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698