Chromium Code Reviews| Index: ios/web/shell/test/meta_tags_egtest.mm |
| diff --git a/ios/web/shell/test/meta_tags_egtest.mm b/ios/web/shell/test/meta_tags_egtest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..88d7a949c6b332c8d0eecb3060b7c81889e0cf53 |
| --- /dev/null |
| +++ b/ios/web/shell/test/meta_tags_egtest.mm |
| @@ -0,0 +1,77 @@ |
| +// 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. |
| + |
| +#include <map> |
| + |
| +#include "base/strings/stringprintf.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/earl_grey/shell_base_test_case.h" |
| +#import "ios/web/shell/test/earl_grey/shell_matchers.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +namespace { |
| + |
| +// A simple test page with generic content. |
| +const char kDestinationPage[] = "You've arrived!"; |
| + |
| +// Template for a test page with META refresh tag. Required template arguments |
| +// are: refresh time in seconds (integer) and destination URL for redirect |
| +// (string). |
| +const char kRefreshMetaPageTemplate[] = |
| + "<!DOCTYPE html>" |
| + "<html>" |
| + " <head><meta HTTP-EQUIV='REFRESH' content='%d;url=%s'></head>" |
| + " <body></body>" |
| + "</html>"; |
| + |
| +} // namespace |
| + |
| +using web::test::HttpServer; |
| +using web::addressFieldText; |
| +using web::webViewContainingText; |
| + |
| +// META tag test cases for the web shell. |
| +@interface MetaTagsTest : ShellBaseTestCase |
|
baxley
2016/07/22 15:53:26
Similar to comment in https://codereview.chromium.
Eugene But (OOO till 7-30)
2016/07/22 18:29:37
In ios/web/shell files Shell prefix is used for sh
|
| +@end |
| + |
| +@implementation MetaTagsTest |
| + |
| +// Tests loading of a page with a META tag having a refresh value of 0 seconds. |
| +- (void)testMetaRefresh0Seconds { |
| + [self runMetaRefreshTestWithRefreshInterval:0]; |
| +} |
| + |
| +// Tests loading of a page with a META tag having a refresh value of 3 seconds. |
| +- (void)testMetaRefresh3Seconds { |
| + [self runMetaRefreshTestWithRefreshInterval:3]; |
| +} |
| + |
| +// Loads a page with a META tag having a refresh value of |refreshInterval| |
| +// seconds and verifies that redirect happens. |
| +- (void)runMetaRefreshTestWithRefreshInterval:(int)refreshIntervalInSeconds { |
| + // Create map of canned responses and set up the test HTML server. |
| + std::map<GURL, std::string> responses; |
| + const GURL originURL = HttpServer::MakeUrl("http://origin"); |
| + const GURL destinationURL = HttpServer::MakeUrl("http://destination"); |
| + responses[originURL] = |
| + base::StringPrintf(kRefreshMetaPageTemplate, refreshIntervalInSeconds, |
| + destinationURL.spec().c_str()); |
| + responses[destinationURL] = kDestinationPage; |
| + web::test::SetUpSimpleHttpServer(responses); |
| + |
| + web::shell_test_util::LoadUrl(originURL); |
| + |
| + // Verify that redirect happened. |
| + [[EarlGrey selectElementWithMatcher:addressFieldText(destinationURL.spec())] |
| + assertWithMatcher:grey_notNil()]; |
|
baxley
2016/07/22 15:53:26
This has a 4 second timeout. In the case where the
Eugene But (OOO till 7-30)
2016/07/22 18:29:37
Good point. |runMetaRefreshTestWithRefreshInterval
|
| + [[EarlGrey selectElementWithMatcher:webViewContainingText(kDestinationPage)] |
| + assertWithMatcher:grey_notNil()]; |
| +} |
| + |
| +@end |