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