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

Side by Side Diff: components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc

Issue 1806703002: Use ui::Event instead of mojom::EventPtr in mus::InputEventHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed feedback. Created 4 years, 9 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/public/cpp/lib/window_tree_client_impl.cc ('k') | content/renderer/mus/BUILD.gn » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/public/cpp/lib/window_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void Reset() { 133 void Reset() {
134 received_event_ = false; 134 received_event_ = false;
135 ack_callback_ = base::Bind(&::DoNothingBool); 135 ack_callback_ = base::Bind(&::DoNothingBool);
136 } 136 }
137 bool received_event() const { return received_event_; } 137 bool received_event() const { return received_event_; }
138 138
139 private: 139 private:
140 // InputEventHandler: 140 // InputEventHandler:
141 void OnWindowInputEvent( 141 void OnWindowInputEvent(
142 Window* target, 142 Window* target,
143 mojom::EventPtr event, 143 const ui::Event& event,
144 scoped_ptr<base::Callback<void(bool)>>* ack_callback) override { 144 scoped_ptr<base::Callback<void(bool)>>* ack_callback) override {
145 EXPECT_FALSE(received_event_) 145 EXPECT_FALSE(received_event_)
146 << "Observer was not reset after receiving event."; 146 << "Observer was not reset after receiving event.";
147 received_event_ = true; 147 received_event_ = true;
148 if (should_manually_ack_) { 148 if (should_manually_ack_) {
149 ack_callback_ = *ack_callback->get(); 149 ack_callback_ = *ack_callback->get();
150 ack_callback->reset(); 150 ack_callback->reset();
151 } 151 }
152 } 152 }
153 153
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 WindowTreeSetup setup; 342 WindowTreeSetup setup;
343 Window* root = setup.GetFirstRoot(); 343 Window* root = setup.GetFirstRoot();
344 ASSERT_TRUE(root); 344 ASSERT_TRUE(root);
345 345
346 TestInputEventHandler event_handler; 346 TestInputEventHandler event_handler;
347 root->set_input_event_handler(&event_handler); 347 root->set_input_event_handler(&event_handler);
348 348
349 scoped_ptr<ui::Event> ui_event( 349 scoped_ptr<ui::Event> ui_event(
350 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(), 350 new ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
351 ui::EventTimeForNow(), ui::EF_NONE, 0)); 351 ui::EventTimeForNow(), ui::EF_NONE, 0));
352 mojom::EventPtr mus_event = mojom::Event::From(*ui_event); 352 setup.window_tree_client()->OnWindowInputEvent(
353 setup.window_tree_client()->OnWindowInputEvent(1, root->id(), 353 1, root->id(), mojom::Event::From(*ui_event.get()));
354 std::move(mus_event));
355 EXPECT_TRUE(event_handler.received_event()); 354 EXPECT_TRUE(event_handler.received_event());
356 EXPECT_TRUE(setup.window_tree()->WasEventAcked(1)); 355 EXPECT_TRUE(setup.window_tree()->WasEventAcked(1));
357 event_handler.Reset(); 356 event_handler.Reset();
358 357
359 event_handler.set_should_manually_ack(); 358 event_handler.set_should_manually_ack();
360 mus_event = mojom::Event::From(*ui_event); 359 setup.window_tree_client()->OnWindowInputEvent(
361 setup.window_tree_client()->OnWindowInputEvent(33, root->id(), 360 33, root->id(), mojom::Event::From(*ui_event.get()));
362 std::move(mus_event));
363 EXPECT_TRUE(event_handler.received_event()); 361 EXPECT_TRUE(event_handler.received_event());
364 EXPECT_FALSE(setup.window_tree()->WasEventAcked(33)); 362 EXPECT_FALSE(setup.window_tree()->WasEventAcked(33));
365 363
366 event_handler.AckEvent(); 364 event_handler.AckEvent();
367 EXPECT_TRUE(setup.window_tree()->WasEventAcked(33)); 365 EXPECT_TRUE(setup.window_tree()->WasEventAcked(33));
368 } 366 }
369 367
370 // Verifies focus is reverted if the server replied that the change failed. 368 // Verifies focus is reverted if the server replied that the change failed.
371 TEST_F(WindowTreeClientImplTest, SetFocusFailed) { 369 TEST_F(WindowTreeClientImplTest, SetFocusFailed) {
372 WindowTreeSetup setup; 370 WindowTreeSetup setup;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 802
805 setup.window_tree_client()->OnChangeCompleted(change_id2, false); 803 setup.window_tree_client()->OnChangeCompleted(change_id2, false);
806 EXPECT_FALSE(child->HasCapture()); 804 EXPECT_FALSE(child->HasCapture());
807 EXPECT_TRUE(root->HasCapture()); 805 EXPECT_TRUE(root->HasCapture());
808 806
809 setup.window_tree_client()->OnLostCapture(root->id()); 807 setup.window_tree_client()->OnLostCapture(root->id());
810 EXPECT_FALSE(root->HasCapture()); 808 EXPECT_FALSE(root->HasCapture());
811 } 809 }
812 810
813 } // namespace mus 811 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/window_tree_client_impl.cc ('k') | content/renderer/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698