OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "components/html_viewer/layout_test_html_viewer.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "components/html_viewer/global_state.h" | |
10 #include "components/html_viewer/layout_test_content_handler_impl.h" | |
11 #include "components/test_runner/web_test_interfaces.h" | |
12 #include "components/web_view/test_runner/public/interfaces/layout_test_runner.m
ojom.h" | |
13 #include "v8/include/v8.h" | |
14 | |
15 namespace html_viewer { | |
16 | |
17 LayoutTestHTMLViewer::LayoutTestHTMLViewer() { | |
18 } | |
19 | |
20 LayoutTestHTMLViewer::~LayoutTestHTMLViewer() { | |
21 } | |
22 | |
23 void LayoutTestHTMLViewer::Initialize(mojo::Shell* shell, | |
24 const std::string& url, uint32_t id) { | |
25 HTMLViewer::Initialize(shell, url, id); | |
26 global_state()->InitIfNecessary(gfx::Size(800, 600), 1.f); | |
27 test_interfaces_.reset(new test_runner::WebTestInterfaces); | |
28 test_interfaces_->ResetAll(); | |
29 test_delegate_.set_test_interfaces(test_interfaces_.get()); | |
30 test_delegate_.set_completion_callback( | |
31 base::Bind(&LayoutTestHTMLViewer::TestFinished, base::Unretained(this))); | |
32 test_interfaces_->SetDelegate(&test_delegate_); | |
33 | |
34 // Always expose GC to layout tests. | |
35 std::string flags("--expose-gc"); | |
36 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | |
37 } | |
38 | |
39 void LayoutTestHTMLViewer::TestFinished() { | |
40 test_interfaces_->ResetAll(); | |
41 | |
42 web_view::LayoutTestRunnerPtr test_runner_ptr; | |
43 shell()->ConnectToService("mojo:web_view_test_runner", &test_runner_ptr); | |
44 test_runner_ptr->TestFinished(); | |
45 } | |
46 | |
47 void LayoutTestHTMLViewer::Create( | |
48 mojo::Connection* connection, | |
49 mojo::InterfaceRequest<mojo::shell::mojom::ContentHandler> request) { | |
50 new LayoutTestContentHandlerImpl(global_state(), shell(), std::move(request), | |
51 test_interfaces_.get(), &test_delegate_); | |
52 } | |
53 | |
54 } // namespace html_viewer | |
OLD | NEW |