blob: fe561bce83ac368ff3c323d6df6e94a3c619a68f [file] [log] [blame]
[email protected]09464c72013-04-26 07:31:281// Copyright 2013 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 "ash/test/ash_test_helper.h"
6
xiyuan317fdbe2017-05-31 15:02:027#include <algorithm>
Mitsuru Oshima04b54d02017-10-09 14:22:458#include <memory>
xiyuan317fdbe2017-05-31 15:02:029#include <set>
Scott Violetc8a1c6c2017-11-29 23:17:3610#include <utility>
xiyuan317fdbe2017-05-31 15:02:0211
Scott Violet42d6695782018-06-04 16:12:1712#include "ash/app_list/test/app_list_test_helper.h"
James Cook346c8c62017-07-18 19:38:3713#include "ash/display/display_configuration_controller_test_api.h"
James Cookd3cf52c2018-05-24 14:57:3014#include "ash/display/screen_ash.h"
Steven Bennetts99f5b692018-11-27 16:31:4015#include "ash/keyboard/ash_keyboard_controller.h"
Jun Mukaif2357792018-12-20 19:58:0016#include "ash/keyboard/test_keyboard_ui.h"
Scott Violet38fe2882018-07-24 23:02:0817#include "ash/mojo_test_interface_factory.h"
Evan Stade7d0e8232017-10-04 02:01:3618#include "ash/public/cpp/ash_switches.h"
Steven Bennetts99f5b692018-11-27 16:31:4019#include "ash/public/cpp/test/test_keyboard_controller_observer.h"
Scott Violet42d6695782018-06-04 16:12:1720#include "ash/session/test_session_controller_client.h"
[email protected]09464c72013-04-26 07:31:2821#include "ash/shell.h"
[email protected]1b4c7472014-05-15 18:32:2322#include "ash/shell_init_params.h"
James Cooka35a1e22017-04-08 02:33:0823#include "ash/system/screen_layout_observer.h"
[email protected]93e828f2014-05-14 14:08:1124#include "ash/test/ash_test_views_delegate.h"
James Cook346c8c62017-07-18 19:38:3725#include "ash/test_shell_delegate.h"
Sammie Quon8bac8282019-03-30 03:06:4626#include "ash/wm/overview/overview_controller.h"
Scott Violet42d6695782018-06-04 16:12:1727#include "ash/ws/window_service_owner.h"
Sebastien Marchand6d0558fd2019-01-25 16:49:3728#include "base/bind.h"
Scott Violet42d6695782018-06-04 16:12:1729#include "base/guid.h"
[email protected]09464c72013-04-26 07:31:2830#include "base/run_loop.h"
skyd06586d2017-02-22 17:46:3631#include "base/strings/string_split.h"
Ken Rockotda7edc62018-11-10 01:01:4532#include "base/token.h"
jamescooke96488a2017-01-20 15:49:4433#include "chromeos/audio/cras_audio_handler.h"
Steven Bennetts10ecd9d2019-04-08 20:36:4634#include "chromeos/dbus/cras_audio_client.h"
jamescooke96488a2017-01-20 15:49:4435#include "chromeos/dbus/dbus_thread_manager.h"
Steven Bennetts3330b9f2019-03-15 20:24:1336#include "chromeos/dbus/power/power_policy_controller.h"
skyeeccd7e2017-03-22 23:24:1837#include "chromeos/network/network_handler.h"
Scott Violetbd945752018-09-28 23:42:0338#include "chromeos/system/fake_statistics_provider.h"
Scott Violet176346002018-09-13 21:20:1739#include "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom.h"
Sam McNallya853cd82017-08-30 01:55:1040#include "components/prefs/testing_pref_service.h"
jamescooke96488a2017-01-20 15:49:4441#include "device/bluetooth/bluetooth_adapter_factory.h"
42#include "device/bluetooth/dbus/bluez_dbus_manager.h"
Scott Violet42d6695782018-06-04 16:12:1743#include "mojo/public/cpp/bindings/binding_set.h"
44#include "mojo/public/cpp/bindings/interface_request.h"
45#include "services/service_manager/public/cpp/bind_source_info.h"
46#include "services/service_manager/public/cpp/connector.h"
47#include "services/service_manager/public/cpp/identity.h"
48#include "services/service_manager/public/cpp/service.h"
Scott Violet176346002018-09-13 21:20:1749#include "services/ws/public/cpp/host/gpu_interface_provider.h"
Ken Rockot414710a2018-11-12 23:30:4650#include "services/ws/public/mojom/constants.mojom.h"
Scott Violet176346002018-09-13 21:20:1751#include "services/ws/public/mojom/gpu.mojom.h"
Scott Violet9f984252018-08-27 19:02:1352#include "services/ws/window_service.h"
[email protected]09464c72013-04-26 07:31:2853#include "ui/aura/env.h"
[email protected]ccf28b82013-10-14 17:19:1554#include "ui/aura/input_state_lookup.h"
55#include "ui/aura/test/env_test_helper.h"
[email protected]1f0ece912014-08-11 05:52:2056#include "ui/aura/test/event_generator_delegate_aura.h"
Scott Violetac410622018-08-11 18:33:2257#include "ui/aura/test/test_windows.h"
58#include "ui/aura/window.h"
Michael Spang539c6f32019-04-03 19:08:5259#include "ui/base/ime/init/input_method_initializer.h"
varkha0b40cc392016-04-14 01:13:0560#include "ui/base/material_design/material_design_controller.h"
kylechare4030ae2017-02-10 22:36:0861#include "ui/base/platform_window_defaults.h"
Scott Violet8ff9c302018-02-22 22:28:3562#include "ui/base/ui_base_features.h"
Sadrul Habib Chowdhuryf3bc4512017-12-06 06:25:2163#include "ui/base/ui_base_switches_util.h"
[email protected]09464c72013-04-26 07:31:2864#include "ui/compositor/scoped_animation_duration_scale_mode.h"
[email protected]f6333942013-10-30 17:32:5565#include "ui/compositor/test/context_factories_for_test.h"
varkhac8621dd2017-05-31 19:09:0166#include "ui/display/display.h"
wutaob161bf22017-04-26 16:55:0367#include "ui/display/display_switches.h"
skyd06586d2017-02-22 17:46:3668#include "ui/display/manager/display_manager.h"
varkhac8621dd2017-05-31 19:09:0169#include "ui/display/screen.h"
rjkroege72f8154f2016-10-29 00:49:0270#include "ui/display/test/display_manager_test_api.h"
Scott Violet7935e442018-12-13 18:29:4671#include "ui/views/mus/mus_client.h"
[email protected]ee3ed10772014-03-11 22:02:0172#include "ui/wm/core/capture_controller.h"
anantaf2b280f2016-04-13 21:49:3573#include "ui/wm/core/cursor_manager.h"
skyf8fcebc2016-10-27 18:34:1374#include "ui/wm/core/wm_state.h"
[email protected]09464c72013-04-26 07:31:2875
76namespace ash {
[email protected]09464c72013-04-26 07:31:2877
Scott Violet176346002018-09-13 21:20:1778// An implementation of GpuInterfaceProvider that queues up requests for
79// interfaces. The requests are never actually bound, but are kept alive to
80// ensure the requestor doesn't detect a close and try to exit.
81class TestGpuInterfaceProvider : public ws::GpuInterfaceProvider {
82 public:
83 TestGpuInterfaceProvider() = default;
84 ~TestGpuInterfaceProvider() override = default;
85
86 // ws::GpuInterfaceProvider:
87 void RegisterGpuInterfaces(
88 service_manager::BinderRegistry* registry) override {
89 registry->AddInterface(base::BindRepeating(
90 &TestGpuInterfaceProvider::BindDiscardableSharedMemoryManager,
91 base::Unretained(this)));
92 registry->AddInterface(base::BindRepeating(
93 &TestGpuInterfaceProvider::BindGpuRequest, base::Unretained(this)));
94 }
Mohsen Izadi3c71a9b2019-01-23 01:22:0095 void BindOzoneGpuInterface(const std::string& interface_name,
96 mojo::ScopedMessagePipeHandle handle) override {}
Scott Violet176346002018-09-13 21:20:1797
98 private:
99 void BindDiscardableSharedMemoryManager(
100 discardable_memory::mojom::DiscardableSharedMemoryManagerRequest
101 request) {
102 request_handles_.push_back(request.PassMessagePipe());
103 }
104 void BindGpuRequest(ws::mojom::GpuRequest request) {
105 request_handles_.push_back(request.PassMessagePipe());
106 }
107
108 std::vector<mojo::ScopedMessagePipeHandle> request_handles_;
109
110 DISALLOW_COPY_AND_ASSIGN(TestGpuInterfaceProvider);
111};
112
Scott Violet6ac56412018-12-19 17:25:50113AshTestHelper::AshTestHelper()
114 : command_line_(std::make_unique<base::test::ScopedCommandLine>()) {
kylechare4030ae2017-02-10 22:36:08115 ui::test::EnableTestConfigForPlatformWindows();
[email protected]09464c72013-04-26 07:31:28116}
117
James Cookd3cf52c2018-05-24 14:57:30118AshTestHelper::~AshTestHelper() {
119 // Ensure the next test starts with a null display::Screen. Done here because
120 // some tests use Screen after TearDown().
121 ScreenAsh::DeleteScreenForShutdown();
122}
[email protected]09464c72013-04-26 07:31:28123
Sam McNallya853cd82017-08-30 01:55:10124void AshTestHelper::SetUp(bool start_session, bool provide_local_state) {
Scott Violetac410622018-08-11 18:33:22125#if !defined(NDEBUG)
126 aura::Window::SetEnvArgRequired(
127 "Within ash you must supply a non-null aura::Env when creating a Window, "
128 "use window_factory, or supply the Env obtained from "
129 "Shell::Get()->aura_env()");
130#endif
131
wutaob161bf22017-04-26 16:55:03132 // TODO(jamescook): Can we do this without changing command line?
133 // Use the origin (1,1) so that it doesn't over
134 // lap with the native mouse cursor.
135 if (!command_line_->GetProcessCommandLine()->HasSwitch(
136 ::switches::kHostWindowBounds)) {
137 command_line_->GetProcessCommandLine()->AppendSwitchASCII(
138 ::switches::kHostWindowBounds, "1+1-800x600");
139 }
140
Scott Violetbd945752018-09-28 23:42:03141 statistics_provider_ =
142 std::make_unique<chromeos::system::ScopedFakeStatisticsProvider>();
143
Scott Violet03467432018-08-28 22:11:39144 ui::test::EventGeneratorDelegate::SetFactoryFunction(base::BindRepeating(
145 &aura::test::EventGeneratorDelegateAura::Create, nullptr));
Scott Violet9aafab62018-08-28 20:46:34146
rjkroege259c01882016-08-30 19:29:50147 display::ResetDisplayIdForTest();
Scott Violetc43ea0c62018-07-20 15:13:00148 wm_state_ = std::make_unique<::wm::WMState>();
Scott Violet6ac56412018-12-19 17:25:50149 // Only create a ViewsDelegate if the test didn't create one already.
150 if (!views::ViewsDelegate::GetInstance())
151 test_views_delegate_ = std::make_unique<AshTestViewsDelegate>();
[email protected]ef663fa2013-12-20 17:55:00152
[email protected]09464c72013-04-26 07:31:28153 // Disable animations during tests.
154 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
155 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
[email protected]749bf6432013-06-12 16:00:08156 ui::InitializeInputMethodForTesting();
[email protected]09464c72013-04-26 07:31:28157
158 // Creates Shell and hook with Desktop.
[email protected]b2e2a4a2014-03-15 05:39:28159 if (!test_shell_delegate_)
160 test_shell_delegate_ = new TestShellDelegate;
[email protected]09464c72013-04-26 07:31:28161
Scott Violetc43ea0c62018-07-20 15:13:00162 if (!chromeos::DBusThreadManager::IsInitialized()) {
163 chromeos::DBusThreadManager::Initialize(
164 chromeos::DBusThreadManager::kShared);
Scott Violetc43ea0c62018-07-20 15:13:00165 dbus_thread_manager_initialized_ = true;
[email protected]f08f39b2013-12-19 06:14:11166 }
rkc06c92c02015-11-05 01:55:40167
Scott Violetc43ea0c62018-07-20 15:13:00168 if (!bluez::BluezDBusManager::IsInitialized()) {
Giovanni Ortuño Urquidi506d9332018-09-24 22:56:38169 bluez::BluezDBusManager::Initialize();
Scott Violetc43ea0c62018-07-20 15:13:00170 bluez_dbus_manager_initialized_ = true;
171 }
172
Steven Bennettsb95d2d42019-03-19 17:03:49173 chromeos::PowerManagerClient::InitializeFake();
Evan Stade523f7fc2019-03-02 19:20:51174
Scott Violetc43ea0c62018-07-20 15:13:00175 if (!chromeos::PowerPolicyController::IsInitialized()) {
176 chromeos::PowerPolicyController::Initialize(
Evan Stade523f7fc2019-03-02 19:20:51177 chromeos::PowerManagerClient::Get());
Scott Violetc43ea0c62018-07-20 15:13:00178 power_policy_controller_initialized_ = true;
179 }
180
Steven Bennetts10ecd9d2019-04-08 20:36:46181 chromeos::CrasAudioClient::InitializeFake();
Scott Violetc43ea0c62018-07-20 15:13:00182 // Create CrasAudioHandler for testing since g_browser_process is not
183 // created in AshTestBase tests.
184 chromeos::CrasAudioHandler::InitializeForTesting();
Scott Violetc43ea0c62018-07-20 15:13:00185
anantaf2b280f2016-04-13 21:49:35186 // Reset the global state for the cursor manager. This includes the
187 // last cursor visibility state, etc.
sky984c1892016-04-20 00:00:34188 ::wm::CursorManager::ResetCursorVisibilityStateForTest();
anantaf2b280f2016-04-13 21:49:35189
varkha0b40cc392016-04-14 01:13:05190 ui::MaterialDesignController::Initialize();
mohsenc66d6872016-07-30 01:46:08191
Scott Violetc43ea0c62018-07-20 15:13:00192 CreateShell();
skyd06586d2017-02-22 17:46:36193
Andrew Xu6d7f4392018-11-01 23:25:47194 // Reset aura::Env to eliminate test dependency (https://crbug.com/586514).
195 aura::test::EnvTestHelper env_helper(Shell::Get()->aura_env());
196 env_helper.ResetEnvForTesting();
197
Scott Violetac410622018-08-11 18:33:22198 aura::test::SetEnvForTestWindows(Shell::Get()->aura_env());
199
Andrew Xu6d7f4392018-11-01 23:25:47200 env_helper.SetInputStateLookup(std::unique_ptr<aura::InputStateLookup>());
[email protected]ccf28b82013-10-14 17:19:15201
skycb4be5b2017-04-06 17:52:45202 Shell* shell = Shell::Get();
Mitsuru Oshimaccfa74c2018-02-01 17:43:24203
204 // Cursor is visible by default in tests.
205 // CursorManager is null on MASH.
206 if (shell->cursor_manager())
207 shell->cursor_manager()->ShowCursor();
208
Sam McNallya853cd82017-08-30 01:55:10209 if (provide_local_state) {
Mitsuru Oshima04b54d02017-10-09 14:22:45210 auto pref_service = std::make_unique<TestingPrefServiceSimple>();
Steven Bennettsca108512018-05-02 11:05:03211 Shell::RegisterLocalStatePrefs(pref_service->registry(), true);
Sam McNallya853cd82017-08-30 01:55:10212 Shell::Get()->OnLocalStatePrefServiceInitialized(std::move(pref_service));
213 }
214
xiyuanf1ff14d2017-03-20 20:28:14215 session_controller_client_.reset(
skycb4be5b2017-04-06 17:52:45216 new TestSessionControllerClient(shell->session_controller()));
xiyuanf1ff14d2017-03-20 20:28:14217 session_controller_client_->InitializeAndBind();
218
Scott Violet176346002018-09-13 21:20:17219 if (start_session)
xiyuanf1ff14d2017-03-20 20:28:14220 session_controller_client_->CreatePredefinedUserSessions(1);
[email protected]ad2f5df2013-07-02 08:21:56221
Scott Violet596bb46342017-06-21 14:43:13222 // Tests that change the display configuration generally don't care about
223 // the notifications and the popup UI can interfere with things like
224 // cursors.
225 shell->screen_layout_observer()->set_show_notifications_for_testing(false);
jamescookf60d6ea2016-10-11 21:37:37226
Scott Violet596bb46342017-06-21 14:43:13227 display::test::DisplayManagerTestApi(shell->display_manager())
228 .DisableChangeDisplayUponHostResize();
229 DisplayConfigurationControllerTestApi(
230 shell->display_configuration_controller())
Steven Bennettsc5acf572018-08-16 19:58:53231 .SetDisplayAnimator(false);
Jiaquan Hedbfd4512018-03-02 02:16:38232
233 app_list_test_helper_ = std::make_unique<AppListTestHelper>();
Scott Violet42d6695782018-06-04 16:12:17234
Scott Violetc43ea0c62018-07-20 15:13:00235 CreateWindowService();
Steven Bennetts99f5b692018-11-27 16:31:40236
237 // Create the test keyboard controller observer to respond to
Darren Shenb67cd89f2019-03-11 00:35:24238 // OnLoadKeyboardContentsRequested().
Steven Bennetts99f5b692018-11-27 16:31:40239 test_keyboard_controller_observer_ =
240 std::make_unique<TestKeyboardControllerObserver>(
241 shell->ash_keyboard_controller());
Sammie Quon8bac8282019-03-30 03:06:46242
243 // Remove the app dragging animations delay for testing purposes.
244 shell->overview_controller()->set_delayed_animation_task_delay_for_test(
245 base::TimeDelta());
[email protected]09464c72013-04-26 07:31:28246}
247
248void AshTestHelper::TearDown() {
Scott Violet7935e442018-12-13 18:29:46249 mus_client_.reset();
250 window_tree_client_setter_.reset();
251
Steven Bennetts99f5b692018-11-27 16:31:40252 test_keyboard_controller_observer_.reset();
Jiaquan Hedbfd4512018-03-02 02:16:38253 app_list_test_helper_.reset();
254
Scott Violetac410622018-08-11 18:33:22255 aura::test::SetEnvForTestWindows(nullptr);
256
Scott Violetc43ea0c62018-07-20 15:13:00257 Shell::DeleteInstance();
starazd8f4f642016-12-10 23:49:20258
259 // Suspend the tear down until all resources are returned via
danakj2e3aca02017-06-23 22:58:52260 // CompositorFrameSinkClient::ReclaimResources()
Steven Bennettsa1f686d2018-06-05 18:01:19261 base::RunLoop().RunUntilIdle();
benb91330f2015-10-03 22:20:18262
Scott Violetc43ea0c62018-07-20 15:13:00263 chromeos::CrasAudioHandler::Shutdown();
Steven Bennetts10ecd9d2019-04-08 20:36:46264 chromeos::CrasAudioClient::Shutdown();
skyd06586d2017-02-22 17:46:36265
Qiang Xu36234e532018-04-11 04:54:02266 if (power_policy_controller_initialized_) {
267 chromeos::PowerPolicyController::Shutdown();
268 power_policy_controller_initialized_ = false;
269 }
270
Evan Stade523f7fc2019-03-02 19:20:51271 chromeos::PowerManagerClient::Shutdown();
272
rkc06c92c02015-11-05 01:55:40273 if (bluez_dbus_manager_initialized_) {
skycf094f672016-09-01 19:40:12274 device::BluetoothAdapterFactory::Shutdown();
rkc06c92c02015-11-05 01:55:40275 bluez::BluezDBusManager::Shutdown();
276 bluez_dbus_manager_initialized_ = false;
277 }
skyd06586d2017-02-22 17:46:36278
[email protected]f08f39b2013-12-19 06:14:11279 if (dbus_thread_manager_initialized_) {
[email protected]f08f39b2013-12-19 06:14:11280 chromeos::DBusThreadManager::Shutdown();
281 dbus_thread_manager_initialized_ = false;
282 }
[email protected]6d8c8f02013-05-13 17:33:12283
Scott Violetc43ea0c62018-07-20 15:13:00284 ui::TerminateContextFactoryForTests();
[email protected]09464c72013-04-26 07:31:28285
Scott Violet176346002018-09-13 21:20:17286 // ui::TerminateContextFactoryForTests() destroyed the context factory (and
287 // context factory private) referenced by Env. Reset Env's members in case
288 // some other test tries to use it. This matters if someone else created Env
289 // (such as the test suite) and is long lived.
290 if (aura::Env::HasInstance()) {
291 aura::Env::GetInstance()->set_context_factory(nullptr);
292 aura::Env::GetInstance()->set_context_factory_private(nullptr);
293 }
294
[email protected]749bf6432013-06-12 16:00:08295 ui::ShutdownInputMethodForTesting();
[email protected]09464c72013-04-26 07:31:28296 zero_duration_mode_.reset();
[email protected]23a2dc8d2013-08-22 15:04:22297
kylixrd4e8cac42017-04-13 17:15:56298 test_views_delegate_.reset();
skyc0900322016-11-01 04:52:43299 wm_state_.reset();
300
wutaob161bf22017-04-26 16:55:03301 command_line_.reset();
302
Mitsuru Oshimab61a2642017-09-01 17:41:02303 display::Display::ResetForceDeviceScaleFactorForTesting();
304
Scott Violetc43ea0c62018-07-20 15:13:00305 CHECK(!::wm::CaptureController::Get());
Scott Violetac410622018-08-11 18:33:22306#if !defined(NDEBUG)
307 aura::Window::SetEnvArgRequired(nullptr);
308#endif
Scott Violet9aafab62018-08-28 20:46:34309
310 ui::test::EventGeneratorDelegate::SetFactoryFunction(
311 ui::test::EventGeneratorDelegate::FactoryFunction());
Scott Violetbd945752018-09-28 23:42:03312
313 statistics_provider_.reset();
Scott Violetac410622018-08-11 18:33:22314}
315
316void AshTestHelper::SetRunningOutsideAsh() {
317 test_views_delegate_->set_running_outside_ash();
318#if DCHECK_IS_ON()
319 aura::Window::SetEnvArgRequired(nullptr);
320#endif
[email protected]09464c72013-04-26 07:31:28321}
322
Steven Bennettse1b13b82018-04-02 15:51:00323PrefService* AshTestHelper::GetLocalStatePrefService() {
324 return Shell::Get()->local_state_.get();
325}
326
[email protected]bf9cdb362013-10-25 19:22:45327aura::Window* AshTestHelper::CurrentContext() {
sky27344382017-03-08 21:30:32328 aura::Window* root_window = Shell::GetRootWindowForNewWindows();
[email protected]09464c72013-04-26 07:31:28329 if (!root_window)
330 root_window = Shell::GetPrimaryRootWindow();
331 DCHECK(root_window);
332 return root_window;
333}
334
skyd06586d2017-02-22 17:46:36335display::Display AshTestHelper::GetSecondaryDisplay() {
Scott Violet596bb46342017-06-21 14:43:13336 return Shell::Get()->display_manager()->GetSecondaryDisplay();
skyd06586d2017-02-22 17:46:36337}
338
Scott Violet38fe2882018-07-24 23:02:08339service_manager::Connector* AshTestHelper::GetWindowServiceConnector() {
340 return window_service_connector_.get();
341}
342
Scott Violet7935e442018-12-13 18:29:46343void AshTestHelper::CreateMusClient() {
344 DCHECK(!mus_client_);
345 // Set aura::Env's WindowTreeClient to null. This is necessary as code such
346 // as AshTestBase may have already installed a WindowTreeClient.
347 window_tree_client_setter_ =
348 std::make_unique<aura::test::EnvWindowTreeClientSetter>(nullptr);
349 // As EnvWindowTreeClientSetter sets aura::Env's WindowTreeClient to null, it
350 // also sets Env::in_mus_shutdown_ to false. Env isn't in shutdown at this
351 // point, so force it to false.
352 aura::test::EnvTestHelper().SetInMusShutdown(false);
353
354 // Configure views backed by mus.
355 views::MusClient::InitParams mus_client_init_params;
356 mus_client_init_params.connector = GetWindowServiceConnector();
357 mus_client_init_params.create_wm_state = false;
358 mus_client_init_params.running_in_ws_process = true;
359 mus_client_ = std::make_unique<views::MusClient>(mus_client_init_params);
360}
361
Scott Violet42d6695782018-06-04 16:12:17362void AshTestHelper::CreateWindowService() {
Scott Violet42d6695782018-06-04 16:12:17363 Shell::Get()->window_service_owner()->BindWindowService(
Ken Rockot414710a2018-11-12 23:30:46364 test_connector_factory_.RegisterInstance(ws::mojom::kServiceName));
365
Scott Violet42d6695782018-06-04 16:12:17366 // WindowService::OnStart() is not immediately called (it happens async over
367 // mojo). If this becomes a problem we could run the MessageLoop here.
368 // Surprisingly running the MessageLooop results in some test failures. These
369 // failures seem to be because spinning the messageloop causes some timers to
370 // fire (perhaps animations too) the results in a slightly different Shell
371 // state.
Ken Rockot414710a2018-11-12 23:30:46372 window_service_connector_ = test_connector_factory_.CreateConnector();
Scott Violet42d6695782018-06-04 16:12:17373}
374
skyd06586d2017-02-22 17:46:36375void AshTestHelper::CreateShell() {
skyd06586d2017-02-22 17:46:36376 ui::ContextFactory* context_factory = nullptr;
377 ui::ContextFactoryPrivate* context_factory_private = nullptr;
378 bool enable_pixel_output = false;
379 ui::InitializeContextFactoryForTests(enable_pixel_output, &context_factory,
380 &context_factory_private);
381 ShellInitParams init_params;
Scott Violetc8a1c6c2017-11-29 23:17:36382 init_params.delegate.reset(test_shell_delegate_);
skyd06586d2017-02-22 17:46:36383 init_params.context_factory = context_factory;
384 init_params.context_factory_private = context_factory_private;
Scott Violet176346002018-09-13 21:20:17385 init_params.gpu_interface_provider =
386 std::make_unique<TestGpuInterfaceProvider>();
Jun Mukaif2357792018-12-20 19:58:00387 init_params.keyboard_ui_factory = std::make_unique<TestKeyboardUIFactory>();
Scott Violetc8a1c6c2017-11-29 23:17:36388 Shell::CreateInstance(std::move(init_params));
skyd06586d2017-02-22 17:46:36389}
390
[email protected]09464c72013-04-26 07:31:28391} // namespace ash