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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/print/print_controller_egtest.mm
diff --git a/ios/chrome/browser/ui/print/print_controller_egtest.mm b/ios/chrome/browser/ui/print/print_controller_egtest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..59525e1dde5df6a9ef58a06ea9ac97022b1ccfba
--- /dev/null
+++ b/ios/chrome/browser/ui/print/print_controller_egtest.mm
@@ -0,0 +1,87 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <EarlGrey/EarlGrey.h>
+#import <UIKit/UIKit.h>
+#import <XCTest/XCTest.h>
+
+#import "ios/chrome/browser/ui/uikit_ui_util.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ios/chrome/test/app/navigation_test_util.h"
+#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
+#import "ios/chrome/test/earl_grey/chrome_matchers.h"
+#import "ios/chrome/test/earl_grey/chrome_test_case.h"
+#import "ios/web/public/test/http_server.h"
+#import "ios/web/public/test/http_server_util.h"
+#include "ui/base/l10n/l10n_util_mac.h"
+#include "url/gurl.h"
+
+namespace {
+// URL which leads to a PDF file.
+const char kPDFURL[] = "http://ios/testing/data/http_server_files/testpage.pdf";
+
+// A test HTML URL.
+const char kHTMLURL[] = "http://test";
+} // namespace
+
+// Print test cases. These are Earl Grey integration tests.
+// They test printing a normal page and a pdf.
+@interface PrintControllerTestCase : ChromeTestCase
+
+// Tests that it is possible to print the current page by opening the sharing
+// menu, tapping on print and verifying it displays the print page.
+- (void)printCurrentPage;
+
+@end
+
+@implementation PrintControllerTestCase
+
+// Tests that the AirPrint menu successfully loads when a normal web page is
+// loaded.
+- (void)testPrintNormalPage {
+ GURL url = web::test::HttpServer::MakeUrl(kHTMLURL);
+ std::map<GURL, std::string> responses;
+ std::string response = "Test";
+ responses[url] = response;
+ web::test::SetUpSimpleHttpServer(responses);
+
+ chrome_test_util::LoadUrl(url);
+ id<GREYMatcher> response1Matcher =
+ chrome_test_util::webViewContainingText(response);
+ [[EarlGrey selectElementWithMatcher:response1Matcher]
+ assertWithMatcher:grey_notNil()];
+
+ [self printCurrentPage];
+}
+
+// Tests that the AirPrint menu successfully loads when a PDF is loaded.
+- (void)testPrintPDF {
+ web::test::SetUpFileBasedHttpServer();
+ GURL url = web::test::HttpServer::MakeUrl(kPDFURL);
+ chrome_test_util::LoadUrl(url);
+
+ [self printCurrentPage];
+}
+
+- (void)printCurrentPage {
+ if (IsCompact())
+ [ChromeEarlGreyUI openToolsMenu];
+
+ NSString* shareLabel = l10n_util::GetNSString(IDS_IOS_TOOLS_MENU_SHARE);
+ [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(shareLabel)]
+ performAction:grey_tap()];
+
+ id<GREYMatcher> printButton =
+ grey_allOf(grey_accessibilityLabel(@"Print"),
+ grey_accessibilityTrait(UIAccessibilityTraitButton), nil);
+ [[EarlGrey selectElementWithMatcher:printButton] performAction:grey_tap()];
+
+ id<GREYMatcher> printerOptionButton = grey_allOf(
+ grey_accessibilityLabel(@"Printer Options"),
+ grey_not(grey_accessibilityTrait(UIAccessibilityTraitHeader)), nil);
+ [[EarlGrey selectElementWithMatcher:printerOptionButton]
+ assertWithMatcher:grey_sufficientlyVisible()];
+}
+
+@end
« 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