OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/aura/test/aura_test_helper.h" | 5 #include "ui/aura/test/aura_test_helper.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 void AuraTestHelper::EnableMusWithWindowTreeClient( | 71 void AuraTestHelper::EnableMusWithWindowTreeClient( |
72 WindowTreeClient* window_tree_client) { | 72 WindowTreeClient* window_tree_client) { |
73 DCHECK(!setup_called_); | 73 DCHECK(!setup_called_); |
74 DCHECK_EQ(Mode::LOCAL, mode_); | 74 DCHECK_EQ(Mode::LOCAL, mode_); |
75 mode_ = Mode::MUS; | 75 mode_ = Mode::MUS; |
76 window_tree_client_ = window_tree_client; | 76 window_tree_client_ = window_tree_client; |
77 } | 77 } |
78 | 78 |
79 void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { | 79 void AuraTestHelper::SetUp(ui::ContextFactory* context_factory, |
| 80 ui::ContextFactoryPrivate* context_factory_private) { |
80 setup_called_ = true; | 81 setup_called_ = true; |
81 | 82 |
82 if (mode_ != Mode::MUS) { | 83 if (mode_ != Mode::MUS) { |
83 // Assume if an explicit WindowTreeClient was created then a WmState was | 84 // Assume if an explicit WindowTreeClient was created then a WmState was |
84 // already created. | 85 // already created. |
85 wm_state_ = base::MakeUnique<wm::WMState>(); | 86 wm_state_ = base::MakeUnique<wm::WMState>(); |
86 } | 87 } |
87 // Needs to be before creating WindowTreeClient. | 88 // Needs to be before creating WindowTreeClient. |
88 focus_client_ = base::MakeUnique<TestFocusClient>(); | 89 focus_client_ = base::MakeUnique<TestFocusClient>(); |
89 capture_client_ = base::MakeUnique<client::DefaultCaptureClient>(); | 90 capture_client_ = base::MakeUnique<client::DefaultCaptureClient>(); |
90 const Env::Mode env_mode = | 91 const Env::Mode env_mode = |
91 (mode_ == Mode::LOCAL) ? Env::Mode::LOCAL : Env::Mode::MUS; | 92 (mode_ == Mode::LOCAL) ? Env::Mode::LOCAL : Env::Mode::MUS; |
92 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) | 93 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) |
93 InitWindowTreeClient(); | 94 InitWindowTreeClient(); |
94 if (!Env::GetInstanceDontCreate()) | 95 if (!Env::GetInstanceDontCreate()) |
95 env_ = Env::CreateInstance(env_mode); | 96 env_ = Env::CreateInstance(env_mode); |
96 EnvTestHelper env_helper; | 97 EnvTestHelper env_helper; |
97 // Always reset the mode. This really only matters for if Env was created | 98 // Always reset the mode. This really only matters for if Env was created |
98 // above. | 99 // above. |
99 env_helper.SetMode(env_mode); | 100 env_helper.SetMode(env_mode); |
100 env_helper.SetWindowTreeClient(window_tree_client_); | 101 env_helper.SetWindowTreeClient(window_tree_client_); |
101 Env::GetInstance()->SetActiveFocusClient(focus_client_.get(), nullptr); | 102 Env::GetInstance()->SetActiveFocusClient(focus_client_.get(), nullptr); |
102 Env::GetInstance()->set_context_factory(context_factory); | 103 Env::GetInstance()->set_context_factory(context_factory); |
| 104 Env::GetInstance()->set_context_factory_private(context_factory_private); |
103 // Unit tests generally don't want to query the system, rather use the state | 105 // Unit tests generally don't want to query the system, rather use the state |
104 // from RootWindow. | 106 // from RootWindow. |
105 env_helper.SetInputStateLookup(nullptr); | 107 env_helper.SetInputStateLookup(nullptr); |
106 env_helper.ResetEventState(); | 108 env_helper.ResetEventState(); |
107 | 109 |
108 ui::InitializeInputMethodForTesting(); | 110 ui::InitializeInputMethodForTesting(); |
109 | 111 |
110 display::Screen* screen = display::Screen::GetScreen(); | 112 display::Screen* screen = display::Screen::GetScreen(); |
111 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel() | 113 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel() |
112 : gfx::Size(800, 600)); | 114 : gfx::Size(800, 600)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 176 |
175 void AuraTestHelper::InitWindowTreeClient() { | 177 void AuraTestHelper::InitWindowTreeClient() { |
176 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>(); | 178 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>(); |
177 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_, | 179 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_, |
178 window_manager_delegate_); | 180 window_manager_delegate_); |
179 window_tree_client_ = window_tree_client_setup_->window_tree_client(); | 181 window_tree_client_ = window_tree_client_setup_->window_tree_client(); |
180 } | 182 } |
181 | 183 |
182 } // namespace test | 184 } // namespace test |
183 } // namespace aura | 185 } // namespace aura |
OLD | NEW |