| Index: ios/web/public/test/web_test_with_web_state.h
|
| diff --git a/ios/web/test/web_test.h b/ios/web/public/test/web_test_with_web_state.h
|
| similarity index 58%
|
| copy from ios/web/test/web_test.h
|
| copy to ios/web/public/test/web_test_with_web_state.h
|
| index 9eb34823641fded0a3a0afc135ab414293a98606..527a0e4236e3fe5e08f5435336702abddc0d3b87 100644
|
| --- a/ios/web/test/web_test.h
|
| +++ b/ios/web/public/test/web_test_with_web_state.h
|
| @@ -1,65 +1,37 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// 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.
|
|
|
| -#ifndef IOS_WEB_TEST_WEB_TEST_H_
|
| -#define IOS_WEB_TEST_WEB_TEST_H_
|
| +#ifndef IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_
|
| +#define IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_
|
|
|
| -#import <UIKit/UIKit.h>
|
| -
|
| -#import "base/ios/block_types.h"
|
| +#include "base/ios/block_types.h"
|
| #import "base/ios/weak_nsobject.h"
|
| -#import "base/mac/scoped_nsobject.h"
|
| #include "base/message_loop/message_loop.h"
|
| -#include "ios/web/public/test/scoped_testing_web_client.h"
|
| -#include "ios/web/public/test/test_browser_state.h"
|
| -#import "ios/web/public/test/test_web_client.h"
|
| -#include "ios/web/public/test/test_web_thread_bundle.h"
|
| -#include "ios/web/public/web_client.h"
|
| -#import "ios/web/web_state/ui/crw_web_controller.h"
|
| -#include "testing/platform_test.h"
|
| +#include "ios/web/public/test/web_test.h"
|
| +#include "url/gurl.h"
|
| +
|
| +@class CRWWebController;
|
|
|
| namespace web {
|
|
|
| -// A test fixture for web tests that need a minimum environment set up that
|
| -// mimics a web embedder.
|
| -class WebTest : public PlatformTest {
|
| +class WebState;
|
| +
|
| +// Base test fixture that provides WebState for testing.
|
| +class WebTestWithWebState : public WebTest,
|
| + public base::MessageLoop::TaskObserver {
|
| protected:
|
| - WebTest();
|
| - ~WebTest() override;
|
| + WebTestWithWebState();
|
| + ~WebTestWithWebState() override;
|
|
|
| - // PlatformTest methods.
|
| + // WebTest overrides.
|
| void SetUp() override;
|
| void TearDown() override;
|
|
|
| - // Returns the WebClient that is used for testing.
|
| - TestWebClient* GetWebClient();
|
| -
|
| - // Returns the BrowserState that is used for testing.
|
| - virtual BrowserState* GetBrowserState();
|
| -
|
| - private:
|
| - // The WebClient used in tests.
|
| - ScopedTestingWebClient web_client_;
|
| - // The threads used for testing.
|
| - web::TestWebThreadBundle thread_bundle_;
|
| - // The browser state used in tests.
|
| - TestBrowserState browser_state_;
|
| -};
|
| -
|
| -#pragma mark -
|
| -
|
| -// An abstract test fixture that sets up a WebControllers that can be loaded
|
| -// with test HTML and JavaScripts.
|
| -class WebTestWithWebController : public WebTest,
|
| - public base::MessageLoop::TaskObserver {
|
| - public:
|
| - ~WebTestWithWebController() override;
|
| + // base::MessageLoop::TaskObserver overrides.
|
| + void WillProcessTask(const base::PendingTask& pending_task) override;
|
| + void DidProcessTask(const base::PendingTask& pending_task) override;
|
|
|
| - protected:
|
| - WebTestWithWebController();
|
| - void SetUp() override;
|
| - void TearDown() override;
|
| // Loads the specified HTML content into the WebController via public APIs.
|
| void LoadHtml(NSString* html);
|
| // Loads the specified HTML content into the WebController via public APIs.
|
| @@ -80,15 +52,13 @@ class WebTestWithWebController : public WebTest,
|
| NSString* EvaluateJavaScriptAsString(NSString* script);
|
| // Synchronously executes JavaScript and returns result as id.
|
| id ExecuteJavaScript(NSString* script);
|
| - // TaskObserver methods (used when waiting for background tasks).
|
| - void WillProcessTask(const base::PendingTask& pending_task) override;
|
| - void DidProcessTask(const base::PendingTask& pending_task) override;
|
|
|
| // Returns web state for this web controller.
|
| web::WebState* web_state();
|
| const web::WebState* web_state() const;
|
|
|
| // The web controller for testing.
|
| + // TODO(crbug.com/619076): Remove this ivar.
|
| base::WeakNSObject<CRWWebController> webController_;
|
| // true if a task has been processed.
|
| bool processed_a_task_;
|
| @@ -103,9 +73,9 @@ class WebTestWithWebController : public WebTest,
|
| // ResetPageIfNavigationStalled().
|
| NSString* CreateLoadCheck();
|
| // The web state for testing.
|
| - std::unique_ptr<WebStateImpl> web_state_impl_;
|
| + std::unique_ptr<WebState> web_state_;
|
| };
|
|
|
| } // namespace web
|
|
|
| -#endif // IOS_WEB_TEST_WEB_TEST_H_
|
| +#endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_
|
|
|