| Index: ios/chrome/browser/web/error_page_generator_unittest.mm
|
| diff --git a/ios/chrome/browser/web/error_page_content_unittest.mm b/ios/chrome/browser/web/error_page_generator_unittest.mm
|
| similarity index 56%
|
| rename from ios/chrome/browser/web/error_page_content_unittest.mm
|
| rename to ios/chrome/browser/web/error_page_generator_unittest.mm
|
| index 371488238e21d342d690d399b3ac5f2b4ac4f963..af1f933f700dab45a7c1def4aad972b4758086f8 100644
|
| --- a/ios/chrome/browser/web/error_page_content_unittest.mm
|
| +++ b/ios/chrome/browser/web/error_page_generator_unittest.mm
|
| @@ -1,11 +1,10 @@
|
| -// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Copyright 2017 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 "ios/chrome/browser/web/error_page_generator.h"
|
| #include "base/mac/scoped_nsobject.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| -#import "ios/chrome/browser/ui/url_loader.h"
|
| -#import "ios/chrome/browser/web/error_page_content.h"
|
| #include "ios/web/public/test/web_test.h"
|
| #include "ios/web/web_state/error_translation_util.h"
|
| #import "net/base/mac/url_conversions.h"
|
| @@ -19,22 +18,16 @@
|
| // From static_html_view_controller.mm: callback for the HtmlGenerator protocol.
|
| typedef void (^HtmlCallback)(NSString*);
|
|
|
| -// To test the error page content code, generate a URL and error data, and
|
| -// examine the generated HTML to make sure the expected text has been
|
| -// included. In detail:
|
| -// 1. Create a GURL with the URL to submit to the error page creator.
|
| -// 2. Use GenerateError to create an NSError object to pass in.
|
| -// 3. Initialize errorPageContent_ with the URL and NSError objects.
|
| -// 4. Pass the |TestHTMLForError| function to errorPageContent_'s generateHTML
|
| +// To test the error page generator code, generate error data, and examine the
|
| +// generated HTML to make sure the expected text has been included. In detail:
|
| +// 1. Use GenerateError to create an NSError object to pass in.
|
| +// 2. Initialize errorPageGenerator_ with NSError objects.
|
| +// 3. Pass the |TestHTMLForError| function to errorPageContent_'s generateHTML
|
| // function, along with the string that's expected to appear in the
|
| // generated HTML for this error.
|
| -class ErrorPageContentTest : public web::WebTest {
|
| +class ErrorPageGeneratorTest : public web::WebTest {
|
| protected:
|
| - void SetUp() override {
|
| - web::WebTest::SetUp();
|
| - mockLoader_.reset(
|
| - [[OCMockObject niceMockForProtocol:@protocol(UrlLoader)] retain]);
|
| - }
|
| + void SetUp() override { web::WebTest::SetUp(); }
|
|
|
| // Test the HTML generated in the test against the error we were supposed to
|
| // find.
|
| @@ -56,61 +49,49 @@ class ErrorPageContentTest : public web::WebTest {
|
| }
|
|
|
| // ErrorPageContent object to be tested.
|
| - base::scoped_nsobject<ErrorPageContent> errorPageContent_;
|
| + base::scoped_nsobject<ErrorPageGenerator> errorPageGenerator_;
|
|
|
| // Mock for the URLLoader that would otherwise handle the HTML produced.
|
| base::scoped_nsobject<OCMockObject> mockLoader_;
|
| };
|
|
|
| // Test with a timed out error.
|
| -TEST_F(ErrorPageContentTest, TimedOut) {
|
| +TEST_F(ErrorPageGeneratorTest, TimedOut) {
|
| GURL errorURL("http://www.google.com");
|
| NSError* error =
|
| GenerateError(errorURL, NSURLErrorDomain, kCFURLErrorTimedOut);
|
| - errorPageContent_.reset([[ErrorPageContent alloc]
|
| - initWithLoader:((id<UrlLoader>)mockLoader_.get())
|
| - browserState:GetBrowserState()
|
| - url:errorURL
|
| - error:error
|
| - isPost:NO
|
| - isIncognito:NO]);
|
| - [errorPageContent_.get() generateHtml:^(NSString* html) {
|
| + errorPageGenerator_.reset([[ErrorPageGenerator alloc] initWithError:error
|
| + isPost:NO
|
| + isIncognito:NO]);
|
| + [errorPageGenerator_.get() generateHtml:^(NSString* html) {
|
| TestHTMLForError(html, @"ERR_CONNECTION_TIMED_OUT");
|
| }];
|
| }
|
|
|
| // Test with a bad URL scheme (see b/7448754).
|
| -TEST_F(ErrorPageContentTest, BadURLScheme) {
|
| +TEST_F(ErrorPageGeneratorTest, BadURLScheme) {
|
| GURL errorURL(
|
| "itms-appss://itunes.apple.com/gb/app/google-search/id284815942?mt=8");
|
| NSError* error =
|
| GenerateError(errorURL, NSURLErrorDomain, kCFURLErrorTimedOut);
|
| - errorPageContent_.reset([[ErrorPageContent alloc]
|
| - initWithLoader:((id<UrlLoader>)mockLoader_.get())
|
| - browserState:GetBrowserState()
|
| - url:errorURL
|
| - error:error
|
| - isPost:NO
|
| - isIncognito:NO]);
|
| - [errorPageContent_.get() generateHtml:^(NSString* html) {
|
| + errorPageGenerator_.reset([[ErrorPageGenerator alloc] initWithError:error
|
| + isPost:NO
|
| + isIncognito:NO]);
|
| + [errorPageGenerator_.get() generateHtml:^(NSString* html) {
|
| TestHTMLForError(html, @"ERR_CONNECTION_TIMED_OUT");
|
| }];
|
| }
|
|
|
| // Test with an empty GURL object.
|
| // TODO(ios): [merge 191784] b/8525110 fix the code or the test.
|
| -TEST_F(ErrorPageContentTest, EmptyURLObject) {
|
| +TEST_F(ErrorPageGeneratorTest, EmptyURLObject) {
|
| GURL errorURL;
|
| NSError* error =
|
| GenerateError(errorURL, NSURLErrorDomain, kCFURLErrorTimedOut);
|
| - errorPageContent_.reset([[ErrorPageContent alloc]
|
| - initWithLoader:((id<UrlLoader>)mockLoader_.get())
|
| - browserState:GetBrowserState()
|
| - url:errorURL
|
| - error:error
|
| - isPost:NO
|
| - isIncognito:NO]);
|
| - [errorPageContent_.get() generateHtml:^(NSString* html) {
|
| + errorPageGenerator_.reset([[ErrorPageGenerator alloc] initWithError:error
|
| + isPost:NO
|
| + isIncognito:NO]);
|
| + [errorPageGenerator_.get() generateHtml:^(NSString* html) {
|
| TestHTMLForError(html, @"ERR_CONNECTION_TIMED_OUT");
|
| }];
|
| }
|
|
|