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