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 14 matching lines...) Expand all Loading... |
25 #include "ui/aura/mus/window_tree_client_delegate.h" | 25 #include "ui/aura/mus/window_tree_client_delegate.h" |
26 #include "ui/aura/mus/window_tree_client_observer.h" | 26 #include "ui/aura/mus/window_tree_client_observer.h" |
27 #include "ui/aura/mus/window_tree_host_mus.h" | 27 #include "ui/aura/mus/window_tree_host_mus.h" |
28 #include "ui/aura/test/aura_mus_test_base.h" | 28 #include "ui/aura/test/aura_mus_test_base.h" |
29 #include "ui/aura/test/mus/test_window_tree.h" | 29 #include "ui/aura/test/mus/test_window_tree.h" |
30 #include "ui/aura/test/mus/window_tree_client_private.h" | 30 #include "ui/aura/test/mus/window_tree_client_private.h" |
31 #include "ui/aura/test/test_window_delegate.h" | 31 #include "ui/aura/test/test_window_delegate.h" |
32 #include "ui/aura/window.h" | 32 #include "ui/aura/window.h" |
33 #include "ui/aura/window_property.h" | 33 #include "ui/aura/window_property.h" |
34 #include "ui/aura/window_tracker.h" | 34 #include "ui/aura/window_tracker.h" |
| 35 #include "ui/aura/window_tree_host_observer.h" |
35 #include "ui/compositor/compositor.h" | 36 #include "ui/compositor/compositor.h" |
36 #include "ui/display/display_switches.h" | 37 #include "ui/display/display_switches.h" |
37 #include "ui/events/event.h" | 38 #include "ui/events/event.h" |
38 #include "ui/events/event_utils.h" | 39 #include "ui/events/event_utils.h" |
39 #include "ui/gfx/geometry/rect.h" | 40 #include "ui/gfx/geometry/rect.h" |
40 | 41 |
41 namespace aura { | 42 namespace aura { |
42 | 43 |
43 namespace { | 44 namespace { |
44 | 45 |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 EXPECT_EQ(static_cast<int64_t>(property_value), | 1125 EXPECT_EQ(static_cast<int64_t>(property_value), |
1125 mojo::ConvertTo<int64_t>(properties2[kTestPropertyServerKey1])); | 1126 mojo::ConvertTo<int64_t>(properties2[kTestPropertyServerKey1])); |
1126 | 1127 |
1127 ASSERT_EQ(1u, properties2.count(kUnknownPropertyKey)); | 1128 ASSERT_EQ(1u, properties2.count(kUnknownPropertyKey)); |
1128 ASSERT_EQ(sizeof(UnknownPropertyType), | 1129 ASSERT_EQ(sizeof(UnknownPropertyType), |
1129 properties2[kUnknownPropertyKey].size()); | 1130 properties2[kUnknownPropertyKey].size()); |
1130 EXPECT_EQ(kUnknownPropertyValue, mojo::ConvertTo<UnknownPropertyType>( | 1131 EXPECT_EQ(kUnknownPropertyValue, mojo::ConvertTo<UnknownPropertyType>( |
1131 properties2[kUnknownPropertyKey])); | 1132 properties2[kUnknownPropertyKey])); |
1132 } | 1133 } |
1133 | 1134 |
| 1135 namespace { |
| 1136 |
| 1137 class CloseWindowWindowTreeHostObserver : public aura::WindowTreeHostObserver { |
| 1138 public: |
| 1139 CloseWindowWindowTreeHostObserver() {} |
| 1140 ~CloseWindowWindowTreeHostObserver() override {} |
| 1141 |
| 1142 bool root_destroyed() const { return root_destroyed_; } |
| 1143 |
| 1144 // aura::WindowTreeHostObserver:: |
| 1145 void OnHostCloseRequested(const aura::WindowTreeHost* host) override { |
| 1146 root_destroyed_ = true; |
| 1147 } |
| 1148 |
| 1149 private: |
| 1150 bool root_destroyed_ = false; |
| 1151 |
| 1152 DISALLOW_COPY_AND_ASSIGN(CloseWindowWindowTreeHostObserver); |
| 1153 }; |
| 1154 |
| 1155 } // namespace |
| 1156 |
| 1157 TEST_F(WindowTreeClientClientTest, CloseWindow) { |
| 1158 WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
| 1159 window_tree_host.InitHost(); |
| 1160 CloseWindowWindowTreeHostObserver observer; |
| 1161 window_tree_host.AddObserver(&observer); |
| 1162 Window* top_level = window_tree_host.window(); |
| 1163 |
| 1164 // Close a root window should send close request to the observer of its |
| 1165 // WindowTreeHost. |
| 1166 EXPECT_FALSE(observer.root_destroyed()); |
| 1167 window_tree_client()->RequestClose(server_id(top_level)); |
| 1168 EXPECT_TRUE(observer.root_destroyed()); |
| 1169 } |
| 1170 |
1134 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly | 1171 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly |
1135 // updated on failures. | 1172 // updated on failures. |
1136 TEST_F(WindowTreeClientWmTest, ExplicitCapture) { | 1173 TEST_F(WindowTreeClientWmTest, ExplicitCapture) { |
1137 root_window()->SetCapture(); | 1174 root_window()->SetCapture(); |
1138 EXPECT_TRUE(root_window()->HasCapture()); | 1175 EXPECT_TRUE(root_window()->HasCapture()); |
1139 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( | 1176 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( |
1140 WindowTreeChangeType::CAPTURE, false)); | 1177 WindowTreeChangeType::CAPTURE, false)); |
1141 EXPECT_FALSE(root_window()->HasCapture()); | 1178 EXPECT_FALSE(root_window()->HasCapture()); |
1142 | 1179 |
1143 root_window()->SetCapture(); | 1180 root_window()->SetCapture(); |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), | 1495 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
1459 display_id, true); | 1496 display_id, true); |
1460 | 1497 |
1461 // aura::Window should operate in DIP and aura::WindowTreeHost should operate | 1498 // aura::Window should operate in DIP and aura::WindowTreeHost should operate |
1462 // in pixels. | 1499 // in pixels. |
1463 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); | 1500 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); |
1464 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); | 1501 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); |
1465 } | 1502 } |
1466 | 1503 |
1467 } // namespace aura | 1504 } // namespace aura |
OLD | NEW |