| 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 CloseWindowTestWindowDelegate : public test::TestWindowDelegate { |
| 1138 public: |
| 1139 CloseWindowTestWindowDelegate() {} |
| 1140 ~CloseWindowTestWindowDelegate() override {} |
| 1141 |
| 1142 bool window_closed() const { return window_closed_; } |
| 1143 |
| 1144 // TestWindowDelegate:: |
| 1145 void OnRequestClose() override { window_closed_ = true; } |
| 1146 |
| 1147 private: |
| 1148 bool window_closed_ = false; |
| 1149 |
| 1150 DISALLOW_COPY_AND_ASSIGN(CloseWindowTestWindowDelegate); |
| 1151 }; |
| 1152 |
| 1153 class CloseWindowWindowTreeHostObserver : public aura::WindowTreeHostObserver { |
| 1154 public: |
| 1155 CloseWindowWindowTreeHostObserver() {} |
| 1156 ~CloseWindowWindowTreeHostObserver() override {} |
| 1157 |
| 1158 bool root_destroyed() const { return root_destroyed_; } |
| 1159 |
| 1160 // aura::WindowTreeHostObserver:: |
| 1161 void OnHostCloseRequested(const aura::WindowTreeHost* host) override { |
| 1162 root_destroyed_ = true; |
| 1163 } |
| 1164 |
| 1165 private: |
| 1166 bool root_destroyed_ = false; |
| 1167 |
| 1168 DISALLOW_COPY_AND_ASSIGN(CloseWindowWindowTreeHostObserver); |
| 1169 }; |
| 1170 |
| 1171 } // namespace |
| 1172 |
| 1173 TEST_F(WindowTreeClientClientTest, CloseWindow) { |
| 1174 WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
| 1175 window_tree_host.InitHost(); |
| 1176 CloseWindowWindowTreeHostObserver observer; |
| 1177 window_tree_host.AddObserver(&observer); |
| 1178 Window* top_level = window_tree_host.window(); |
| 1179 |
| 1180 CloseWindowTestWindowDelegate window_delegate1; |
| 1181 Window child1(&window_delegate1); |
| 1182 child1.Init(ui::LAYER_NOT_DRAWN); |
| 1183 top_level->AddChild(&child1); |
| 1184 CloseWindowTestWindowDelegate window_delegate2; |
| 1185 Window child2(&window_delegate2); |
| 1186 child2.Init(ui::LAYER_NOT_DRAWN); |
| 1187 top_level->AddChild(&child2); |
| 1188 |
| 1189 // Close a child window should only trigger its window delegate to close |
| 1190 // that window. |
| 1191 EXPECT_FALSE(window_delegate1.window_closed()); |
| 1192 window_tree_client()->RequestClose(server_id(&child1)); |
| 1193 EXPECT_TRUE(window_delegate1.window_closed()); |
| 1194 EXPECT_FALSE(window_delegate2.window_closed()); |
| 1195 EXPECT_FALSE(observer.root_destroyed()); |
| 1196 |
| 1197 // Close a root window should send close request to the observer of its |
| 1198 // WindowTreeHost. |
| 1199 window_tree_client()->RequestClose(server_id(top_level)); |
| 1200 EXPECT_TRUE(observer.root_destroyed()); |
| 1201 EXPECT_FALSE(window_delegate2.window_closed()); |
| 1202 } |
| 1203 |
| 1134 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly | 1204 // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly |
| 1135 // updated on failures. | 1205 // updated on failures. |
| 1136 TEST_F(WindowTreeClientWmTest, ExplicitCapture) { | 1206 TEST_F(WindowTreeClientWmTest, ExplicitCapture) { |
| 1137 root_window()->SetCapture(); | 1207 root_window()->SetCapture(); |
| 1138 EXPECT_TRUE(root_window()->HasCapture()); | 1208 EXPECT_TRUE(root_window()->HasCapture()); |
| 1139 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( | 1209 ASSERT_TRUE(window_tree()->AckSingleChangeOfType( |
| 1140 WindowTreeChangeType::CAPTURE, false)); | 1210 WindowTreeChangeType::CAPTURE, false)); |
| 1141 EXPECT_FALSE(root_window()->HasCapture()); | 1211 EXPECT_FALSE(root_window()->HasCapture()); |
| 1142 | 1212 |
| 1143 root_window()->SetCapture(); | 1213 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), | 1528 window_tree_client()->OnTopLevelCreated(change_id, std::move(data), |
| 1459 display_id, true); | 1529 display_id, true); |
| 1460 | 1530 |
| 1461 // aura::Window should operate in DIP and aura::WindowTreeHost should operate | 1531 // aura::Window should operate in DIP and aura::WindowTreeHost should operate |
| 1462 // in pixels. | 1532 // in pixels. |
| 1463 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); | 1533 EXPECT_EQ(gfx::Rect(0, 0, 3, 4), top_level->bounds()); |
| 1464 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); | 1534 EXPECT_EQ(gfx::Rect(2, 4, 6, 8), top_level->GetHost()->GetBoundsInPixels()); |
| 1465 } | 1535 } |
| 1466 | 1536 |
| 1467 } // namespace aura | 1537 } // namespace aura |
| OLD | NEW |