Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1631)

Side by Side Diff: components/web_view/test_runner/test_runner_application_delegate.cc

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/web_view/test_runner/test_runner_application_delegate.h" 5 #include "components/web_view/test_runner/test_runner_application_delegate.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
18 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "components/mus/public/cpp/scoped_window_ptr.h" 20 #include "components/mus/public/cpp/scoped_window_ptr.h"
21 #include "components/mus/public/cpp/window.h" 21 #include "components/mus/public/cpp/window.h"
22 #include "components/mus/public/cpp/window_tree_connection.h" 22 #include "components/mus/public/cpp/window_tree_connection.h"
23 #include "components/mus/public/cpp/window_tree_host_factory.h" 23 #include "components/mus/public/cpp/window_tree_host_factory.h"
24 #include "components/test_runner/blink_test_platform_support.h" 24 #include "components/test_runner/blink_test_platform_support.h"
25 #include "mojo/converters/geometry/geometry_type_converters.h" 25 #include "mojo/converters/geometry/geometry_type_converters.h"
26 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" 26 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
27 #include "mojo/shell/public/cpp/application_connection.h" 27 #include "mojo/shell/public/cpp/application_connection.h"
28 #include "mojo/shell/public/cpp/application_impl.h" 28 #include "mojo/shell/public/cpp/shell.h"
29 #include "ui/gfx/geometry/rect.h" 29 #include "ui/gfx/geometry/rect.h"
30 #include "ui/gfx/geometry/size.h" 30 #include "ui/gfx/geometry/size.h"
31 #include "url/gurl.h" 31 #include "url/gurl.h"
32 32
33 #if defined(OS_WIN) 33 #if defined(OS_WIN)
34 #include "base/strings/sys_string_conversions.h" 34 #include "base/strings/sys_string_conversions.h"
35 #include "base/strings/utf_string_conversions.h" 35 #include "base/strings/utf_string_conversions.h"
36 #endif 36 #endif
37 37
38 namespace web_view { 38 namespace web_view {
39 39
40 TestRunnerApplicationDelegate::TestRunnerApplicationDelegate() 40 TestRunnerApplicationDelegate::TestRunnerApplicationDelegate()
41 : app_(nullptr), root_(nullptr), content_(nullptr) {} 41 : shell_(nullptr), root_(nullptr), content_(nullptr) {}
42 42
43 TestRunnerApplicationDelegate::~TestRunnerApplicationDelegate() { 43 TestRunnerApplicationDelegate::~TestRunnerApplicationDelegate() {
44 if (root_) 44 if (root_)
45 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); 45 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_);
46 } 46 }
47 47
48 void TestRunnerApplicationDelegate::LaunchURL(const GURL& test_url) { 48 void TestRunnerApplicationDelegate::LaunchURL(const GURL& test_url) {
49 if (!web_view_) { 49 if (!web_view_) {
50 web_view_.reset(new WebView(this)); 50 web_view_.reset(new WebView(this));
51 web_view_->Init(app_, content_); 51 web_view_->Init(shell_, content_);
52 } 52 }
53 mojo::URLRequestPtr request(mojo::URLRequest::New()); 53 mojo::URLRequestPtr request(mojo::URLRequest::New());
54 request->url = test_url.spec(); 54 request->url = test_url.spec();
55 web_view_->web_view()->LoadRequest(std::move(request)); 55 web_view_->web_view()->LoadRequest(std::move(request));
56 } 56 }
57 57
58 void TestRunnerApplicationDelegate::Terminate() { 58 void TestRunnerApplicationDelegate::Terminate() {
59 if (root_) 59 if (root_)
60 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_); 60 mus::ScopedWindowPtr::DeleteWindowOrWindowManager(root_);
61 } 61 }
62 62
63 //////////////////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////////////////
64 // mojo::ApplicationDelegate implementation: 64 // mojo::ApplicationDelegate implementation:
65 65
66 void TestRunnerApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { 66 void TestRunnerApplicationDelegate::Initialize(mojo::Shell* shell,
67 const std::string& url,
68 uint32_t id) {
67 if (!test_runner::BlinkTestPlatformInitialize()) { 69 if (!test_runner::BlinkTestPlatformInitialize()) {
68 NOTREACHED() << "Test environment could not be properly set up for blink."; 70 NOTREACHED() << "Test environment could not be properly set up for blink.";
69 } 71 }
70 app_ = app; 72 shell_ = shell;
71 mus::CreateWindowTreeHost(app_, this, &host_, nullptr); 73 mus::CreateWindowTreeHost(shell_, this, &host_, nullptr);
72 } 74 }
73 75
74 bool TestRunnerApplicationDelegate::AcceptConnection( 76 bool TestRunnerApplicationDelegate::AcceptConnection(
75 mojo::ApplicationConnection* connection) { 77 mojo::ApplicationConnection* connection) {
76 connection->AddService<web_view::LayoutTestRunner>(this); 78 connection->AddService<web_view::LayoutTestRunner>(this);
77 return true; 79 return true;
78 } 80 }
79 81
80 //////////////////////////////////////////////////////////////////////////////// 82 ////////////////////////////////////////////////////////////////////////////////
81 // mus::WindowTreeDelegate implementation: 83 // mus::WindowTreeDelegate implementation:
(...skipping 26 matching lines...) Expand all
108 test_extractor_.reset(new test_runner::TestInfoExtractor(cmdline_args)); 110 test_extractor_.reset(new test_runner::TestInfoExtractor(cmdline_args));
109 111
110 scoped_ptr<test_runner::TestInfo> test_info = test_extractor_->GetNextTest(); 112 scoped_ptr<test_runner::TestInfo> test_info = test_extractor_->GetNextTest();
111 if (test_info) 113 if (test_info)
112 LaunchURL(test_info->url); 114 LaunchURL(test_info->url);
113 } 115 }
114 116
115 void TestRunnerApplicationDelegate::OnConnectionLost( 117 void TestRunnerApplicationDelegate::OnConnectionLost(
116 mus::WindowTreeConnection* connection) { 118 mus::WindowTreeConnection* connection) {
117 root_ = nullptr; 119 root_ = nullptr;
118 app_->Quit(); 120 shell_->Quit();
119 } 121 }
120 122
121 //////////////////////////////////////////////////////////////////////////////// 123 ////////////////////////////////////////////////////////////////////////////////
122 // mojom::WebViewClient implementation: 124 // mojom::WebViewClient implementation:
123 125
124 void TestRunnerApplicationDelegate::TopLevelNavigateRequest( 126 void TestRunnerApplicationDelegate::TopLevelNavigateRequest(
125 mojo::URLRequestPtr request) { 127 mojo::URLRequestPtr request) {
126 web_view_->web_view()->LoadRequest(std::move(request)); 128 web_view_->web_view()->LoadRequest(std::move(request));
127 } 129 }
128 130
(...skipping 26 matching lines...) Expand all
155 //////////////////////////////////////////////////////////////////////////////// 157 ////////////////////////////////////////////////////////////////////////////////
156 // mojo::InterfaceFactory<LayoutTestRunner> implementation: 158 // mojo::InterfaceFactory<LayoutTestRunner> implementation:
157 159
158 void TestRunnerApplicationDelegate::Create( 160 void TestRunnerApplicationDelegate::Create(
159 mojo::ApplicationConnection* connection, 161 mojo::ApplicationConnection* connection,
160 mojo::InterfaceRequest<web_view::LayoutTestRunner> request) { 162 mojo::InterfaceRequest<web_view::LayoutTestRunner> request) {
161 layout_test_runner_.AddBinding(this, std::move(request)); 163 layout_test_runner_.AddBinding(this, std::move(request));
162 } 164 }
163 165
164 } // namespace web_view 166 } // namespace web_view
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698