Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Unified Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2604453002: Fix WindowTreeClient::RequestClose(window_id). (Closed)
Patch Set: remove non-root case Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/aura/mus/window_tree_client.cc ('K') | « ui/aura/mus/window_tree_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« ui/aura/mus/window_tree_client.cc ('K') | « ui/aura/mus/window_tree_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698