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

Side by Side Diff: services/ui/ws/window_manager_state_unittest.cc

Issue 2685883003: chromeos: converts observed pointer events to DIPs (Closed)
Patch Set: merge Created 3 years, 10 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 | « services/ui/ws/window_manager_state.cc ('k') | services/ui/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 "services/ui/ws/window_manager_state.h" 5 #include "services/ui/ws/window_manager_state.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 ASSERT_TRUE(window_manager_state()->event_dispatcher()->AddAccelerator( 232 ASSERT_TRUE(window_manager_state()->event_dispatcher()->AddAccelerator(
233 accelerator_id, std::move(matcher))); 233 accelerator_id, std::move(matcher)));
234 } 234 }
235 TestChangeTracker* tracker = wm_client()->tracker(); 235 TestChangeTracker* tracker = wm_client()->tracker();
236 tracker->changes()->clear(); 236 tracker->changes()->clear();
237 TestChangeTracker* tracker2 = window_tree_client()->tracker(); 237 TestChangeTracker* tracker2 = window_tree_client()->tracker();
238 tracker2->changes()->clear(); 238 tracker2->changes()->clear();
239 239
240 // Send an ensure only the pre accelerator is called. 240 // Send an ensure only the pre accelerator is called.
241 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 241 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
242 window_manager_state()->ProcessEvent(key); 242 window_manager_state()->ProcessEvent(key, 0);
243 EXPECT_TRUE(window_manager()->on_accelerator_called()); 243 EXPECT_TRUE(window_manager()->on_accelerator_called());
244 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id()); 244 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id());
245 EXPECT_TRUE(tracker->changes()->empty()); 245 EXPECT_TRUE(tracker->changes()->empty());
246 EXPECT_TRUE(tracker2->changes()->empty()); 246 EXPECT_TRUE(tracker2->changes()->empty());
247 247
248 // Ack the accelerator, saying we consumed it. 248 // Ack the accelerator, saying we consumed it.
249 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::HANDLED); 249 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::HANDLED);
250 // Nothing should change. 250 // Nothing should change.
251 EXPECT_TRUE(tracker->changes()->empty()); 251 EXPECT_TRUE(tracker->changes()->empty());
252 EXPECT_TRUE(tracker2->changes()->empty()); 252 EXPECT_TRUE(tracker2->changes()->empty());
253 253
254 window_manager()->ClearAcceleratorCalled(); 254 window_manager()->ClearAcceleratorCalled();
255 255
256 // Repeat, but respond with UNHANDLED. 256 // Repeat, but respond with UNHANDLED.
257 window_manager_state()->ProcessEvent(key); 257 window_manager_state()->ProcessEvent(key, 0);
258 EXPECT_TRUE(window_manager()->on_accelerator_called()); 258 EXPECT_TRUE(window_manager()->on_accelerator_called());
259 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id()); 259 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id());
260 EXPECT_TRUE(tracker->changes()->empty()); 260 EXPECT_TRUE(tracker->changes()->empty());
261 EXPECT_TRUE(tracker2->changes()->empty()); 261 EXPECT_TRUE(tracker2->changes()->empty());
262 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::UNHANDLED); 262 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::UNHANDLED);
263 263
264 EXPECT_TRUE(tracker->changes()->empty()); 264 EXPECT_TRUE(tracker->changes()->empty());
265 // The focused window should get the event. 265 // The focused window should get the event.
266 EXPECT_EQ("InputEvent window=0,11 event_action=7", 266 EXPECT_EQ("InputEvent window=0,11 event_action=7",
267 SingleChangeToDescription(*tracker2->changes())); 267 SingleChangeToDescription(*tracker2->changes()));
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 child_window->SetVisible(true); 576 child_window->SetVisible(true);
577 child_window->SetBounds(gfx::Rect(0, 0, 20, 20)); 577 child_window->SetBounds(gfx::Rect(0, 0, 20, 20));
578 child_window->parent()->SetPredefinedCursor(ui::mojom::Cursor::COPY); 578 child_window->parent()->SetPredefinedCursor(ui::mojom::Cursor::COPY);
579 EXPECT_EQ(ui::mojom::Cursor::COPY, display_test_api.last_cursor()); 579 EXPECT_EQ(ui::mojom::Cursor::COPY, display_test_api.last_cursor());
580 // Move the mouse outside the bounds of the child, so that the mouse is not 580 // Move the mouse outside the bounds of the child, so that the mouse is not
581 // over any valid windows. Cursor should change to POINTER. 581 // over any valid windows. Cursor should change to POINTER.
582 ui::PointerEvent move( 582 ui::PointerEvent move(
583 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, 0, 583 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, 0,
584 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), 584 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE),
585 base::TimeTicks()); 585 base::TimeTicks());
586 window_manager_state()->ProcessEvent(move); 586 window_manager_state()->ProcessEvent(move, 0);
587 // The event isn't over a valid target, which should trigger resetting the 587 // The event isn't over a valid target, which should trigger resetting the
588 // cursor to POINTER. 588 // cursor to POINTER.
589 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); 589 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor());
590 } 590 }
591 591
592 } // namespace test 592 } // namespace test
593 } // namespace ws 593 } // namespace ws
594 } // namespace ui 594 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_state.cc ('k') | services/ui/ws/window_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698