| 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..b6cf81728fa700446cd7ed850092a1c408bf9c5f
|
| --- /dev/null
|
| +++ b/ios/web/shell/test/meta_tags_egtest.mm
|
| @@ -0,0 +1,82 @@
|
| +// 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"
|
| +#include "base/test/ios/wait_util.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
|
| +@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);
|
| +
|
| + // Wait for redirect.
|
| + base::test::ios::SpinRunLoopWithMaxDelay(
|
| + base::TimeDelta::FromSecondsD(refreshIntervalInSeconds));
|
| +
|
| + // Verify that redirect happened.
|
| + [[EarlGrey selectElementWithMatcher:addressFieldText(destinationURL.spec())]
|
| + assertWithMatcher:grey_notNil()];
|
| + [[EarlGrey selectElementWithMatcher:webViewContainingText(kDestinationPage)]
|
| + assertWithMatcher:grey_notNil()];
|
| +}
|
| +
|
| +@end
|
|
|