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

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

Issue 2184613005: Fixes bug in accelerator handling in mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak Created 4 years, 4 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') | no next file » | 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 ASSERT_EQ(0u, embed_client_proxy->tracker()->changes()->size()); 474 ASSERT_EQ(0u, embed_client_proxy->tracker()->changes()->size());
475 475
476 ASSERT_EQ(1u, embedder_client->tracker()->changes()->size()); 476 ASSERT_EQ(1u, embedder_client->tracker()->changes()->size());
477 EXPECT_EQ(CHANGE_TYPE_INPUT_EVENT, 477 EXPECT_EQ(CHANGE_TYPE_INPUT_EVENT,
478 (*embedder_client->tracker()->changes())[0].type); 478 (*embedder_client->tracker()->changes())[0].type);
479 WindowTreeTestApi(embedder_tree) 479 WindowTreeTestApi(embedder_tree)
480 .AckLastEvent(mojom::EventResult::UNHANDLED); 480 .AckLastEvent(mojom::EventResult::UNHANDLED);
481 } 481 }
482 } 482 }
483 483
484 // Ensures accelerators are forgotten between events.
485 TEST_F(WindowManagerStateTest, PostAcceleratorForgotten) {
486 // Send an event that matches the accelerator and have the target respond
487 // that it handled the event so that the accelerator isn't called.
488 ui::KeyEvent accelerator_key(ui::ET_KEY_PRESSED, ui::VKEY_W,
489 ui::EF_CONTROL_DOWN);
490 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
491 ServerWindow* target = window();
492 DispatchInputEventToWindow(target, accelerator_key, accelerator.get());
493 TestChangeTracker* tracker = window_tree_client()->tracker();
494 ASSERT_EQ(1u, tracker->changes()->size());
495 EXPECT_EQ("InputEvent window=1,1 event_action=7",
496 ChangesToDescription1(*tracker->changes())[0]);
497 tracker->changes()->clear();
498 WindowTreeTestApi(window_tree()).AckLastEvent(mojom::EventResult::HANDLED);
499 EXPECT_FALSE(window_manager()->on_accelerator_called());
500
501 // Send another event that doesn't match the accelerator, the accelerator
502 // shouldn't be called.
503 ui::KeyEvent non_accelerator_key(ui::ET_KEY_PRESSED, ui::VKEY_T,
504 ui::EF_CONTROL_DOWN);
505 DispatchInputEventToWindow(target, non_accelerator_key, nullptr);
506 ASSERT_EQ(1u, tracker->changes()->size());
507 EXPECT_EQ("InputEvent window=1,1 event_action=7",
508 ChangesToDescription1(*tracker->changes())[0]);
509 WindowTreeTestApi(window_tree()).AckLastEvent(mojom::EventResult::UNHANDLED);
510 EXPECT_FALSE(window_manager()->on_accelerator_called());
511 }
512
484 } // namespace test 513 } // namespace test
485 } // namespace ws 514 } // namespace ws
486 } // namespace ui 515 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/window_manager_state.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698