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

Side by Side Diff: ios/chrome/browser/ui/print/print_controller_egtest.mm

Issue 2798773002: Create ChromeEarlGrey waitForWebViewContainingText. (Closed)
Patch Set: better formatting Created 3 years, 8 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 <EarlGrey/EarlGrey.h> 5 #import <EarlGrey/EarlGrey.h>
6 #import <UIKit/UIKit.h> 6 #import <UIKit/UIKit.h>
7 #import <XCTest/XCTest.h> 7 #import <XCTest/XCTest.h>
8 8
9 #include "base/strings/sys_string_conversions.h"
9 #import "ios/chrome/browser/ui/uikit_ui_util.h" 10 #import "ios/chrome/browser/ui/uikit_ui_util.h"
10 #include "ios/chrome/grit/ios_strings.h" 11 #include "ios/chrome/grit/ios_strings.h"
11 #include "ios/chrome/test/app/navigation_test_util.h" 12 #include "ios/chrome/test/app/navigation_test_util.h"
13 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
12 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" 14 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
13 #import "ios/chrome/test/earl_grey/chrome_matchers.h" 15 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
14 #import "ios/chrome/test/earl_grey/chrome_test_case.h" 16 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
15 #import "ios/web/public/test/http_server.h" 17 #import "ios/web/public/test/http_server.h"
16 #import "ios/web/public/test/http_server_util.h" 18 #import "ios/web/public/test/http_server_util.h"
17 #include "ui/base/l10n/l10n_util_mac.h" 19 #include "ui/base/l10n/l10n_util_mac.h"
18 #include "url/gurl.h" 20 #include "url/gurl.h"
19 21
20 #if !defined(__has_feature) || !__has_feature(objc_arc) 22 #if !defined(__has_feature) || !__has_feature(objc_arc)
21 #error "This file requires ARC support." 23 #error "This file requires ARC support."
(...skipping 22 matching lines...) Expand all
44 // Tests that the AirPrint menu successfully loads when a normal web page is 46 // Tests that the AirPrint menu successfully loads when a normal web page is
45 // loaded. 47 // loaded.
46 - (void)testPrintNormalPage { 48 - (void)testPrintNormalPage {
47 GURL url = web::test::HttpServer::MakeUrl(kHTMLURL); 49 GURL url = web::test::HttpServer::MakeUrl(kHTMLURL);
48 std::map<GURL, std::string> responses; 50 std::map<GURL, std::string> responses;
49 std::string response = "Test"; 51 std::string response = "Test";
50 responses[url] = response; 52 responses[url] = response;
51 web::test::SetUpSimpleHttpServer(responses); 53 web::test::SetUpSimpleHttpServer(responses);
52 54
53 chrome_test_util::LoadUrl(url); 55 chrome_test_util::LoadUrl(url);
54 id<GREYMatcher> response1Matcher = 56 [ChromeEarlGrey
55 chrome_test_util::WebViewContainingText(response); 57 waitForWebViewContainingText:base::SysUTF8ToNSString(response)];
56 [[EarlGrey selectElementWithMatcher:response1Matcher]
57 assertWithMatcher:grey_notNil()];
58 58
59 [self printCurrentPage]; 59 [self printCurrentPage];
60 } 60 }
61 61
62 // Tests that the AirPrint menu successfully loads when a PDF is loaded. 62 // Tests that the AirPrint menu successfully loads when a PDF is loaded.
63 - (void)testPrintPDF { 63 - (void)testPrintPDF {
64 web::test::SetUpFileBasedHttpServer(); 64 web::test::SetUpFileBasedHttpServer();
65 GURL url = web::test::HttpServer::MakeUrl(kPDFURL); 65 GURL url = web::test::HttpServer::MakeUrl(kPDFURL);
66 chrome_test_util::LoadUrl(url); 66 chrome_test_util::LoadUrl(url);
67 67
68 [self printCurrentPage]; 68 [self printCurrentPage];
69 } 69 }
70 70
71 - (void)printCurrentPage { 71 - (void)printCurrentPage {
72 [ChromeEarlGreyUI openShareMenu]; 72 [ChromeEarlGreyUI openShareMenu];
73 73
74 id<GREYMatcher> printButton = 74 id<GREYMatcher> printButton =
75 grey_allOf(grey_accessibilityLabel(@"Print"), 75 grey_allOf(grey_accessibilityLabel(@"Print"),
76 grey_accessibilityTrait(UIAccessibilityTraitButton), nil); 76 grey_accessibilityTrait(UIAccessibilityTraitButton), nil);
77 [[EarlGrey selectElementWithMatcher:printButton] performAction:grey_tap()]; 77 [[EarlGrey selectElementWithMatcher:printButton] performAction:grey_tap()];
78 78
79 id<GREYMatcher> printerOptionButton = grey_allOf( 79 id<GREYMatcher> printerOptionButton = grey_allOf(
80 grey_accessibilityLabel(@"Printer Options"), 80 grey_accessibilityLabel(@"Printer Options"),
81 grey_not(grey_accessibilityTrait(UIAccessibilityTraitHeader)), nil); 81 grey_not(grey_accessibilityTrait(UIAccessibilityTraitHeader)), nil);
82 [[EarlGrey selectElementWithMatcher:printerOptionButton] 82 [[EarlGrey selectElementWithMatcher:printerOptionButton]
83 assertWithMatcher:grey_sufficientlyVisible()]; 83 assertWithMatcher:grey_sufficientlyVisible()];
84 } 84 }
85 85
86 @end 86 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698