Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: components/mus/ws/window_manager_state_unittest.cc

Issue 1906623003: Convert //components/mus from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/ws/window_manager_state.cc ('k') | components/mus/ws/window_server.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/mus/ws/window_manager_state.h" 5 #include "components/mus/ws/window_manager_state.h"
6 6
7 #include <memory>
8
7 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h"
8 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/test/test_simple_task_runner.h" 12 #include "base/test/test_simple_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
12 #include "components/mus/public/cpp/event_matcher.h" 14 #include "components/mus/public/cpp/event_matcher.h"
13 #include "components/mus/surfaces/surfaces_state.h" 15 #include "components/mus/surfaces/surfaces_state.h"
14 #include "components/mus/ws/accelerator.h" 16 #include "components/mus/ws/accelerator.h"
15 #include "components/mus/ws/display_binding.h" 17 #include "components/mus/ws/display_binding.h"
16 #include "components/mus/ws/platform_display.h" 18 #include "components/mus/ws/platform_display.h"
17 #include "components/mus/ws/platform_display_init_params.h" 19 #include "components/mus/ws/platform_display_init_params.h"
18 #include "components/mus/ws/server_window_surface_manager_test_api.h" 20 #include "components/mus/ws/server_window_surface_manager_test_api.h"
19 #include "components/mus/ws/test_change_tracker.h" 21 #include "components/mus/ws/test_change_tracker.h"
20 #include "components/mus/ws/test_server_window_delegate.h" 22 #include "components/mus/ws/test_server_window_delegate.h"
21 #include "components/mus/ws/test_utils.h" 23 #include "components/mus/ws/test_utils.h"
22 #include "components/mus/ws/window_manager_access_policy.h" 24 #include "components/mus/ws/window_manager_access_policy.h"
23 #include "components/mus/ws/window_manager_state.h" 25 #include "components/mus/ws/window_manager_state.h"
24 #include "components/mus/ws/window_server.h" 26 #include "components/mus/ws/window_server.h"
25 #include "components/mus/ws/window_tree.h" 27 #include "components/mus/ws/window_tree.h"
26 #include "services/shell/public/interfaces/connector.mojom.h" 28 #include "services/shell/public/interfaces/connector.mojom.h"
27 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/events/event.h" 30 #include "ui/events/event.h"
29 31
30 namespace mus { 32 namespace mus {
31 namespace ws { 33 namespace ws {
32 namespace test { 34 namespace test {
33 35
34 class WindowManagerStateTest : public testing::Test { 36 class WindowManagerStateTest : public testing::Test {
35 public: 37 public:
36 WindowManagerStateTest(); 38 WindowManagerStateTest();
37 ~WindowManagerStateTest() override {} 39 ~WindowManagerStateTest() override {}
38 40
39 scoped_ptr<Accelerator> CreateAccelerator(); 41 std::unique_ptr<Accelerator> CreateAccelerator();
40 42
41 // Creates a child |server_window| with associataed |window_tree| and 43 // Creates a child |server_window| with associataed |window_tree| and
42 // |test_client|. The window is setup for processing input. 44 // |test_client|. The window is setup for processing input.
43 void CreateSecondaryTree(TestWindowTreeClient** test_client, 45 void CreateSecondaryTree(TestWindowTreeClient** test_client,
44 WindowTree** window_tree, 46 WindowTree** window_tree,
45 ServerWindow** server_window); 47 ServerWindow** server_window);
46 48
47 void DispatchInputEventToWindow(ServerWindow* target, 49 void DispatchInputEventToWindow(ServerWindow* target,
48 bool in_nonclient_area, 50 bool in_nonclient_area,
49 const ui::Event& event, 51 const ui::Event& event,
(...skipping 20 matching lines...) Expand all
70 TestDisplayBinding* display_binding_; 72 TestDisplayBinding* display_binding_;
71 // Destroyed in TearDown. 73 // Destroyed in TearDown.
72 WindowTree* tree_; 74 WindowTree* tree_;
73 // Owned by Display. 75 // Owned by Display.
74 WindowTree* original_tree_; 76 WindowTree* original_tree_;
75 // TestWindowTreeClient that is used for the WM connection. Owned by 77 // TestWindowTreeClient that is used for the WM connection. Owned by
76 // |window_server_delegate_| 78 // |window_server_delegate_|
77 TestWindowTreeClient* wm_client_; 79 TestWindowTreeClient* wm_client_;
78 80
79 TestWindowServerDelegate window_server_delegate_; 81 TestWindowServerDelegate window_server_delegate_;
80 scoped_ptr<WindowServer> window_server_; 82 std::unique_ptr<WindowServer> window_server_;
81 // Handles WindowStateManager ack timeouts. 83 // Handles WindowStateManager ack timeouts.
82 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 84 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
83 TestPlatformDisplayFactory platform_display_factory_; 85 TestPlatformDisplayFactory platform_display_factory_;
84 TestWindowManager window_manager_; 86 TestWindowManager window_manager_;
85 ServerWindow* window_; 87 ServerWindow* window_;
86 // Needed to Bind to |wm_client_| 88 // Needed to Bind to |wm_client_|
87 base::MessageLoop message_loop_; 89 base::MessageLoop message_loop_;
88 90
89 DISALLOW_COPY_AND_ASSIGN(WindowManagerStateTest); 91 DISALLOW_COPY_AND_ASSIGN(WindowManagerStateTest);
90 }; 92 };
91 93
92 WindowManagerStateTest::WindowManagerStateTest() 94 WindowManagerStateTest::WindowManagerStateTest()
93 : cursor_id_(0), 95 : cursor_id_(0),
94 task_runner_(new base::TestSimpleTaskRunner), 96 task_runner_(new base::TestSimpleTaskRunner),
95 platform_display_factory_(&cursor_id_) {} 97 platform_display_factory_(&cursor_id_) {}
96 98
97 scoped_ptr<Accelerator> WindowManagerStateTest::CreateAccelerator() { 99 std::unique_ptr<Accelerator> WindowManagerStateTest::CreateAccelerator() {
98 mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher( 100 mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher(
99 mus::mojom::KeyboardCode::W, mus::mojom::kEventFlagControlDown); 101 mus::mojom::KeyboardCode::W, mus::mojom::kEventFlagControlDown);
100 matcher->accelerator_phase = mojom::AcceleratorPhase::POST_TARGET; 102 matcher->accelerator_phase = mojom::AcceleratorPhase::POST_TARGET;
101 uint32_t accelerator_id = 1; 103 uint32_t accelerator_id = 1;
102 scoped_ptr<Accelerator> accelerator( 104 std::unique_ptr<Accelerator> accelerator(
103 new Accelerator(accelerator_id, *matcher)); 105 new Accelerator(accelerator_id, *matcher));
104 return accelerator; 106 return accelerator;
105 } 107 }
106 108
107 void WindowManagerStateTest::CreateSecondaryTree( 109 void WindowManagerStateTest::CreateSecondaryTree(
108 TestWindowTreeClient** test_client, 110 TestWindowTreeClient** test_client,
109 WindowTree** window_tree, 111 WindowTree** window_tree,
110 ServerWindow** server_window) { 112 ServerWindow** server_window) {
111 WindowTree* tree1 = window_server_->GetTreeWithRoot(window_); 113 WindowTree* tree1 = window_server_->GetTreeWithRoot(window_);
112 ASSERT_TRUE(tree1 != nullptr); 114 ASSERT_TRUE(tree1 != nullptr);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void WindowManagerStateTest::SetUp() { 155 void WindowManagerStateTest::SetUp() {
154 message_loop_.SetTaskRunner(task_runner_); 156 message_loop_.SetTaskRunner(task_runner_);
155 157
156 PlatformDisplay::set_factory_for_testing(&platform_display_factory_); 158 PlatformDisplay::set_factory_for_testing(&platform_display_factory_);
157 window_server_.reset(new WindowServer(&window_server_delegate_, 159 window_server_.reset(new WindowServer(&window_server_delegate_,
158 scoped_refptr<SurfacesState>())); 160 scoped_refptr<SurfacesState>()));
159 161
160 PlatformDisplayInitParams display_init_params; 162 PlatformDisplayInitParams display_init_params;
161 display_ = new Display(window_server_.get(), display_init_params); 163 display_ = new Display(window_server_.get(), display_init_params);
162 display_binding_ = new TestDisplayBinding(display_, window_server_.get()); 164 display_binding_ = new TestDisplayBinding(display_, window_server_.get());
163 display_->Init(make_scoped_ptr(display_binding_)); 165 display_->Init(base::WrapUnique(display_binding_));
164 166
165 wm_client_ = window_server_delegate_.last_client(); 167 wm_client_ = window_server_delegate_.last_client();
166 window_manager_state_ = display_->GetActiveWindowManagerState(); 168 window_manager_state_ = display_->GetActiveWindowManagerState();
167 169
168 tree_ = window_server_->GetTreeWithId(1); 170 tree_ = window_server_->GetTreeWithId(1);
169 const ClientWindowId embed_window_id(WindowIdToTransportId(WindowId(1, 1))); 171 const ClientWindowId embed_window_id(WindowIdToTransportId(WindowId(1, 1)));
170 EXPECT_TRUE(tree_->NewWindow(embed_window_id, ServerWindow::Properties())); 172 EXPECT_TRUE(tree_->NewWindow(embed_window_id, ServerWindow::Properties()));
171 ClientWindowId root_id; 173 ClientWindowId root_id;
172 if (tree_->roots().size() == 1u) { 174 if (tree_->roots().size() == 1u) {
173 // If window isn't known we'll return 0, which should then error out. 175 // If window isn't known we'll return 0, which should then error out.
(...skipping 30 matching lines...) Expand all
204 ChangesToDescription1(*tracker->changes())[0]); 206 ChangesToDescription1(*tracker->changes())[0]);
205 207
206 state->OnEventAck(target_tree, mojom::EventResult::UNHANDLED); 208 state->OnEventAck(target_tree, mojom::EventResult::UNHANDLED);
207 EXPECT_FALSE(window_manager()->on_accelerator_called()); 209 EXPECT_FALSE(window_manager()->on_accelerator_called());
208 } 210 }
209 211
210 // Tests that when a post target accelerator is provided on an event, that it is 212 // Tests that when a post target accelerator is provided on an event, that it is
211 // called on ack. 213 // called on ack.
212 TEST_F(WindowManagerStateTest, PostTargetAccelerator) { 214 TEST_F(WindowManagerStateTest, PostTargetAccelerator) {
213 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 215 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
214 scoped_ptr<Accelerator> accelerator = CreateAccelerator(); 216 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
215 217
216 ServerWindow* target = window(); 218 ServerWindow* target = window();
217 DispatchInputEventToWindow(target, true, key, accelerator.get()); 219 DispatchInputEventToWindow(target, true, key, accelerator.get());
218 TestChangeTracker* tracker = wm_client()->tracker(); 220 TestChangeTracker* tracker = wm_client()->tracker();
219 EXPECT_EQ(1u, tracker->changes()->size()); 221 EXPECT_EQ(1u, tracker->changes()->size());
220 EXPECT_EQ("InputEvent window=1,1 event_action=1", 222 EXPECT_EQ("InputEvent window=1,1 event_action=1",
221 ChangesToDescription1(*tracker->changes())[0]); 223 ChangesToDescription1(*tracker->changes())[0]);
222 224
223 window_manager_state()->OnEventAck(tree(), mojom::EventResult::UNHANDLED); 225 window_manager_state()->OnEventAck(tree(), mojom::EventResult::UNHANDLED);
224 EXPECT_TRUE(window_manager()->on_accelerator_called()); 226 EXPECT_TRUE(window_manager()->on_accelerator_called());
225 EXPECT_EQ(accelerator->id(), window_manager()->on_accelerator_id()); 227 EXPECT_EQ(accelerator->id(), window_manager()->on_accelerator_id());
226 } 228 }
227 229
228 // Tests that when a client handles an event that post target accelerators are 230 // Tests that when a client handles an event that post target accelerators are
229 // not called. 231 // not called.
230 TEST_F(WindowManagerStateTest, ClientHandlesEvent) { 232 TEST_F(WindowManagerStateTest, ClientHandlesEvent) {
231 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 233 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
232 scoped_ptr<Accelerator> accelerator = CreateAccelerator(); 234 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
233 235
234 ServerWindow* target = window(); 236 ServerWindow* target = window();
235 DispatchInputEventToWindow(target, true, key, accelerator.get()); 237 DispatchInputEventToWindow(target, true, key, accelerator.get());
236 TestChangeTracker* tracker = wm_client()->tracker(); 238 TestChangeTracker* tracker = wm_client()->tracker();
237 EXPECT_EQ(1u, tracker->changes()->size()); 239 EXPECT_EQ(1u, tracker->changes()->size());
238 EXPECT_EQ("InputEvent window=1,1 event_action=1", 240 EXPECT_EQ("InputEvent window=1,1 event_action=1",
239 ChangesToDescription1(*tracker->changes())[0]); 241 ChangesToDescription1(*tracker->changes())[0]);
240 242
241 window_manager_state()->OnEventAck(tree(), mojom::EventResult::HANDLED); 243 window_manager_state()->OnEventAck(tree(), mojom::EventResult::HANDLED);
242 EXPECT_FALSE(window_manager()->on_accelerator_called()); 244 EXPECT_FALSE(window_manager()->on_accelerator_called());
243 } 245 }
244 246
245 // Tests that when an accelerator is deleted before an ack, that it is not 247 // Tests that when an accelerator is deleted before an ack, that it is not
246 // called. 248 // called.
247 TEST_F(WindowManagerStateTest, AcceleratorDeleted) { 249 TEST_F(WindowManagerStateTest, AcceleratorDeleted) {
248 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 250 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
249 scoped_ptr<Accelerator> accelerator(CreateAccelerator()); 251 std::unique_ptr<Accelerator> accelerator(CreateAccelerator());
250 252
251 ServerWindow* target = window(); 253 ServerWindow* target = window();
252 DispatchInputEventToWindow(target, true, key, accelerator.get()); 254 DispatchInputEventToWindow(target, true, key, accelerator.get());
253 TestChangeTracker* tracker = wm_client()->tracker(); 255 TestChangeTracker* tracker = wm_client()->tracker();
254 EXPECT_EQ(1u, tracker->changes()->size()); 256 EXPECT_EQ(1u, tracker->changes()->size());
255 EXPECT_EQ("InputEvent window=1,1 event_action=1", 257 EXPECT_EQ("InputEvent window=1,1 event_action=1",
256 ChangesToDescription1(*tracker->changes())[0]); 258 ChangesToDescription1(*tracker->changes())[0]);
257 259
258 accelerator.reset(); 260 accelerator.reset();
259 window_manager_state()->OnEventAck(tree(), mojom::EventResult::UNHANDLED); 261 window_manager_state()->OnEventAck(tree(), mojom::EventResult::UNHANDLED);
260 EXPECT_FALSE(window_manager()->on_accelerator_called()); 262 EXPECT_FALSE(window_manager()->on_accelerator_called());
261 } 263 }
262 264
263 // Tests that a events arriving before an ack don't notify the tree until the 265 // Tests that a events arriving before an ack don't notify the tree until the
264 // ack arrives, and that the correct accelerator is called. 266 // ack arrives, and that the correct accelerator is called.
265 TEST_F(WindowManagerStateTest, EnqueuedAccelerators) { 267 TEST_F(WindowManagerStateTest, EnqueuedAccelerators) {
266 WindowManagerState* state = window_manager_state(); 268 WindowManagerState* state = window_manager_state();
267 269
268 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 270 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
269 scoped_ptr<Accelerator> accelerator(CreateAccelerator()); 271 std::unique_ptr<Accelerator> accelerator(CreateAccelerator());
270 272
271 ServerWindow* target = window(); 273 ServerWindow* target = window();
272 DispatchInputEventToWindow(target, true, key, accelerator.get()); 274 DispatchInputEventToWindow(target, true, key, accelerator.get());
273 TestChangeTracker* tracker = wm_client()->tracker(); 275 TestChangeTracker* tracker = wm_client()->tracker();
274 EXPECT_EQ(1u, tracker->changes()->size()); 276 EXPECT_EQ(1u, tracker->changes()->size());
275 EXPECT_EQ("InputEvent window=1,1 event_action=1", 277 EXPECT_EQ("InputEvent window=1,1 event_action=1",
276 ChangesToDescription1(*tracker->changes())[0]); 278 ChangesToDescription1(*tracker->changes())[0]);
277 279
278 tracker->changes()->clear(); 280 tracker->changes()->clear();
279 ui::KeyEvent key2(ui::ET_KEY_PRESSED, ui::VKEY_Y, ui::EF_CONTROL_DOWN); 281 ui::KeyEvent key2(ui::ET_KEY_PRESSED, ui::VKEY_Y, ui::EF_CONTROL_DOWN);
280 mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher( 282 mojom::EventMatcherPtr matcher = mus::CreateKeyMatcher(
281 mus::mojom::KeyboardCode::Y, mus::mojom::kEventFlagControlDown); 283 mus::mojom::KeyboardCode::Y, mus::mojom::kEventFlagControlDown);
282 matcher->accelerator_phase = mojom::AcceleratorPhase::POST_TARGET; 284 matcher->accelerator_phase = mojom::AcceleratorPhase::POST_TARGET;
283 uint32_t accelerator_id = 2; 285 uint32_t accelerator_id = 2;
284 scoped_ptr<Accelerator> accelerator2( 286 std::unique_ptr<Accelerator> accelerator2(
285 new Accelerator(accelerator_id, *matcher)); 287 new Accelerator(accelerator_id, *matcher));
286 DispatchInputEventToWindow(target, true, key2, accelerator2.get()); 288 DispatchInputEventToWindow(target, true, key2, accelerator2.get());
287 EXPECT_TRUE(tracker->changes()->empty()); 289 EXPECT_TRUE(tracker->changes()->empty());
288 290
289 WindowTree* target_tree = tree(); 291 WindowTree* target_tree = tree();
290 WindowTreeTestApi(target_tree).ClearAck(); 292 WindowTreeTestApi(target_tree).ClearAck();
291 state->OnEventAck(target_tree, mojom::EventResult::UNHANDLED); 293 state->OnEventAck(target_tree, mojom::EventResult::UNHANDLED);
292 EXPECT_EQ(1u, tracker->changes()->size()); 294 EXPECT_EQ(1u, tracker->changes()->size());
293 EXPECT_EQ("InputEvent window=1,1 event_action=1", 295 EXPECT_EQ("InputEvent window=1,1 event_action=1",
294 ChangesToDescription1(*tracker->changes())[0]); 296 ChangesToDescription1(*tracker->changes())[0]);
295 EXPECT_TRUE(window_manager()->on_accelerator_called()); 297 EXPECT_TRUE(window_manager()->on_accelerator_called());
296 EXPECT_EQ(accelerator->id(), window_manager()->on_accelerator_id()); 298 EXPECT_EQ(accelerator->id(), window_manager()->on_accelerator_id());
297 } 299 }
298 300
299 // Tests that the accelerator is not sent when the tree is dying. 301 // Tests that the accelerator is not sent when the tree is dying.
300 TEST_F(WindowManagerStateTest, DeleteTree) { 302 TEST_F(WindowManagerStateTest, DeleteTree) {
301 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 303 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
302 scoped_ptr<Accelerator> accelerator = CreateAccelerator(); 304 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
303 305
304 ServerWindow* target = window(); 306 ServerWindow* target = window();
305 DispatchInputEventToWindow(target, true, key, accelerator.get()); 307 DispatchInputEventToWindow(target, true, key, accelerator.get());
306 TestChangeTracker* tracker = wm_client()->tracker(); 308 TestChangeTracker* tracker = wm_client()->tracker();
307 EXPECT_EQ(1u, tracker->changes()->size()); 309 EXPECT_EQ(1u, tracker->changes()->size());
308 EXPECT_EQ("InputEvent window=1,1 event_action=1", 310 EXPECT_EQ("InputEvent window=1,1 event_action=1",
309 ChangesToDescription1(*tracker->changes())[0]); 311 ChangesToDescription1(*tracker->changes())[0]);
310 312
311 window_manager_state()->OnWillDestroyTree(tree()); 313 window_manager_state()->OnWillDestroyTree(tree());
312 EXPECT_FALSE(window_manager()->on_accelerator_called()); 314 EXPECT_FALSE(window_manager()->on_accelerator_called());
313 } 315 }
314 316
315 // Tests that if a tree is destroyed before acking, that the accelerator is 317 // Tests that if a tree is destroyed before acking, that the accelerator is
316 // still sent if it is not the root tree. 318 // still sent if it is not the root tree.
317 TEST_F(WindowManagerStateTest, DeleteNonRootTree) { 319 TEST_F(WindowManagerStateTest, DeleteNonRootTree) {
318 TestWindowTreeClient* embed_connection = nullptr; 320 TestWindowTreeClient* embed_connection = nullptr;
319 WindowTree* target_tree = nullptr; 321 WindowTree* target_tree = nullptr;
320 ServerWindow* target = nullptr; 322 ServerWindow* target = nullptr;
321 CreateSecondaryTree(&embed_connection, &target_tree, &target); 323 CreateSecondaryTree(&embed_connection, &target_tree, &target);
322 TestWindowManager target_window_manager; 324 TestWindowManager target_window_manager;
323 WindowTreeTestApi(target_tree) 325 WindowTreeTestApi(target_tree)
324 .set_window_manager_internal(&target_window_manager); 326 .set_window_manager_internal(&target_window_manager);
325 327
326 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 328 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
327 scoped_ptr<Accelerator> accelerator = CreateAccelerator(); 329 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
328 DispatchInputEventToWindow(target, true, key, accelerator.get()); 330 DispatchInputEventToWindow(target, true, key, accelerator.get());
329 TestChangeTracker* tracker = embed_connection->tracker(); 331 TestChangeTracker* tracker = embed_connection->tracker();
330 EXPECT_EQ(1u, tracker->changes()->size()); 332 EXPECT_EQ(1u, tracker->changes()->size());
331 EXPECT_EQ("InputEvent window=2,1 event_action=1", 333 EXPECT_EQ("InputEvent window=2,1 event_action=1",
332 ChangesToDescription1(*tracker->changes())[0]); 334 ChangesToDescription1(*tracker->changes())[0]);
333 EXPECT_TRUE(wm_client()->tracker()->changes()->empty()); 335 EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
334 336
335 window_manager_state()->OnWillDestroyTree(target_tree); 337 window_manager_state()->OnWillDestroyTree(target_tree);
336 EXPECT_FALSE(target_window_manager.on_accelerator_called()); 338 EXPECT_FALSE(target_window_manager.on_accelerator_called());
337 EXPECT_TRUE(window_manager()->on_accelerator_called()); 339 EXPECT_TRUE(window_manager()->on_accelerator_called());
338 } 340 }
339 341
340 // Tests that when an ack times out that the accelerator is notified. 342 // Tests that when an ack times out that the accelerator is notified.
341 TEST_F(WindowManagerStateTest, AckTimeout) { 343 TEST_F(WindowManagerStateTest, AckTimeout) {
342 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 344 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
343 scoped_ptr<Accelerator> accelerator = CreateAccelerator(); 345 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
344 DispatchInputEventToWindow(window(), true, key, accelerator.get()); 346 DispatchInputEventToWindow(window(), true, key, accelerator.get());
345 TestChangeTracker* tracker = wm_client()->tracker(); 347 TestChangeTracker* tracker = wm_client()->tracker();
346 EXPECT_EQ(1u, tracker->changes()->size()); 348 EXPECT_EQ(1u, tracker->changes()->size());
347 EXPECT_EQ("InputEvent window=1,1 event_action=1", 349 EXPECT_EQ("InputEvent window=1,1 event_action=1",
348 ChangesToDescription1(*tracker->changes())[0]); 350 ChangesToDescription1(*tracker->changes())[0]);
349 351
350 OnEventAckTimeout(); 352 OnEventAckTimeout();
351 EXPECT_TRUE(window_manager()->on_accelerator_called()); 353 EXPECT_TRUE(window_manager()->on_accelerator_called());
352 EXPECT_EQ(accelerator->id(), window_manager()->on_accelerator_id()); 354 EXPECT_EQ(accelerator->id(), window_manager()->on_accelerator_id());
353 } 355 }
354 356
355 } // namespace test 357 } // namespace test
356 } // namespace ws 358 } // namespace ws
357 } // namespace mus 359 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_manager_state.cc ('k') | components/mus/ws/window_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698