Commit 8622ff63 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Prepare WebUIMojoTest for Pending Item ownership refactoring.

Notable changes:
 - SetUp method wraps it's code into @autoreleasepool, to make sure that
   CRWWebController never goes to autorelease pool. CRWWebController
   will go to autorelease pool when used as a delegate for
   CRWSessionController in crrev.com/1455658. CRWWebController should
   not outlive WebThreadBundle, hence should not go to autorelease pool.

 - Use public WebState API for web state creation. This way all requred
   changes inside WebState::Create don't have to be duplicated in
   the test, which used to create WebStateImpl object via constructor.

Bug: 899827
Change-Id: I50d07c6a06c5affdab2aa0924d3c97f15b4c387e
Reviewed-on: https://chromium-review.googlesource.com/c/1484819
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634984}
parent 68aa6643
......@@ -11,6 +11,7 @@
#include "ios/web/grit/ios_web_resources.h"
#import "ios/web/public/navigation_manager.h"
#import "ios/web/public/test/navigation_test_util.h"
#import "ios/web/public/web_state/web_state.h"
#include "ios/web/public/web_state/web_state_interface_provider.h"
#include "ios/web/public/web_ui_ios_data_source.h"
#include "ios/web/public/webui/web_ui_ios_controller.h"
......@@ -19,8 +20,6 @@
#include "ios/web/test/mojo_test.mojom.h"
#include "ios/web/test/test_url_constants.h"
#import "ios/web/test/web_int_test.h"
#import "ios/web/web_state/ui/crw_web_controller.h"
#import "ios/web/web_state/web_state_impl.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
......@@ -143,12 +142,13 @@ class WebUIMojoTest : public WebIntTest {
protected:
void SetUp() override {
WebIntTest::SetUp();
ui_handler_ = std::make_unique<TestUIHandler>();
web::WebState::CreateParams params(GetBrowserState());
web_state_ = std::make_unique<web::WebStateImpl>(params);
web_state_->GetNavigationManagerImpl().InitializeSession();
WebUIIOSControllerFactory::RegisterFactory(
new TestWebUIControllerFactory(ui_handler_.get()));
@autoreleasepool {
ui_handler_ = std::make_unique<TestUIHandler>();
WebState::CreateParams params(GetBrowserState());
web_state_ = WebState::Create(params);
WebUIIOSControllerFactory::RegisterFactory(
new TestWebUIControllerFactory(ui_handler_.get()));
}
}
void TearDown() override {
......@@ -169,12 +169,12 @@ class WebUIMojoTest : public WebIntTest {
}
// Returns WebState which loads test WebUI page.
WebStateImpl* web_state() { return web_state_.get(); }
WebState* web_state() { return web_state_.get(); }
// Returns UI handler which communicates with WebUI page.
TestUIHandler* test_ui_handler() { return ui_handler_.get(); }
private:
std::unique_ptr<WebStateImpl> web_state_;
std::unique_ptr<WebState> web_state_;
std::unique_ptr<TestUIHandler> ui_handler_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment