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

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

Powered by Google App Engine
This is Rietveld 408576698