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

Unified Diff: ash/wm/toplevel_window_event_handler_unittest.cc

Issue 1800793003: Check if the resizer has been deleted during drag start. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/toplevel_window_event_handler_unittest.cc
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index 55129eb9e4f9f98568a796d4326d683958b7fcb2..165c92c712b8f247f18df4ada2ac33a7a0b63593 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -17,6 +17,7 @@
#include "base/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/client/capture_client.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window_event_dispatcher.h"
@@ -67,8 +68,8 @@ class ToplevelWindowEventHandlerTest : public AshTestBase {
w1->SetType(ui::wm::WINDOW_TYPE_NORMAL);
w1->set_id(1);
w1->Init(ui::LAYER_TEXTURED);
- aura::Window* parent = Shell::GetContainer(
- Shell::GetPrimaryRootWindow(), kShellWindowId_AlwaysOnTopContainer);
+ aura::Window* parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
+ kShellWindowId_DefaultContainer);
oshima 2016/03/15 09:15:04 This is is to use normal dragging path (window in
parent->AddChild(w1);
w1->SetBounds(gfx::Rect(0, 0, 100, 100));
w1->Show();
@@ -109,6 +110,36 @@ TEST_F(ToplevelWindowEventHandlerTest, Caption) {
EXPECT_EQ(size.ToString(), w1->bounds().size().ToString());
}
+namespace {
+
+class CancelDragObserver : public aura::WindowObserver {
+ public:
+ CancelDragObserver() {}
+ ~CancelDragObserver() override {}
+
+ void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override {
+ aura::client::CaptureClient* client =
+ aura::client::GetCaptureClient(params.target->GetRootWindow());
+ client->SetCapture(nullptr);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CancelDragObserver);
+};
+
+} // namespace
+
+// Cancelling drag while starting window drag should not crash.
+TEST_F(ToplevelWindowEventHandlerTest, CancelWhileDragStart) {
+ scoped_ptr<aura::Window> w1(CreateWindow(HTCAPTION));
+ CancelDragObserver observer;
+ w1->AddObserver(&observer);
+ gfx::Point origin = w1->bounds().origin();
+ DragFromCenterBy(w1.get(), 100, 100);
+ EXPECT_EQ(origin, w1->bounds().origin());
+ w1->RemoveObserver(&observer);
+}
+
TEST_F(ToplevelWindowEventHandlerTest, BottomRight) {
scoped_ptr<aura::Window> w1(CreateWindow(HTBOTTOMRIGHT));
gfx::Point position = w1->bounds().origin();
« no previous file with comments | « ash/wm/dock/docked_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698