OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "components/mus/public/interfaces/window_tree.mojom.h" | 9 #include "components/mus/public/interfaces/window_tree.mojom.h" |
10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 10 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 tree_ = tree.Pass(); | 291 tree_ = tree.Pass(); |
292 connection_id_ = connection_id; | 292 connection_id_ = connection_id; |
293 tracker()->OnEmbed(connection_id, root.Pass()); | 293 tracker()->OnEmbed(connection_id, root.Pass()); |
294 if (embed_run_loop_) | 294 if (embed_run_loop_) |
295 embed_run_loop_->Quit(); | 295 embed_run_loop_->Quit(); |
296 } | 296 } |
297 void OnEmbeddedAppDisconnected(Id window_id) override { | 297 void OnEmbeddedAppDisconnected(Id window_id) override { |
298 tracker()->OnEmbeddedAppDisconnected(window_id); | 298 tracker()->OnEmbeddedAppDisconnected(window_id); |
299 } | 299 } |
300 void OnUnembed() override { tracker()->OnUnembed(); } | 300 void OnUnembed() override { tracker()->OnUnembed(); } |
| 301 void OnLostCapture(Id window_id) override { |
| 302 tracker()->OnLostCapture(window_id); |
| 303 } |
301 void OnWindowBoundsChanged(Id window_id, | 304 void OnWindowBoundsChanged(Id window_id, |
302 RectPtr old_bounds, | 305 RectPtr old_bounds, |
303 RectPtr new_bounds) override { | 306 RectPtr new_bounds) override { |
304 // The bounds of the root may change during startup on Android at random | 307 // The bounds of the root may change during startup on Android at random |
305 // times. As this doesn't matter, and shouldn't impact test exepctations, | 308 // times. As this doesn't matter, and shouldn't impact test exepctations, |
306 // it is ignored. | 309 // it is ignored. |
307 if (window_id == root_window_id_) | 310 if (window_id == root_window_id_) |
308 return; | 311 return; |
309 tracker()->OnWindowBoundsChanged(window_id, old_bounds.Pass(), | 312 tracker()->OnWindowBoundsChanged(window_id, old_bounds.Pass(), |
310 new_bounds.Pass()); | 313 new_bounds.Pass()); |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 | 1759 |
1757 changes1()->clear(); | 1760 changes1()->clear(); |
1758 ASSERT_TRUE(DeleteWindow(ws2(), window_2_1)); | 1761 ASSERT_TRUE(DeleteWindow(ws2(), window_2_1)); |
1759 ws_client1()->WaitForChangeCount(2); | 1762 ws_client1()->WaitForChangeCount(2); |
1760 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_2), | 1763 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_2), |
1761 ChangesToDescription1(*changes1())[0]); | 1764 ChangesToDescription1(*changes1())[0]); |
1762 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1), | 1765 EXPECT_EQ("WindowDeleted window=" + IdToString(window_2_1), |
1763 ChangesToDescription1(*changes1())[1]); | 1766 ChangesToDescription1(*changes1())[1]); |
1764 } | 1767 } |
1765 | 1768 |
| 1769 TEST_F(WindowTreeAppTest, ExplicitCapturePropagation) { |
| 1770 Id window_1_1 = ws_client1()->NewWindow(1); |
| 1771 Id window_1_2 = ws_client1()->NewWindow(2); |
| 1772 changes1()->clear(); |
| 1773 // Window 1 takes capture then Window 2 takes capture. |
| 1774 // Verify that window 1 has lost capture. |
| 1775 ws1()->SetCapture(1, window_1_1); |
| 1776 ws1()->SetCapture(2, window_1_2); |
| 1777 ws_client1_->WaitForChangeCount(1); |
| 1778 |
| 1779 EXPECT_EQ("OnLostCapture window=" + IdToString(window_1_1), |
| 1780 SingleChangeToDescription(*changes1())); |
| 1781 changes1()->clear(); |
| 1782 ws1()->ReleaseCapture(3, window_1_2); |
| 1783 ws_client1_->WaitForChangeCount(1); |
| 1784 |
| 1785 EXPECT_EQ("OnLostCapture window=" + IdToString(window_1_2), |
| 1786 SingleChangeToDescription(*changes1())); |
| 1787 } |
| 1788 |
1766 // TODO(sky): need to better track changes to initial connection. For example, | 1789 // TODO(sky): need to better track changes to initial connection. For example, |
1767 // that SetBounsdWindows/AddWindow and the like don't result in messages to the | 1790 // that SetBounsdWindows/AddWindow and the like don't result in messages to the |
1768 // originating connection. | 1791 // originating connection. |
1769 | 1792 |
1770 // TODO(sky): make sure coverage of what was | 1793 // TODO(sky): make sure coverage of what was |
1771 // WindowManagerTest.SecondEmbedRoot_InitService and | 1794 // WindowManagerTest.SecondEmbedRoot_InitService and |
1772 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window | 1795 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window |
1773 // manager | 1796 // manager |
1774 // tests. | 1797 // tests. |
1775 | 1798 |
1776 } // namespace ws | 1799 } // namespace ws |
1777 } // namespace mus | 1800 } // namespace mus |
OLD | NEW |