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

Unified Diff: ios/web/shell/test/pdf_egtest.mm

Issue 2183583002: [ios] EarlGrey test for PDF Mime type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@css_selector_matcher
Patch Set: Added missing GN dependency Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/shell/test/http_server_files/testpage.pdf ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/shell/test/pdf_egtest.mm
diff --git a/ios/web/shell/test/pdf_egtest.mm b/ios/web/shell/test/pdf_egtest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..73aa0276f0892d513fcf0549eddfed06ef098689
--- /dev/null
+++ b/ios/web/shell/test/pdf_egtest.mm
@@ -0,0 +1,73 @@
+// 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>
+
+#include "base/test/ios/wait_util.h"
+#include "ios/testing/earl_grey/wait_util.h"
+#import "ios/web/public/test/earl_grey/web_view_matchers.h"
+#import "ios/web/public/test/http_server.h"
+#include "ios/web/public/test/http_server_util.h"
+#include "ios/web/shell/test/app/navigation_test_util.h"
+#import "ios/web/shell/test/app/web_shell_test_util.h"
+#import "ios/web/shell/test/earl_grey/shell_base_test_case.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace {
+// URL spec for test PDF page.
+const char kTestPDFURL[] =
+ "http://ios/web/shell/test/http_server_files/testpage.pdf";
+
+// Matcher for WKWebView displaying PDF.
+id<GREYMatcher> webViewWithPdf() {
+ web::WebState* web_state = web::shell_test_util::GetCurrentWebState();
+ MatchesBlock matches = ^BOOL(UIView* view) {
+ __block BOOL did_succeed = NO;
+ NSDate* deadline =
+ [NSDate dateWithTimeIntervalSinceNow:testing::kWaitForUIElementTimeout];
+ while ([[NSDate date] compare:deadline] != NSOrderedDescending) {
+ if (web_state->GetContentsMimeType() == "application/pdf") {
+ did_succeed = YES;
+ break;
+ }
+ base::test::ios::SpinRunLoopWithMaxDelay(
+ base::TimeDelta::FromSecondsD(testing::kSpinDelaySeconds));
+ }
+ return did_succeed;
+ };
+
+ DescribeToBlock describe = ^(id<GREYDescription> description) {
+ [description appendText:@"web view with PDF"];
+ };
+
+ return grey_allOf(
+ webViewInWebState(web_state),
+ [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
+ descriptionBlock:describe],
+ nil);
+}
+
+} // namespace
+
+using web::shell_test_util::LoadUrl;
+using web::test::HttpServer;
+
+// PDF test cases for the web shell.
+@interface PDFTest : ShellBaseTestCase
+@end
+
+@implementation PDFTest
+
+// Tests MIME type of the loaded PDF document.
+- (void)testMIMEType {
+ web::test::SetUpFileBasedHttpServer();
+ LoadUrl(HttpServer::MakeUrl(kTestPDFURL));
+ [[EarlGrey selectElementWithMatcher:webViewWithPdf()]
+ assertWithMatcher:grey_notNil()];
+}
+
+@end
« no previous file with comments | « ios/web/shell/test/http_server_files/testpage.pdf ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698