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

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

Issue 1677513002: mus Window Server: implement event capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « components/mus/ws/window_tree_impl.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 mus::mojom::WindowTreePtr tree, 126 mus::mojom::WindowTreePtr tree,
127 Id focused_window_id, 127 Id focused_window_id,
128 uint32_t access_policy) override { 128 uint32_t access_policy) override {
129 // TODO(sky): add test coverage of |focused_window_id|. 129 // TODO(sky): add test coverage of |focused_window_id|.
130 tracker_.OnEmbed(connection_id, std::move(root)); 130 tracker_.OnEmbed(connection_id, std::move(root));
131 } 131 }
132 void OnEmbeddedAppDisconnected(uint32_t window) override { 132 void OnEmbeddedAppDisconnected(uint32_t window) override {
133 tracker_.OnEmbeddedAppDisconnected(window); 133 tracker_.OnEmbeddedAppDisconnected(window);
134 } 134 }
135 void OnUnembed(Id window_id) override { tracker_.OnUnembed(window_id); } 135 void OnUnembed(Id window_id) override { tracker_.OnUnembed(window_id); }
136 void OnLostCapture(Id window_id) override {}
136 void OnTopLevelCreated(uint32_t change_id, 137 void OnTopLevelCreated(uint32_t change_id,
137 mojom::WindowDataPtr data) override { 138 mojom::WindowDataPtr data) override {
138 tracker_.OnTopLevelCreated(change_id, std::move(data)); 139 tracker_.OnTopLevelCreated(change_id, std::move(data));
139 } 140 }
140 void OnWindowBoundsChanged(uint32_t window, 141 void OnWindowBoundsChanged(uint32_t window,
141 mojo::RectPtr old_bounds, 142 mojo::RectPtr old_bounds,
142 mojo::RectPtr new_bounds) override { 143 mojo::RectPtr new_bounds) override {
143 tracker_.OnWindowBoundsChanged(window, std::move(old_bounds), 144 tracker_.OnWindowBoundsChanged(window, std::move(old_bounds),
144 std::move(new_bounds)); 145 std::move(new_bounds));
145 } 146 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // root-window is created). 317 // root-window is created).
317 mojom::ViewportMetrics metrics; 318 mojom::ViewportMetrics metrics;
318 metrics.size_in_pixels = mojo::Size::From(gfx::Size(400, 300)); 319 metrics.size_in_pixels = mojo::Size::From(gfx::Size(400, 300));
319 metrics.device_pixel_ratio = 1.f; 320 metrics.device_pixel_ratio = 1.f;
320 delegate->OnViewportMetricsChanged(mojom::ViewportMetrics(), metrics); 321 delegate->OnViewportMetricsChanged(mojom::ViewportMetrics(), metrics);
321 } 322 }
322 void SchedulePaint(const ServerWindow* window, 323 void SchedulePaint(const ServerWindow* window,
323 const gfx::Rect& bounds) override {} 324 const gfx::Rect& bounds) override {}
324 void SetViewportSize(const gfx::Size& size) override {} 325 void SetViewportSize(const gfx::Size& size) override {}
325 void SetTitle(const base::string16& title) override {} 326 void SetTitle(const base::string16& title) override {}
327 void SetCapture() override {}
328 void ReleaseCapture() override {}
326 void SetCursorById(int32_t cursor) override { *cursor_id_storage_ = cursor; } 329 void SetCursorById(int32_t cursor) override { *cursor_id_storage_ = cursor; }
327 mojom::Rotation GetRotation() override { return mojom::Rotation::VALUE_0; } 330 mojom::Rotation GetRotation() override { return mojom::Rotation::VALUE_0; }
328 const mojom::ViewportMetrics& GetViewportMetrics() override { 331 const mojom::ViewportMetrics& GetViewportMetrics() override {
329 return display_metrices_; 332 return display_metrices_;
330 } 333 }
331 void UpdateTextInputState(const ui::TextInputState& state) override {} 334 void UpdateTextInputState(const ui::TextInputState& state) override {}
332 void SetImeVisibility(bool visible) override {} 335 void SetImeVisibility(bool visible) override {}
333 bool IsFramePending() const override { return false; } 336 bool IsFramePending() const override { return false; }
334 void RequestCopyOfOutput( 337 void RequestCopyOfOutput(
335 scoped_ptr<cc::CopyOutputRequest> output_request) override {} 338 scoped_ptr<cc::CopyOutputRequest> output_request) override {}
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 WindowIdFromTransportId(embed_window_id2_in_child.id)) + 894 WindowIdFromTransportId(embed_window_id2_in_child.id)) +
892 " visible=true", 895 " visible=true",
893 SingleChangeToDescription(*embed_connection->tracker()->changes())); 896 SingleChangeToDescription(*embed_connection->tracker()->changes()));
894 897
895 // Set the visibility from the child using the client assigned id. 898 // Set the visibility from the child using the client assigned id.
896 ASSERT_TRUE(window_tree_connection->SetWindowVisibility( 899 ASSERT_TRUE(window_tree_connection->SetWindowVisibility(
897 embed_window_id2_in_child, false)); 900 embed_window_id2_in_child, false));
898 EXPECT_FALSE(embed_window->visible()); 901 EXPECT_FALSE(embed_window->visible());
899 } 902 }
900 903
904 // Tests that setting capture only works while an input event is being
905 // processed, and the only the capture window can release capture.
906 TEST_F(WindowTreeTest, ExplicitSetCapture) {
907 TestWindowTreeClient* embed_connection = nullptr;
908 WindowTreeImpl* window_tree_connection = nullptr;
909 ServerWindow* window = nullptr;
910 EXPECT_NO_FATAL_FAILURE(
911 SetupEventTargeting(&embed_connection, &window_tree_connection, &window));
912 const ServerWindow* root_window = *window_tree_connection->roots().begin();
913 window_tree_connection->AddWindow(
914 FirstRootId(window_tree_connection),
915 ClientWindowIdForWindow(window_tree_connection, window));
916 window->SetBounds(gfx::Rect(0, 0, 100, 100));
917 ASSERT_TRUE(window_tree_connection->GetHost(window));
918
919 // Setting capture should fail when there are no active events
920 mojom::WindowTree* mojom_window_tree =
921 static_cast<mojom::WindowTree*>(window_tree_connection);
922 uint32_t change_id = 42;
923 mojom_window_tree->SetCapture(change_id, WindowIdToTransportId(window->id()));
924 WindowTreeHostImpl* host = window_tree_connection->GetHost(window);
925 EXPECT_NE(window, host->GetCaptureWindow());
926
927 // Setting capture after the event is acknowledged should fail
928 DispatchEventAndAckImmediately(CreatePointerDownEvent(10, 10));
929 mojom_window_tree->SetCapture(++change_id,
930 WindowIdToTransportId(window->id()));
931 EXPECT_NE(window, host->GetCaptureWindow());
932
933 // Settings while the event is being process should pass
934 DispatchEventWithoutAck(CreatePointerDownEvent(10, 10));
935 mojom_window_tree->SetCapture(++change_id,
936 WindowIdToTransportId(window->id()));
937 EXPECT_EQ(window, host->GetCaptureWindow());
938 AckPreviousEvent();
939
940 // Only the capture window should be able to release capture
941 mojom_window_tree->ReleaseCapture(++change_id,
942 WindowIdToTransportId(root_window->id()));
943 EXPECT_EQ(window, host->GetCaptureWindow());
944 mojom_window_tree->ReleaseCapture(++change_id,
945 WindowIdToTransportId(window->id()));
946 EXPECT_EQ(nullptr, host->GetCaptureWindow());
947 }
948
901 } // namespace ws 949 } // namespace ws
902 } // namespace mus 950 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_tree_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698