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

Unified Diff: ash/wm/panels/panel_window_resizer_unittest.cc

Issue 12441010: Attach panel while dragging to bring it in front of other panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: ash/wm/panels/panel_window_resizer_unittest.cc
diff --git a/ash/wm/panels/panel_window_resizer_unittest.cc b/ash/wm/panels/panel_window_resizer_unittest.cc
index 4be464567b906f15ba5f803a969bc6b789c5f3fc..521d2b4b8d780b3508eb6292a11bbb59a911cad0 100644
--- a/ash/wm/panels/panel_window_resizer_unittest.cc
+++ b/ash/wm/panels/panel_window_resizer_unittest.cc
@@ -15,6 +15,7 @@
#include "ash/test/test_launcher_delegate.h"
#include "ash/wm/panels/panel_layout_manager.h"
#include "ash/wm/window_properties.h"
+#include "ash/wm/window_resizer_owner.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_window_delegate.h"
@@ -25,9 +26,10 @@
namespace ash {
namespace internal {
-class PanelWindowResizerTest : public test::AshTestBase {
+class PanelWindowResizerTest : public test::AshTestBase,
+ public WindowResizerOwner {
public:
- PanelWindowResizerTest() : window_(NULL) {}
+ PanelWindowResizerTest() : window_(NULL), resizer_passed_(false) {}
virtual ~PanelWindowResizerTest() {}
virtual void SetUp() OVERRIDE {
@@ -45,6 +47,14 @@ class PanelWindowResizerTest : public test::AshTestBase {
AshTestBase::TearDown();
}
+ virtual void PassResizer(WindowResizerOwner* new_owner) {
+ resizer_passed_ = true;
+ }
+
+ virtual void AcceptResizer(WindowResizer* resizer,
+ bool in_gesture_drag) {
+ }
+
protected:
gfx::Point CalculateDragPoint(const PanelWindowResizer& resizer,
int delta_x,
@@ -77,15 +87,17 @@ class PanelWindowResizerTest : public test::AshTestBase {
}
static PanelWindowResizer* CreatePanelWindowResizer(
+ WindowResizerOwner* owner,
aura::Window* window,
const gfx::Point& point_in_parent,
int window_component) {
return static_cast<PanelWindowResizer*>(CreateWindowResizer(
- window, point_in_parent, window_component).release());
+ owner, window, point_in_parent, window_component).release());
}
void DragStart() {
- resizer_.reset(CreatePanelWindowResizer(window_.get(), gfx::Point(),
+ resizer_passed_ = false;
+ resizer_.reset(CreatePanelWindowResizer(this, window_.get(), gfx::Point(),
HTCAPTION));
ASSERT_TRUE(resizer_.get());
}
@@ -103,6 +115,7 @@ class PanelWindowResizerTest : public test::AshTestBase {
// dragging out by the vector (dx, dy).
void DetachReattachTest(int dx, int dy) {
EXPECT_TRUE(window_->GetProperty(kPanelAttachedKey));
+ EXPECT_EQ(internal::kShellWindowId_PanelContainer, window_->parent()->id());
DragStart();
gfx::Rect initial_bounds = window_->bounds();
@@ -120,6 +133,8 @@ class PanelWindowResizerTest : public test::AshTestBase {
// The panel should be detached when the drag completes.
DragEnd();
EXPECT_FALSE(window_->GetProperty(kPanelAttachedKey));
+ EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
+ window_->parent()->id());
DragStart();
// Drag the panel down.
@@ -131,6 +146,7 @@ class PanelWindowResizerTest : public test::AshTestBase {
EXPECT_TRUE(window_->GetProperty(kPanelAttachedKey));
EXPECT_EQ(initial_bounds.x(), window_->bounds().x());
EXPECT_EQ(initial_bounds.y(), window_->bounds().y());
+ EXPECT_EQ(internal::kShellWindowId_PanelContainer, window_->parent()->id());
}
aura::test::TestWindowDelegate delegate_;
@@ -139,6 +155,7 @@ class PanelWindowResizerTest : public test::AshTestBase {
aura::Window* panel_container_;
internal::PanelLayoutManager* panel_layout_manager_;
gfx::Rect launcher_bounds_;
+ bool resizer_passed_;
private:
DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTest);
@@ -177,5 +194,24 @@ TEST_F(PanelWindowResizerTest, PanelDetachReattachTop) {
DetachReattachTest(0, 1);
}
+TEST_F(PanelWindowResizerTest, DragMovesToPanelLayer) {
+ DragStart();
+ DragMove(0, -100);
+ DragEnd();
+ EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
+ window_->parent()->id());
+
+ // While moving the panel window should be moved to the panel container.
+ DragStart();
+ DragMove(20, 0);
+ EXPECT_EQ(internal::kShellWindowId_PanelContainer, window_->parent()->id());
+ EXPECT_TRUE(resizer_passed_);
+ DragEnd();
+
+ // When dropped it should return to the default container.
+ EXPECT_EQ(internal::kShellWindowId_WorkspaceContainer,
+ window_->parent()->id());
+}
+
} // namespace internal
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698