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

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

Issue 2520093003: WindowManagerClient::AddAccelerator() should take an array (Closed)
Patch Set: Modify helper to return vector and leverage helper in other files.Rename/format code. Created 4 years 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
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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/test/test_simple_task_runner.h" 12 #include "base/test/test_simple_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "services/service_manager/public/interfaces/connector.mojom.h" 14 #include "services/service_manager/public/interfaces/connector.mojom.h"
15 #include "services/ui/common/accelerator_transport_util.h"
15 #include "services/ui/common/event_matcher_util.h" 16 #include "services/ui/common/event_matcher_util.h"
16 #include "services/ui/ws/accelerator.h" 17 #include "services/ui/ws/accelerator.h"
17 #include "services/ui/ws/display.h" 18 #include "services/ui/ws/display.h"
18 #include "services/ui/ws/display_manager.h" 19 #include "services/ui/ws/display_manager.h"
19 #include "services/ui/ws/platform_display.h" 20 #include "services/ui/ws/platform_display.h"
20 #include "services/ui/ws/platform_display_init_params.h" 21 #include "services/ui/ws/platform_display_init_params.h"
21 #include "services/ui/ws/server_window_compositor_frame_sink_manager_test_api.h" 22 #include "services/ui/ws/server_window_compositor_frame_sink_manager_test_api.h"
22 #include "services/ui/ws/test_change_tracker.h" 23 #include "services/ui/ws/test_change_tracker.h"
23 #include "services/ui/ws/test_server_window_delegate.h" 24 #include "services/ui/ws/test_server_window_delegate.h"
24 #include "services/ui/ws/test_utils.h" 25 #include "services/ui/ws/test_utils.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 child_window->SetVisible(true); 225 child_window->SetVisible(true);
225 SetCanFocusUp(child_window); 226 SetCanFocusUp(child_window);
226 tree()->GetDisplay(child_window)->AddActivationParent(child_window->parent()); 227 tree()->GetDisplay(child_window)->AddActivationParent(child_window->parent());
227 ASSERT_TRUE(window_tree()->SetFocus(child_window_id)); 228 ASSERT_TRUE(window_tree()->SetFocus(child_window_id));
228 229
229 // Register a pre-accelerator. 230 // Register a pre-accelerator.
230 uint32_t accelerator_id = 11; 231 uint32_t accelerator_id = 11;
231 { 232 {
232 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher( 233 mojom::EventMatcherPtr matcher = ui::CreateKeyMatcher(
233 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown); 234 ui::mojom::KeyboardCode::W, ui::mojom::kEventFlagControlDown);
234 ASSERT_TRUE(window_manager_state()->event_dispatcher()->AddAccelerator( 235
235 accelerator_id, std::move(matcher))); 236 std::vector<ui::mojom::AcceleratorTransportPtr> accelerators;
237 accelerators = ash::mus::AddAcceleratorHelper(
238 std::move(accelerators), accelerator_id, std::move(matcher));
239
240 ASSERT_TRUE(window_manager_state()->event_dispatcher()->AddAccelerators(
241 std::move(accelerators)));
236 } 242 }
237 TestChangeTracker* tracker = wm_client()->tracker(); 243 TestChangeTracker* tracker = wm_client()->tracker();
238 tracker->changes()->clear(); 244 tracker->changes()->clear();
239 TestChangeTracker* tracker2 = window_tree_client()->tracker(); 245 TestChangeTracker* tracker2 = window_tree_client()->tracker();
240 tracker2->changes()->clear(); 246 tracker2->changes()->clear();
241 247
242 // Send an ensure only the pre accelerator is called. 248 // Send an ensure only the pre accelerator is called.
243 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); 249 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN);
244 window_manager_state()->ProcessEvent(key); 250 window_manager_state()->ProcessEvent(key);
245 EXPECT_TRUE(window_manager()->on_accelerator_called()); 251 EXPECT_TRUE(window_manager()->on_accelerator_called());
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 ASSERT_EQ(1u, tree->roots().size()); 568 ASSERT_EQ(1u, tree->roots().size());
563 ClientWindowId root_client_id; 569 ClientWindowId root_client_id;
564 ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id)); 570 ASSERT_TRUE(tree->IsWindowKnown(*(tree->roots().begin()), &root_client_id));
565 EXPECT_TRUE(tree->DeleteWindow(root_client_id)); 571 EXPECT_TRUE(tree->DeleteWindow(root_client_id));
566 window_server->DestroyTree(tree); 572 window_server->DestroyTree(tree);
567 } 573 }
568 574
569 } // namespace test 575 } // namespace test
570 } // namespace ws 576 } // namespace ws
571 } // namespace ui 577 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698