OLD | NEW |
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 "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/window_tree_client.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 EXPECT_EQ(top_level->id(), capture_recorder2->last_lost_capture_window_id()); | 1739 EXPECT_EQ(top_level->id(), capture_recorder2->last_lost_capture_window_id()); |
1740 | 1740 |
1741 capture_recorder1->reset_capture_captured_count(); | 1741 capture_recorder1->reset_capture_captured_count(); |
1742 capture_recorder2->reset_capture_captured_count(); | 1742 capture_recorder2->reset_capture_captured_count(); |
1743 capture_recorder1.reset(); | 1743 capture_recorder1.reset(); |
1744 capture_recorder2.reset(); | 1744 capture_recorder2.reset(); |
1745 window_tree_host.reset(); | 1745 window_tree_host.reset(); |
1746 capture_client.reset(); | 1746 capture_client.reset(); |
1747 } | 1747 } |
1748 | 1748 |
1749 TEST_F(WindowTreeClientClientTest, ModalFail) { | 1749 TEST_F(WindowTreeClientClientTest, ModalTypeWindowFail) { |
1750 Window window(nullptr); | 1750 Window window(nullptr); |
1751 window.Init(ui::LAYER_NOT_DRAWN); | 1751 window.Init(ui::LAYER_NOT_DRAWN); |
1752 window.SetProperty(client::kModalKey, ui::MODAL_TYPE_WINDOW); | 1752 window.SetProperty(client::kModalKey, ui::MODAL_TYPE_WINDOW); |
1753 // Make sure server was told about it, and have the server say it failed. | 1753 // Make sure server was told about it, and have the server say it failed. |
1754 ASSERT_TRUE( | 1754 ASSERT_TRUE( |
1755 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); | 1755 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); |
1756 // Type should be back to MODAL_TYPE_NONE as the server didn't accept the | 1756 // Type should be back to MODAL_TYPE_NONE as the server didn't accept the |
1757 // change. | 1757 // change. |
1758 EXPECT_EQ(ui::MODAL_TYPE_NONE, window.GetProperty(client::kModalKey)); | 1758 EXPECT_EQ(ui::MODAL_TYPE_NONE, window.GetProperty(client::kModalKey)); |
| 1759 // Server is told that the type is set back to MODAL_TYPE_NONE. |
| 1760 EXPECT_TRUE( |
| 1761 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true)); |
| 1762 // Type should still remain MODAL_TYPE_NONE. |
| 1763 EXPECT_EQ(ui::MODAL_TYPE_NONE, window.GetProperty(client::kModalKey)); |
| 1764 } |
| 1765 |
| 1766 TEST_F(WindowTreeClientClientTest, ModalTypeNoneFail) { |
| 1767 Window window(nullptr); |
| 1768 window.Init(ui::LAYER_NOT_DRAWN); |
| 1769 // First, set modality type to window sucessfully. |
| 1770 window.SetProperty(client::kModalKey, ui::MODAL_TYPE_WINDOW); |
| 1771 ASSERT_TRUE( |
| 1772 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true)); |
| 1773 EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey)); |
| 1774 // Now, set type to MODAL_TYPE_NONE, and have the server say it failed. |
| 1775 window.SetProperty(client::kModalKey, ui::MODAL_TYPE_NONE); |
| 1776 ASSERT_TRUE( |
| 1777 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); |
| 1778 // Type should be back to MODAL_TYPE_WINDOW as the server didn't accept the |
| 1779 // change. |
| 1780 EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey)); |
| 1781 // Server is told that the type is set back to MODAL_TYPE_WINDOW. |
| 1782 EXPECT_TRUE( |
| 1783 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true)); |
| 1784 // Type should still remain MODAL_TYPE_WINDOW. |
| 1785 EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey)); |
| 1786 } |
| 1787 |
| 1788 TEST_F(WindowTreeClientClientTest, ModalTypeSuccess) { |
| 1789 Window window(nullptr); |
| 1790 window.Init(ui::LAYER_NOT_DRAWN); |
| 1791 |
| 1792 // Set modality type to MODAL_TYPE_WINDOW, MODAL_TYPE_SYSTEM, and then back to |
| 1793 // MODAL_TYPE_NONE, and make sure it succeeds each time. |
| 1794 ui::ModalType kModalTypes[] = {ui::MODAL_TYPE_WINDOW, ui::MODAL_TYPE_SYSTEM, |
| 1795 ui::MODAL_TYPE_NONE}; |
| 1796 for (size_t i = 0; i < arraysize(kModalTypes); i++) { |
| 1797 window.SetProperty(client::kModalKey, kModalTypes[i]); |
| 1798 // Ack change as succeeding. |
| 1799 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( |
| 1800 WindowTreeChangeType::MODAL, true)); |
| 1801 EXPECT_EQ(kModalTypes[i], window.GetProperty(client::kModalKey)); |
| 1802 } |
| 1803 |
1759 // There should be no more modal changes. | 1804 // There should be no more modal changes. |
1760 EXPECT_FALSE( | 1805 EXPECT_FALSE( |
1761 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); | 1806 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); |
1762 } | |
1763 | |
1764 TEST_F(WindowTreeClientClientTest, ModalSuccess) { | |
1765 Window window(nullptr); | |
1766 window.Init(ui::LAYER_NOT_DRAWN); | |
1767 window.SetProperty(client::kModalKey, ui::MODAL_TYPE_WINDOW); | |
1768 // Ack change as succeeding. | |
1769 ASSERT_TRUE( | |
1770 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, true)); | |
1771 EXPECT_EQ(ui::MODAL_TYPE_WINDOW, window.GetProperty(client::kModalKey)); | |
1772 // There should be no more modal changes. | |
1773 EXPECT_FALSE( | |
1774 window_tree()->AckSingleChangeOfType(WindowTreeChangeType::MODAL, false)); | |
1775 } | 1807 } |
1776 | 1808 |
1777 // Verifies OnWindowHierarchyChanged() deals correctly with identifying existing | 1809 // Verifies OnWindowHierarchyChanged() deals correctly with identifying existing |
1778 // windows. | 1810 // windows. |
1779 TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithExistingWindow) { | 1811 TEST_F(WindowTreeClientWmTest, OnWindowHierarchyChangedWithExistingWindow) { |
1780 Window* window1 = new Window(nullptr); | 1812 Window* window1 = new Window(nullptr); |
1781 window1->Init(ui::LAYER_NOT_DRAWN); | 1813 window1->Init(ui::LAYER_NOT_DRAWN); |
1782 Window* window2 = new Window(nullptr); | 1814 Window* window2 = new Window(nullptr); |
1783 window2->Init(ui::LAYER_NOT_DRAWN); | 1815 window2->Init(ui::LAYER_NOT_DRAWN); |
1784 window_tree()->AckAllChanges(); | 1816 window_tree()->AckAllChanges(); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1984 window_tree()->GetEventResult(event_id)); | 2016 window_tree()->GetEventResult(event_id)); |
1985 EXPECT_TRUE(window_delegate1.got_move()); | 2017 EXPECT_TRUE(window_delegate1.got_move()); |
1986 EXPECT_FALSE(window_delegate2.got_move()); | 2018 EXPECT_FALSE(window_delegate2.got_move()); |
1987 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, | 2019 gfx::Point transformed_event_location_in_dip(event_location_in_dip.x() + 20, |
1988 event_location_in_dip.y() + 30); | 2020 event_location_in_dip.y() + 30); |
1989 EXPECT_EQ(transformed_event_location_in_dip, | 2021 EXPECT_EQ(transformed_event_location_in_dip, |
1990 window_delegate1.last_event_location()); | 2022 window_delegate1.last_event_location()); |
1991 } | 2023 } |
1992 | 2024 |
1993 } // namespace aura | 2025 } // namespace aura |
OLD | NEW |