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

Unified Diff: ui/views/mus/desktop_window_tree_host_mus_unittest.cc

Issue 2596723002: mus: Unset the cursor client during teardown. (Closed)
Patch Set: - Created 4 years 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
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/desktop_window_tree_host_mus_unittest.cc
diff --git a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
index 23c0aa0d044dbdf3e5abab8e75d8bbeae6e5ce1a..3bdfede047c5d7d6b345d7dab0bb3192d81b44d5 100644
--- a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
+++ b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
@@ -5,6 +5,7 @@
#include "ui/views/mus/desktop_window_tree_host_mus.h"
#include "base/memory/ptr_util.h"
+#include "ui/aura/client/cursor_client.h"
#include "ui/aura/window.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
@@ -32,6 +33,32 @@ class DesktopWindowTreeHostMusTest : public ViewsTestBase {
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostMusTest);
};
+class ExpectsNullCursorClientDuringTearDown : public aura::WindowObserver {
+ public:
+ explicit ExpectsNullCursorClientDuringTearDown(aura::Window* window)
+ : window_(window) {
+ window_->AddObserver(this);
+ }
+
+ ~ExpectsNullCursorClientDuringTearDown() override {
+ EXPECT_FALSE(window_);
+ }
+
+ private:
+ // aura::WindowObserver:
+ void OnWindowRemovingFromRootWindow(aura::Window* window,
+ aura::Window* new_root) override {
+ aura::client::CursorClient* cursor_client =
+ aura::client::GetCursorClient(window->GetRootWindow());
+ EXPECT_FALSE(cursor_client);
+ window_->RemoveObserver(this);
+ window_ = nullptr;
+ }
+
+ aura::Window* window_;
+ DISALLOW_COPY_AND_ASSIGN(ExpectsNullCursorClientDuringTearDown);
+};
+
TEST_F(DesktopWindowTreeHostMusTest, Visibility) {
std::unique_ptr<Widget> widget(CreateWidget(nullptr));
EXPECT_FALSE(widget->IsVisible());
@@ -49,4 +76,16 @@ TEST_F(DesktopWindowTreeHostMusTest, Visibility) {
EXPECT_FALSE(widget->GetNativeView()->parent()->IsVisible());
}
+TEST_F(DesktopWindowTreeHostMusTest, CursorClientDuringTearDown) {
+ std::unique_ptr<Widget> widget(CreateWidget(nullptr));
+ widget->Show();
+
+ std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
+ window->Init(ui::LAYER_SOLID_COLOR);
+ ExpectsNullCursorClientDuringTearDown observer(window.get());
+
+ widget->GetNativeWindow()->AddChild(window.release());
+ widget.reset();
+}
+
} // namespace views
« no previous file with comments | « ui/views/mus/desktop_window_tree_host_mus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698