| 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..1c22711191116bd2636adc2b0c0684f0863e5518 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,75 @@ TEST_F(WindowTreeClientClientTest, NewTopLevelWindowGetsProperties) {
|
| properties2[kUnknownPropertyKey]));
|
| }
|
|
|
| +namespace {
|
| +
|
| +class CloseWindowTestWindowDelegate : public test::TestWindowDelegate {
|
| + public:
|
| + CloseWindowTestWindowDelegate() {}
|
| + ~CloseWindowTestWindowDelegate() override {}
|
| +
|
| + bool window_closed() const { return window_closed_; }
|
| +
|
| + // TestWindowDelegate::
|
| + void OnRequestClose() override { window_closed_ = true; }
|
| +
|
| + private:
|
| + bool window_closed_ = false;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CloseWindowTestWindowDelegate);
|
| +};
|
| +
|
| +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();
|
| +
|
| + CloseWindowTestWindowDelegate window_delegate1;
|
| + Window child1(&window_delegate1);
|
| + child1.Init(ui::LAYER_NOT_DRAWN);
|
| + top_level->AddChild(&child1);
|
| + CloseWindowTestWindowDelegate window_delegate2;
|
| + Window child2(&window_delegate2);
|
| + child2.Init(ui::LAYER_NOT_DRAWN);
|
| + top_level->AddChild(&child2);
|
| +
|
| + // Close a child window should only trigger its window delegate to close
|
| + // that window.
|
| + EXPECT_FALSE(window_delegate1.window_closed());
|
| + window_tree_client()->RequestClose(server_id(&child1));
|
| + EXPECT_TRUE(window_delegate1.window_closed());
|
| + EXPECT_FALSE(window_delegate2.window_closed());
|
| + EXPECT_FALSE(observer.root_destroyed());
|
| +
|
| + // Close a root window should send close request to the observer of its
|
| + // WindowTreeHost.
|
| + window_tree_client()->RequestClose(server_id(top_level));
|
| + EXPECT_TRUE(observer.root_destroyed());
|
| + EXPECT_FALSE(window_delegate2.window_closed());
|
| +}
|
| +
|
| // Tests both SetCapture and ReleaseCapture, to ensure that Window is properly
|
| // updated on failures.
|
| TEST_F(WindowTreeClientWmTest, ExplicitCapture) {
|
|
|