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

Unified Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 10823199: While dragging a window, show a semi-transparent aura window instead of the standard gray phantom wi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win_aura Created 8 years, 4 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/workspace/workspace_window_resizer_unittest.cc
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index 8291dfc7081795f9a227bd8beec95cf45801a8e3..5333353e4671fa84dbd86c42f6ca062bd057f6a2 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -10,6 +10,7 @@
#include "ash/test/ash_test_base.h"
#include "ash/wm/property_util.h"
#include "ash/wm/workspace_controller.h"
+#include "ash/wm/workspace/phantom_window_controller.h"
#include "base/string_number_conversions.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_window_delegate.h"
@@ -62,16 +63,19 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
EXPECT_EQ(kRootHeight, root_bounds.height());
Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
window_.reset(new aura::Window(&delegate_));
+ window_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window_->Init(ui::LAYER_NOT_DRAWN);
window_->SetParent(default_container);
window_->set_id(1);
window2_.reset(new aura::Window(&delegate2_));
+ window2_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window2_->Init(ui::LAYER_NOT_DRAWN);
window2_->SetParent(default_container);
window2_->set_id(2);
window3_.reset(new aura::Window(&delegate3_));
+ window3_->SetType(aura::client::WINDOW_TYPE_NORMAL);
window3_->Init(ui::LAYER_NOT_DRAWN);
window3_->SetParent(default_container);
window3_->set_id(3);
@@ -140,10 +144,12 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
DISABLED_WindowDragWithMultiMonitors
#define MAYBE_WindowDragWithMultiMonitorsRightToLeft \
DISABLED_WindowDragWithMultiMonitorsRightToLeft
+#define MAYBE_PhantomStyle DISABLED_PhantomStyle
#else
#define MAYBE_WindowDragWithMultiMonitors WindowDragWithMultiMonitors
#define MAYBE_WindowDragWithMultiMonitorsRightToLeft \
WindowDragWithMultiMonitorsRightToLeft
+#define MAYBE_PhantomStyle PhantomStyle
#endif
// Assertions around attached window resize dragging from the right with 2
@@ -569,6 +575,75 @@ TEST_F(WorkspaceWindowResizerTest,
}
}
+// Verifies the style of the drag phantom window is correct.
+TEST_F(WorkspaceWindowResizerTest, MAYBE_PhantomStyle) {
+ UpdateDisplay("800x600,800x600");
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ ASSERT_EQ(2U, root_windows.size());
+
+ window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
+ gfx::Screen::GetPrimaryDisplay());
+ EXPECT_EQ(root_windows[0], window_->GetRootWindow());
+ EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
+ {
+ SetGridSize(0);
+ scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
+ ASSERT_TRUE(resizer.get());
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_for_testing());
+ EXPECT_FALSE(resizer->drag_phantom_window_controller_for_testing());
+
+ // The pointer is inside the primary root. Both phantoms should be NULL.
+ resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0);
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_for_testing());
+ EXPECT_FALSE(resizer->drag_phantom_window_controller_for_testing());
+
+ // The window spans both root windows.
+ resizer->Drag(CalculateDragPoint(*resizer, 798, 10), 0);
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_for_testing());
+ PhantomWindowController* controller =
+ resizer->drag_phantom_window_controller_for_testing();
+ ASSERT_TRUE(controller);
+ EXPECT_EQ(PhantomWindowController::STYLE_WINDOW, controller->style());
+ // |window_| should be opaque since the pointer is still on the primary
+ // root window. The phantom should be semi-transparent.
+ EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
+ EXPECT_GT(1.0f, controller->GetOpacity());
+
+ // Enter the pointer to the secondary display.
+ resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_for_testing());
+ controller = resizer->drag_phantom_window_controller_for_testing();
+ ASSERT_TRUE(controller);
+ EXPECT_EQ(PhantomWindowController::STYLE_WINDOW, controller->style());
+ // |window_| should be transparent, and the phantom should be opaque.
+ EXPECT_GT(1.0f, window_->layer()->opacity());
+ EXPECT_FLOAT_EQ(1.0f, controller->GetOpacity());
+
+ resizer->CompleteDrag(0);
+ EXPECT_EQ(root_windows[1], window_->GetRootWindow());
+ EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
+ }
+
+ // Do the same test with RevertDrag().
+ window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
+ gfx::Screen::GetPrimaryDisplay());
+ EXPECT_EQ(root_windows[0], window_->GetRootWindow());
+ EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
+ {
+ scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
+ ASSERT_TRUE(resizer.get());
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_for_testing());
+ EXPECT_FALSE(resizer->drag_phantom_window_controller_for_testing());
+
+ resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
+ resizer->RevertDrag();
+ EXPECT_EQ(root_windows[0], window_->GetRootWindow());
+ EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
+ }
+}
+
// Verifies windows are correctly restacked when reordering multiple windows.
TEST_F(WorkspaceWindowResizerTest, RestackAttached) {
window_->SetBounds(gfx::Rect( 0, 0, 200, 300));
« ash/wm/workspace/phantom_window_controller.cc ('K') | « ash/wm/workspace/workspace_window_resizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698