Index: ui/aura/mus/window_tree_client_unittest.cc |
diff --git a/ui/aura/mus/window_tree_client_unittest.cc b/ui/aura/mus/window_tree_client_unittest.cc |
index f3aeeed972f4202db40f6807baf71101df9974d6..ffdb35b1c35e120f7fcca05b22a4a6f05d07648c 100644 |
--- a/ui/aura/mus/window_tree_client_unittest.cc |
+++ b/ui/aura/mus/window_tree_client_unittest.cc |
@@ -32,6 +32,7 @@ |
#include "ui/aura/window.h" |
#include "ui/aura/window_property.h" |
#include "ui/aura/window_tracker.h" |
+#include "ui/aura/window_tree_host_observer.h" |
#include "ui/compositor/compositor.h" |
#include "ui/display/display_switches.h" |
#include "ui/events/event.h" |
@@ -1131,6 +1132,42 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) { |
properties2[kUnknownPropertyKey])); |
} |
+namespace { |
+ |
+class CloseWindowWindowTreeHostObserver : public aura::WindowTreeHostObserver { |
+ public: |
+ CloseWindowWindowTreeHostObserver() {} |
+ ~CloseWindowWindowTreeHostObserver() override {} |
+ |
+ bool root_destroyed() const { return root_destroyed_; } |
+ |
+ // aura::WindowTreeHostObserver:: |
+ void OnHostCloseRequested(const aura::WindowTreeHost* host) override { |
+ root_destroyed_ = true; |
+ } |
+ |
+ private: |
+ bool root_destroyed_ = false; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CloseWindowWindowTreeHostObserver); |
+}; |
+ |
+} // namespace |
+ |
+TEST_F(WindowTreeClientClientTest, CloseWindow) { |
+ WindowTreeHostMus window_tree_host(window_tree_client_impl()); |
+ window_tree_host.InitHost(); |
+ CloseWindowWindowTreeHostObserver observer; |
+ window_tree_host.AddObserver(&observer); |
+ Window* top_level = window_tree_host.window(); |
+ |
+ // Close a root window should send close request to the observer of its |
+ // WindowTreeHost. |
+ EXPECT_FALSE(observer.root_destroyed()); |
+ window_tree_client()->RequestClose(server_id(top_level)); |
+ EXPECT_TRUE(observer.root_destroyed()); |
+} |
+ |
// Tests both SetCapture and ReleaseCapture, to ensure that Window is properly |
// updated on failures. |
TEST_F(WindowTreeClientWmTest, ExplicitCapture) { |