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

Side by Side Diff: components/mus/ws/window_tree_apptest.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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 tree_ = std::move(tree); 284 tree_ = std::move(tree);
285 connection_id_ = connection_id; 285 connection_id_ = connection_id;
286 tracker()->OnEmbed(connection_id, std::move(root)); 286 tracker()->OnEmbed(connection_id, std::move(root));
287 if (embed_run_loop_) 287 if (embed_run_loop_)
288 embed_run_loop_->Quit(); 288 embed_run_loop_->Quit();
289 } 289 }
290 void OnEmbeddedAppDisconnected(Id window_id) override { 290 void OnEmbeddedAppDisconnected(Id window_id) override {
291 tracker()->OnEmbeddedAppDisconnected(window_id); 291 tracker()->OnEmbeddedAppDisconnected(window_id);
292 } 292 }
293 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); } 293 void OnUnembed(Id window_id) override { tracker()->OnUnembed(window_id); }
294 void OnLostCapture(Id window_id) override {
295 tracker()->OnLostCapture(window_id);
296 }
294 void OnTopLevelCreated(uint32_t change_id, 297 void OnTopLevelCreated(uint32_t change_id,
295 mojom::WindowDataPtr data) override { 298 mojom::WindowDataPtr data) override {
296 tracker()->OnTopLevelCreated(change_id, std::move(data)); 299 tracker()->OnTopLevelCreated(change_id, std::move(data));
297 } 300 }
298 void OnWindowBoundsChanged(Id window_id, 301 void OnWindowBoundsChanged(Id window_id,
299 RectPtr old_bounds, 302 RectPtr old_bounds,
300 RectPtr new_bounds) override { 303 RectPtr new_bounds) override {
301 // The bounds of the root may change during startup on Android at random 304 // The bounds of the root may change during startup on Android at random
302 // times. As this doesn't matter, and shouldn't impact test exepctations, 305 // times. As this doesn't matter, and shouldn't impact test exepctations,
303 // it is ignored. 306 // it is ignored.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 344 }
342 void OnWindowVisibilityChanged(uint32_t window, bool visible) override { 345 void OnWindowVisibilityChanged(uint32_t window, bool visible) override {
343 tracker()->OnWindowVisibilityChanged(window, visible); 346 tracker()->OnWindowVisibilityChanged(window, visible);
344 } 347 }
345 void OnWindowDrawnStateChanged(uint32_t window, bool drawn) override { 348 void OnWindowDrawnStateChanged(uint32_t window, bool drawn) override {
346 tracker()->OnWindowDrawnStateChanged(window, drawn); 349 tracker()->OnWindowDrawnStateChanged(window, drawn);
347 } 350 }
348 void OnWindowInputEvent(uint32_t event_id, 351 void OnWindowInputEvent(uint32_t event_id,
349 Id window_id, 352 Id window_id,
350 EventPtr event) override { 353 EventPtr event) override {
354 // Ack input events to clear the state on the server. These can be received
355 // during test startup. X11Window::DispatchEvent sends a synthetic move
356 // event to notify of entry.
357 tree()->OnWindowInputEventAck(event_id);
351 // Don't log input events as none of the tests care about them and they 358 // Don't log input events as none of the tests care about them and they
352 // may come in at random points. 359 // may come in at random points.
353 } 360 }
354 void OnWindowSharedPropertyChanged(uint32_t window, 361 void OnWindowSharedPropertyChanged(uint32_t window,
355 const String& name, 362 const String& name,
356 Array<uint8_t> new_data) override { 363 Array<uint8_t> new_data) override {
357 tracker_.OnWindowSharedPropertyChanged(window, name, std::move(new_data)); 364 tracker_.OnWindowSharedPropertyChanged(window, name, std::move(new_data));
358 } 365 }
359 // TODO(sky): add testing coverage. 366 // TODO(sky): add testing coverage.
360 void OnWindowFocused(uint32_t focused_window_id) override {} 367 void OnWindowFocused(uint32_t focused_window_id) override {}
(...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 // Remove 2_101 from wm, client1 should see the change. 1859 // Remove 2_101 from wm, client1 should see the change.
1853 ws1()->RemoveWindowFromParent(12, window_2_101_in_ws1); 1860 ws1()->RemoveWindowFromParent(12, window_2_101_in_ws1);
1854 ASSERT_TRUE(ws_client1()->WaitForChangeCompleted(12)); 1861 ASSERT_TRUE(ws_client1()->WaitForChangeCompleted(12));
1855 ws_client2()->WaitForChangeCount(1); 1862 ws_client2()->WaitForChangeCount(1);
1856 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101) + 1863 EXPECT_EQ("HierarchyChanged window=" + IdToString(window_2_101) +
1857 " new_parent=null old_parent=" + 1864 " new_parent=null old_parent=" +
1858 IdToString(window_1_100_in_ws2), 1865 IdToString(window_1_100_in_ws2),
1859 SingleChangeToDescription(*changes2())); 1866 SingleChangeToDescription(*changes2()));
1860 } 1867 }
1861 1868
1869 // Tests that setting capture fails when no input event has occurred, and there
1870 // is no notification of lost capture.
1871 TEST_F(WindowTreeAppTest, ExplicitCaptureWithoutInput) {
1872 Id window_1_1 = ws_client1()->NewWindow(1);
1873
1874 // Add the window to the root, so that they have a WindowTreeHostImpl to
1875 // handle input capture.
1876 ASSERT_TRUE(ws_client1()->AddWindow(root_window_id(), window_1_1));
1877 changes1()->clear();
1878
1879 // Since there has been no input, capture should not succeed. No lost capture
1880 // message is expected.
1881 ws1()->SetCapture(1, window_1_1);
1882 ws_client1_->WaitForAllMessages();
1883 EXPECT_TRUE(changes1()->empty());
1884
1885 // Since there is no window with capture, lost capture should not be notified.
1886 ws1()->ReleaseCapture(3, window_1_1);
1887 ws_client1_->WaitForAllMessages();
1888 EXPECT_TRUE(changes1()->empty());
1889 }
1890
1891 // TODO(jonross): Enable this once apptests can send input events to the server.
1892 // Enabling capture requires that the connection be processing events.
1893 TEST_F(WindowTreeAppTest, DISABLED_ExplicitCapturePropagation) {
1894 Id window_1_1 = ws_client1()->NewWindow(1);
1895 Id window_1_2 = ws_client1()->NewWindow(2);
1896
1897 // Add the windows to the root, so that they have a WindowTreeHostImpl to
1898 // handle input capture.
1899 ASSERT_TRUE(ws_client1()->AddWindow(root_window_id(), window_1_1));
1900 ASSERT_TRUE(ws_client1()->AddWindow(root_window_id(), window_1_2));
1901
1902 changes1()->clear();
1903 // Window 1 takes capture then Window 2 takes capture.
1904 // Verify that window 1 has lost capture.
1905 ws1()->SetCapture(1, window_1_1);
1906 ws1()->SetCapture(2, window_1_2);
1907 ws_client1_->WaitForChangeCount(1);
1908
1909 EXPECT_EQ("OnLostCapture window=" + IdToString(window_1_1),
1910 SingleChangeToDescription(*changes1()));
1911
1912 changes1()->clear();
1913 // Explicitly releasing capture should not notify of lost capture.
1914 ws1()->ReleaseCapture(3, window_1_2);
1915 ws_client1_->WaitForAllMessages();
1916
1917 EXPECT_TRUE(changes1()->empty());
1918 }
1919
1862 // TODO(sky): need to better track changes to initial connection. For example, 1920 // TODO(sky): need to better track changes to initial connection. For example,
1863 // that SetBounsdWindows/AddWindow and the like don't result in messages to the 1921 // that SetBounsdWindows/AddWindow and the like don't result in messages to the
1864 // originating connection. 1922 // originating connection.
1865 1923
1866 // TODO(sky): make sure coverage of what was 1924 // TODO(sky): make sure coverage of what was
1867 // WindowManagerTest.SecondEmbedRoot_InitService and 1925 // WindowManagerTest.SecondEmbedRoot_InitService and
1868 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 1926 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
1869 // manager 1927 // manager
1870 // tests. 1928 // tests.
1871 1929
1872 } // namespace ws 1930 } // namespace ws
1873 } // namespace mus 1931 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_manager_access_policy.cc ('k') | components/mus/ws/window_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698