1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/html_viewer/layout_test_html_viewer.h"
7 #include "components/html_viewer/global_state.h"
8 #include "components/html_viewer/layout_test_content_handler_impl.h"
9 #include "components/test_runner/web_test_interfaces.h"
10 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.mojom.h"
12 namespace html_viewer
{
14 LayoutTestHTMLViewer::LayoutTestHTMLViewer() {
17 LayoutTestHTMLViewer::~LayoutTestHTMLViewer() {
20 void LayoutTestHTMLViewer::Initialize(mojo::ApplicationImpl
* app
) {
21 HTMLViewer::Initialize(app
);
22 global_state()->InitIfNecessary(gfx::Size(800, 600), 1.f
);
23 test_interfaces_
.reset(new test_runner::WebTestInterfaces
);
24 test_interfaces_
->ResetAll();
25 test_delegate_
.set_test_interfaces(test_interfaces_
.get());
26 test_delegate_
.set_completion_callback(
27 base::Bind(&LayoutTestHTMLViewer::TestFinished
, base::Unretained(this)));
28 test_interfaces_
->SetDelegate(&test_delegate_
);
31 void LayoutTestHTMLViewer::TestFinished() {
32 test_interfaces_
->ResetAll();
34 web_view::LayoutTestRunnerPtr test_runner_ptr
;
35 mojo::URLRequestPtr
request(mojo::URLRequest::New());
36 request
->url
= mojo::String::From("mojo:web_view_test_runner");
37 app()->ConnectToService(request
.Pass(), &test_runner_ptr
);
38 test_runner_ptr
->TestFinished();
41 void LayoutTestHTMLViewer::Create(
42 mojo::ApplicationConnection
* connection
,
43 mojo::InterfaceRequest
<mojo::ContentHandler
> request
) {
44 new LayoutTestContentHandlerImpl(global_state(), app(), request
.Pass(),
45 test_interfaces_
.get(),
49 } // namespace html_viewer