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

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

Issue 2589803002: Upstream Chrome on iOS source code [6/11]. (Closed)
Patch Set: Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import <EarlGrey/EarlGrey.h>
6 #import <UIKit/UIKit.h>
7 #import <XCTest/XCTest.h>
8
9 #import "ios/chrome/browser/ui/uikit_ui_util.h"
10 #include "ios/chrome/grit/ios_strings.h"
11 #include "ios/chrome/test/app/navigation_test_util.h"
12 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
13 #import "ios/chrome/test/earl_grey/chrome_matchers.h"
14 #import "ios/chrome/test/earl_grey/chrome_test_case.h"
15 #import "ios/web/public/test/http_server.h"
16 #import "ios/web/public/test/http_server_util.h"
17 #include "ui/base/l10n/l10n_util_mac.h"
18 #include "url/gurl.h"
19
20 namespace {
21 // URL which leads to a PDF file.
22 const char kPDFURL[] = "http://ios/testing/data/http_server_files/testpage.pdf";
23
24 // A test HTML URL.
25 const char kHTMLURL[] = "http://test";
26 } // namespace
27
28 // Print test cases. These are Earl Grey integration tests.
29 // They test printing a normal page and a pdf.
30 @interface PrintControllerTestCase : ChromeTestCase
31
32 // Tests that it is possible to print the current page by opening the sharing
33 // menu, tapping on print and verifying it displays the print page.
34 - (void)printCurrentPage;
35
36 @end
37
38 @implementation PrintControllerTestCase
39
40 // Tests that the AirPrint menu successfully loads when a normal web page is
41 // loaded.
42 - (void)testPrintNormalPage {
43 GURL url = web::test::HttpServer::MakeUrl(kHTMLURL);
44 std::map<GURL, std::string> responses;
45 std::string response = "Test";
46 responses[url] = response;
47 web::test::SetUpSimpleHttpServer(responses);
48
49 chrome_test_util::LoadUrl(url);
50 id<GREYMatcher> response1Matcher =
51 chrome_test_util::webViewContainingText(response);
52 [[EarlGrey selectElementWithMatcher:response1Matcher]
53 assertWithMatcher:grey_notNil()];
54
55 [self printCurrentPage];
56 }
57
58 // Tests that the AirPrint menu successfully loads when a PDF is loaded.
59 - (void)testPrintPDF {
60 web::test::SetUpFileBasedHttpServer();
61 GURL url = web::test::HttpServer::MakeUrl(kPDFURL);
62 chrome_test_util::LoadUrl(url);
63
64 [self printCurrentPage];
65 }
66
67 - (void)printCurrentPage {
68 if (IsCompact())
69 [ChromeEarlGreyUI openToolsMenu];
70
71 NSString* shareLabel = l10n_util::GetNSString(IDS_IOS_TOOLS_MENU_SHARE);
72 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(shareLabel)]
73 performAction:grey_tap()];
74
75 id<GREYMatcher> printButton =
76 grey_allOf(grey_accessibilityLabel(@"Print"),
77 grey_accessibilityTrait(UIAccessibilityTraitButton), nil);
78 [[EarlGrey selectElementWithMatcher:printButton] performAction:grey_tap()];
79
80 id<GREYMatcher> printerOptionButton = grey_allOf(
81 grey_accessibilityLabel(@"Printer Options"),
82 grey_not(grey_accessibilityTrait(UIAccessibilityTraitHeader)), nil);
83 [[EarlGrey selectElementWithMatcher:printerOptionButton]
84 assertWithMatcher:grey_sufficientlyVisible()];
85 }
86
87 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/print/print_controller.mm ('k') | ios/chrome/browser/ui/promos/promo_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698