OLD | NEW |
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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
33 #endif | 33 #endif |
34 | 34 |
35 namespace web_view { | 35 namespace web_view { |
36 | 36 |
37 TestRunnerApplicationDelegate::TestRunnerApplicationDelegate() | 37 TestRunnerApplicationDelegate::TestRunnerApplicationDelegate() |
38 : app_(nullptr), root_(nullptr), content_(nullptr) {} | 38 : app_(nullptr), root_(nullptr), content_(nullptr) {} |
39 | 39 |
40 TestRunnerApplicationDelegate::~TestRunnerApplicationDelegate() { | 40 TestRunnerApplicationDelegate::~TestRunnerApplicationDelegate() { |
41 if (root_) | 41 if (root_) |
42 mojo::ScopedViewPtr::DeleteViewOrViewManager(root_); | 42 mus::ScopedViewPtr::DeleteViewOrViewManager(root_); |
43 } | 43 } |
44 | 44 |
45 void TestRunnerApplicationDelegate::LaunchURL(const GURL& test_url) { | 45 void TestRunnerApplicationDelegate::LaunchURL(const GURL& test_url) { |
46 if (!web_view_) { | 46 if (!web_view_) { |
47 web_view_.reset(new WebView(this)); | 47 web_view_.reset(new WebView(this)); |
48 web_view_->Init(app_, content_); | 48 web_view_->Init(app_, content_); |
49 } | 49 } |
50 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 50 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
51 request->url = test_url.spec(); | 51 request->url = test_url.spec(); |
52 web_view_->web_view()->LoadRequest(request.Pass()); | 52 web_view_->web_view()->LoadRequest(request.Pass()); |
53 } | 53 } |
54 | 54 |
55 void TestRunnerApplicationDelegate::Terminate() { | 55 void TestRunnerApplicationDelegate::Terminate() { |
56 if (root_) | 56 if (root_) |
57 mojo::ScopedViewPtr::DeleteViewOrViewManager(root_); | 57 mus::ScopedViewPtr::DeleteViewOrViewManager(root_); |
58 } | 58 } |
59 | 59 |
60 //////////////////////////////////////////////////////////////////////////////// | 60 //////////////////////////////////////////////////////////////////////////////// |
61 // mojo::ApplicationDelegate implementation: | 61 // mojo::ApplicationDelegate implementation: |
62 | 62 |
63 void TestRunnerApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { | 63 void TestRunnerApplicationDelegate::Initialize(mojo::ApplicationImpl* app) { |
64 app_ = app; | 64 app_ = app; |
65 mojo::CreateSingleViewTreeHost(app_, this, &host_); | 65 mus::CreateSingleViewTreeHost(app_, this, &host_); |
66 } | 66 } |
67 | 67 |
68 bool TestRunnerApplicationDelegate::ConfigureIncomingConnection( | 68 bool TestRunnerApplicationDelegate::ConfigureIncomingConnection( |
69 mojo::ApplicationConnection* connection) { | 69 mojo::ApplicationConnection* connection) { |
70 connection->AddService<web_view::LayoutTestRunner>(this); | 70 connection->AddService<web_view::LayoutTestRunner>(this); |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 //////////////////////////////////////////////////////////////////////////////// | 74 //////////////////////////////////////////////////////////////////////////////// |
75 // mojo::ViewTreeDelegate implementation: | 75 // mus::ViewTreeDelegate implementation: |
76 | 76 |
77 void TestRunnerApplicationDelegate::OnEmbed(mojo::View* root) { | 77 void TestRunnerApplicationDelegate::OnEmbed(mus::View* root) { |
78 root_ = root; | 78 root_ = root; |
79 | 79 |
80 // If this is a sys-check, then terminate in the next cycle. | 80 // If this is a sys-check, then terminate in the next cycle. |
81 const char kCheckLayoutTestSysDeps[] = "check-layout-test-sys-deps"; | 81 const char kCheckLayoutTestSysDeps[] = "check-layout-test-sys-deps"; |
82 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 82 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
83 kCheckLayoutTestSysDeps)) { | 83 kCheckLayoutTestSysDeps)) { |
84 base::ThreadTaskRunnerHandle::Get()->PostTask( | 84 base::ThreadTaskRunnerHandle::Get()->PostTask( |
85 FROM_HERE, base::Bind(&TestRunnerApplicationDelegate::Terminate, | 85 FROM_HERE, base::Bind(&TestRunnerApplicationDelegate::Terminate, |
86 base::Unretained(this))); | 86 base::Unretained(this))); |
87 return; | 87 return; |
(...skipping 12 matching lines...) Expand all Loading... |
100 | 100 |
101 auto cmdline_args = base::CommandLine::ForCurrentProcess()->GetArgs(); | 101 auto cmdline_args = base::CommandLine::ForCurrentProcess()->GetArgs(); |
102 test_extractor_.reset(new test_runner::TestInfoExtractor(cmdline_args)); | 102 test_extractor_.reset(new test_runner::TestInfoExtractor(cmdline_args)); |
103 | 103 |
104 scoped_ptr<test_runner::TestInfo> test_info = test_extractor_->GetNextTest(); | 104 scoped_ptr<test_runner::TestInfo> test_info = test_extractor_->GetNextTest(); |
105 if (test_info) | 105 if (test_info) |
106 LaunchURL(test_info->url); | 106 LaunchURL(test_info->url); |
107 } | 107 } |
108 | 108 |
109 void TestRunnerApplicationDelegate::OnConnectionLost( | 109 void TestRunnerApplicationDelegate::OnConnectionLost( |
110 mojo::ViewTreeConnection* connection) { | 110 mus::ViewTreeConnection* connection) { |
111 root_ = nullptr; | 111 root_ = nullptr; |
112 app_->Quit(); | 112 app_->Quit(); |
113 } | 113 } |
114 | 114 |
115 //////////////////////////////////////////////////////////////////////////////// | 115 //////////////////////////////////////////////////////////////////////////////// |
116 // mojom::WebViewClient implementation: | 116 // mojom::WebViewClient implementation: |
117 | 117 |
118 void TestRunnerApplicationDelegate::TopLevelNavigate( | 118 void TestRunnerApplicationDelegate::TopLevelNavigate( |
119 mojo::URLRequestPtr request) { | 119 mojo::URLRequestPtr request) { |
120 web_view_->web_view()->LoadRequest(request.Pass()); | 120 web_view_->web_view()->LoadRequest(request.Pass()); |
(...skipping 26 matching lines...) Expand all Loading... |
147 //////////////////////////////////////////////////////////////////////////////// | 147 //////////////////////////////////////////////////////////////////////////////// |
148 // mojo::InterfaceFactory<LayoutTestRunner> implementation: | 148 // mojo::InterfaceFactory<LayoutTestRunner> implementation: |
149 | 149 |
150 void TestRunnerApplicationDelegate::Create( | 150 void TestRunnerApplicationDelegate::Create( |
151 mojo::ApplicationConnection* connection, | 151 mojo::ApplicationConnection* connection, |
152 mojo::InterfaceRequest<web_view::LayoutTestRunner> request) { | 152 mojo::InterfaceRequest<web_view::LayoutTestRunner> request) { |
153 layout_test_runner_.AddBinding(this, request.Pass()); | 153 layout_test_runner_.AddBinding(this, request.Pass()); |
154 } | 154 } |
155 | 155 |
156 } // namespace web_view | 156 } // namespace web_view |
OLD | NEW |