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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 11033038: Fix the issue of cursor's device scale factor when using monitors with differnt device scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a comment Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/mouse_cursor_event_filter.h" 8 #include "ash/display/mouse_cursor_event_filter.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
13 #include "ash/test/cursor_manager_test_api.h"
14 #include "ash/wm/cursor_manager.h"
13 #include "ash/wm/property_util.h" 15 #include "ash/wm/property_util.h"
14 #include "ash/wm/shelf_layout_manager.h" 16 #include "ash/wm/shelf_layout_manager.h"
15 #include "ash/wm/workspace_controller.h" 17 #include "ash/wm/workspace_controller.h"
16 #include "ash/wm/workspace/snap_sizer.h" 18 #include "ash/wm/workspace/snap_sizer.h"
17 #include "ash/wm/workspace/phantom_window_controller.h" 19 #include "ash/wm/workspace/phantom_window_controller.h"
18 #include "ash/wm/workspace/workspace_layout_manager2.h" 20 #include "ash/wm/workspace/workspace_layout_manager2.h"
19 #include "base/string_number_conversions.h" 21 #include "base/string_number_conversions.h"
20 #include "base/stringprintf.h" 22 #include "base/stringprintf.h"
21 #include "ui/aura/root_window.h" 23 #include "ui/aura/root_window.h"
22 #include "ui/aura/test/test_window_delegate.h" 24 #include "ui/aura/test/test_window_delegate.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 141
140 // Fails on win_aura since wm::GetRootWindowRelativeToWindow is not implemented 142 // Fails on win_aura since wm::GetRootWindowRelativeToWindow is not implemented
141 // yet for the platform. 143 // yet for the platform.
142 #if defined(OS_WIN) 144 #if defined(OS_WIN)
143 #define MAYBE_WindowDragWithMultiDisplays \ 145 #define MAYBE_WindowDragWithMultiDisplays \
144 DISABLED_WindowDragWithMultiDisplays 146 DISABLED_WindowDragWithMultiDisplays
145 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \ 147 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \
146 DISABLED_WindowDragWithMultiDisplaysRightToLeft 148 DISABLED_WindowDragWithMultiDisplaysRightToLeft
147 #define MAYBE_PhantomStyle DISABLED_PhantomStyle 149 #define MAYBE_PhantomStyle DISABLED_PhantomStyle
148 #define MAYBE_CancelSnapPhantom DISABLED_CancelSnapPhantom 150 #define MAYBE_CancelSnapPhantom DISABLED_CancelSnapPhantom
151 #define MAYBE_CursorDeviceScaleFactor DISABLED_CursorDeviceScaleFactor
149 #else 152 #else
150 #define MAYBE_WindowDragWithMultiDisplays WindowDragWithMultiDisplays 153 #define MAYBE_WindowDragWithMultiDisplays WindowDragWithMultiDisplays
151 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \ 154 #define MAYBE_WindowDragWithMultiDisplaysRightToLeft \
152 WindowDragWithMultiDisplaysRightToLeft 155 WindowDragWithMultiDisplaysRightToLeft
153 #define MAYBE_PhantomStyle PhantomStyle 156 #define MAYBE_PhantomStyle PhantomStyle
154 #define MAYBE_CancelSnapPhantom CancelSnapPhantom 157 #define MAYBE_CancelSnapPhantom CancelSnapPhantom
158 #define MAYBE_CursorDeviceScaleFactor CursorDeviceScaleFactor
155 #endif 159 #endif
156 160
157 // Assertions around attached window resize dragging from the right with 2 161 // Assertions around attached window resize dragging from the right with 2
158 // windows. 162 // windows.
159 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { 163 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) {
160 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); 164 window_->SetBounds(gfx::Rect(0, 300, 400, 300));
161 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); 165 window2_->SetBounds(gfx::Rect(400, 200, 100, 200));
162 166
163 std::vector<aura::Window*> windows; 167 std::vector<aura::Window*> windows;
164 windows.push_back(window2_.get()); 168 windows.push_back(window2_.get());
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 1065
1062 // Move |window| one pixel above |window2|. 1066 // Move |window| one pixel above |window2|.
1063 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); 1067 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0);
1064 EXPECT_EQ("152,130 20x30", window_->bounds().ToString()); 1068 EXPECT_EQ("152,130 20x30", window_->bounds().ToString());
1065 1069
1066 // Move |window| one pixel above the bottom of |window2|. 1070 // Move |window| one pixel above the bottom of |window2|.
1067 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); 1071 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0);
1068 EXPECT_EQ("152,180 20x30", window_->bounds().ToString()); 1072 EXPECT_EQ("152,180 20x30", window_->bounds().ToString());
1069 } 1073 }
1070 1074
1075 // Verifies cursor's device scale factor is updated whe a window is moved across
1076 // root windows with different device scale factors (http://crbug.com/154183).
1077 TEST_F(WorkspaceWindowResizerTest, MAYBE_CursorDeviceScaleFactor) {
1078 // The secondary display is logically on the right, but on the system (e.g. X)
1079 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
1080 UpdateDisplay("400x400,800x800*2");
1081 Shell::GetInstance()->shelf()->LayoutShelf();
1082 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
1083 ASSERT_EQ(2U, root_windows.size());
1084
1085 test::CursorManagerTestApi cursor_test_api(
1086 Shell::GetInstance()->cursor_manager());
1087 MouseCursorEventFilter* event_filter =
1088 Shell::GetInstance()->mouse_cursor_filter();
1089 // Move window from the root window with 1.0 device scale factor to the root
1090 // window with 2.0 device scale factor.
1091 {
1092 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
1093 Shell::GetScreen()->GetPrimaryDisplay());
1094 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
1095 // Grab (0, 0) of the window.
1096 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
1097 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
1098 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor());
1099 ASSERT_TRUE(resizer.get());
1100 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
1101 event_filter->WarpMouseCursorIfNecessary(root_windows[0],
1102 gfx::Point(399, 200));
1103 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor());
1104 resizer->CompleteDrag(0);
1105 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor());
1106 }
1107
1108 // Move window from the root window with 2.0 device scale factor to the root
1109 // window with 1.0 device scale factor.
1110 {
1111 window_->SetBoundsInScreen(
1112 gfx::Rect(600, 0, 50, 60),
1113 Shell::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
1114 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
1115 // Grab (0, 0) of the window.
1116 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
1117 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
1118 EXPECT_EQ(2.0f, cursor_test_api.GetDeviceScaleFactor());
1119 ASSERT_TRUE(resizer.get());
1120 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
1121 event_filter->WarpMouseCursorIfNecessary(root_windows[1],
1122 gfx::Point(400, 200));
1123 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor());
1124 resizer->CompleteDrag(0);
1125 EXPECT_EQ(1.0f, cursor_test_api.GetDeviceScaleFactor());
1126 }
1127 }
1128
1071 } // namespace internal 1129 } // namespace internal
1072 } // namespace ash 1130 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/snap_sizer.cc ('k') | chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698