OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/mus/views_mus_test_suite.h" | 5 #include "ui/views/mus/views_mus_test_suite.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/threading/simple_thread.h" | 15 #include "base/threading/simple_thread.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "mojo/edk/embedder/embedder.h" | 17 #include "mojo/edk/embedder/embedder.h" |
18 #include "mojo/edk/embedder/scoped_ipc_support.h" | 18 #include "mojo/edk/embedder/scoped_ipc_support.h" |
19 #include "services/catalog/catalog.h" | 19 #include "services/catalog/catalog.h" |
20 #include "services/service_manager/background/background_service_manager.h" | 20 #include "services/service_manager/background/background_service_manager.h" |
21 #include "services/service_manager/public/cpp/connector.h" | 21 #include "services/service_manager/public/cpp/connector.h" |
22 #include "services/service_manager/public/cpp/service.h" | 22 #include "services/service_manager/public/cpp/service.h" |
23 #include "services/service_manager/public/cpp/service_context.h" | 23 #include "services/service_manager/public/cpp/service_context.h" |
24 #include "services/ui/common/switches.h" | 24 #include "services/ui/common/switches.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 #include "ui/aura/mus/window_tree_host_mus.h" | 26 #include "ui/aura/mus/window_tree_host_mus.h" |
27 #include "ui/aura/test/env_test_helper.h" | 27 #include "ui/aura/test/env_test_helper.h" |
28 #include "ui/aura/test/mus/input_method_mus_test_api.h" | 28 #include "ui/aura/test/mus/input_method_mus_test_api.h" |
29 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
| 30 #include "ui/compositor/test/fake_context_factory.h" |
30 #include "ui/gl/gl_switches.h" | 31 #include "ui/gl/gl_switches.h" |
31 #include "ui/views/mus/desktop_window_tree_host_mus.h" | 32 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
32 #include "ui/views/mus/mus_client.h" | 33 #include "ui/views/mus/mus_client.h" |
33 #include "ui/views/mus/test_utils.h" | 34 #include "ui/views/mus/test_utils.h" |
34 #include "ui/views/test/platform_test_helper.h" | 35 #include "ui/views/test/platform_test_helper.h" |
35 #include "ui/views/test/views_test_helper_aura.h" | 36 #include "ui/views/test/views_test_helper_aura.h" |
36 #include "ui/views/views_delegate.h" | 37 #include "ui/views/views_delegate.h" |
37 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 38 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
38 | 39 |
39 namespace views { | 40 namespace views { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 mus_client_->window_tree_client()); | 85 mus_client_->window_tree_client()); |
85 } | 86 } |
86 void SimulateNativeDestroy(Widget* widget) override { | 87 void SimulateNativeDestroy(Widget* widget) override { |
87 aura::WindowTreeHostMus* window_tree_host = | 88 aura::WindowTreeHostMus* window_tree_host = |
88 static_cast<aura::WindowTreeHostMus*>( | 89 static_cast<aura::WindowTreeHostMus*>( |
89 widget->GetNativeView()->GetHost()); | 90 widget->GetNativeView()->GetHost()); |
90 static_cast<aura::WindowTreeClientDelegate*>(mus_client_.get()) | 91 static_cast<aura::WindowTreeClientDelegate*>(mus_client_.get()) |
91 ->OnEmbedRootDestroyed(window_tree_host); | 92 ->OnEmbedRootDestroyed(window_tree_host); |
92 } | 93 } |
93 | 94 |
| 95 void InitializeContextFactory( |
| 96 ui::ContextFactory** context_factory, |
| 97 ui::ContextFactoryPrivate** context_factory_private) override { |
| 98 *context_factory = &context_factory_; |
| 99 *context_factory_private = nullptr; |
| 100 } |
| 101 |
94 private: | 102 private: |
95 NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params, | 103 NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params, |
96 internal::NativeWidgetDelegate* delegate) { | 104 internal::NativeWidgetDelegate* delegate) { |
97 NativeWidget* native_widget = | 105 NativeWidget* native_widget = |
98 mus_client_->CreateNativeWidget(init_params, delegate); | 106 mus_client_->CreateNativeWidget(init_params, delegate); |
99 if (!native_widget) | 107 if (!native_widget) |
100 return nullptr; | 108 return nullptr; |
101 | 109 |
102 // Disable sending KeyEvents to IME as tests aren't set up to wait for an | 110 // Disable sending KeyEvents to IME as tests aren't set up to wait for an |
103 // ack (and tests run concurrently). | 111 // ack (and tests run concurrently). |
104 aura::WindowTreeHostMus* window_tree_host_mus = | 112 aura::WindowTreeHostMus* window_tree_host_mus = |
105 static_cast<aura::WindowTreeHostMus*>( | 113 static_cast<aura::WindowTreeHostMus*>( |
106 static_cast<DesktopNativeWidgetAura*>(native_widget)->host()); | 114 static_cast<DesktopNativeWidgetAura*>(native_widget)->host()); |
107 aura::InputMethodMusTestApi::Disable(window_tree_host_mus->input_method()); | 115 aura::InputMethodMusTestApi::Disable(window_tree_host_mus->input_method()); |
108 return native_widget; | 116 return native_widget; |
109 } | 117 } |
110 | 118 |
111 std::unique_ptr<MusClient> mus_client_; | 119 std::unique_ptr<MusClient> mus_client_; |
| 120 ui::FakeContextFactory context_factory_; |
112 | 121 |
113 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); | 122 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); |
114 }; | 123 }; |
115 | 124 |
116 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( | 125 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( |
117 const service_manager::Identity& identity, | 126 const service_manager::Identity& identity, |
118 const base::Callback<service_manager::Connector*(void)>& callback) { | 127 const base::Callback<service_manager::Connector*(void)>& callback) { |
119 return base::MakeUnique<PlatformTestHelperMus>(callback.Run(), identity); | 128 return base::MakeUnique<PlatformTestHelperMus>(callback.Run(), identity); |
120 } | 129 } |
121 | 130 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 ViewsTestSuite::Initialize(); | 256 ViewsTestSuite::Initialize(); |
248 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); | 257 service_manager_connections_ = base::MakeUnique<ServiceManagerConnection>(); |
249 } | 258 } |
250 | 259 |
251 void ViewsMusTestSuite::Shutdown() { | 260 void ViewsMusTestSuite::Shutdown() { |
252 service_manager_connections_.reset(); | 261 service_manager_connections_.reset(); |
253 ViewsTestSuite::Shutdown(); | 262 ViewsTestSuite::Shutdown(); |
254 } | 263 } |
255 | 264 |
256 } // namespace views | 265 } // namespace views |
OLD | NEW |