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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.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
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h"
6 6
7 #include "ash/wm/property_util.h" 7 #include "ash/wm/property_util.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 18 matching lines...) Expand all
29 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
30 #include "ui/gfx/screen.h" 30 #include "ui/gfx/screen.h"
31 #include "ui/ui_controls/ui_controls.h" 31 #include "ui/ui_controls/ui_controls.h"
32 #include "ui/views/view.h" 32 #include "ui/views/view.h"
33 #include "ui/views/widget/widget.h" 33 #include "ui/views/widget/widget.h"
34 34
35 #if defined(USE_ASH) 35 #if defined(USE_ASH)
36 #include "ash/display/display_controller.h" 36 #include "ash/display/display_controller.h"
37 #include "ash/display/multi_display_manager.h" 37 #include "ash/display/multi_display_manager.h"
38 #include "ash/shell.h" 38 #include "ash/shell.h"
39 #include "ash/test/cursor_manager_test_api.h"
40 #include "ash/wm/cursor_manager.h"
39 #include "ui/aura/test/event_generator.h" 41 #include "ui/aura/test/event_generator.h"
40 #include "ui/aura/root_window.h" 42 #include "ui/aura/root_window.h"
41 #endif 43 #endif
42 44
43 namespace test { 45 namespace test {
44 46
45 namespace { 47 namespace {
46 48
47 const char kTabDragControllerInteractiveUITestUserDataKey[] = 49 const char kTabDragControllerInteractiveUITestUserDataKey[] =
48 "TabDragControllerInteractiveUITestUserData"; 50 "TabDragControllerInteractiveUITestUserData";
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1110
1109 // Release the mouse, stopping the drag session. 1111 // Release the mouse, stopping the drag session.
1110 ASSERT_TRUE(ReleaseInput()); 1112 ASSERT_TRUE(ReleaseInput());
1111 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); 1113 ASSERT_FALSE(tab_strip2->IsDragSessionActive());
1112 ASSERT_FALSE(tab_strip->IsDragSessionActive()); 1114 ASSERT_FALSE(tab_strip->IsDragSessionActive());
1113 ASSERT_FALSE(TabDragController::IsActive()); 1115 ASSERT_FALSE(TabDragController::IsActive());
1114 EXPECT_EQ("0 100", IDString(browser2->tab_strip_model())); 1116 EXPECT_EQ("0 100", IDString(browser2->tab_strip_model()));
1115 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); 1117 EXPECT_EQ("1", IDString(browser()->tab_strip_model()));
1116 } 1118 }
1117 1119
1120 class DifferentDeviceScaleFactorDisplayTabDragControllerTest
1121 : public DetachToBrowserTabDragControllerTest {
1122 public:
1123 DifferentDeviceScaleFactorDisplayTabDragControllerTest() {}
1124
1125 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1126 DetachToBrowserTabDragControllerTest::SetUpCommandLine(command_line);
1127 command_line->AppendSwitchASCII("aura-host-window-size",
1128 "400x400,800x800*2");
1129 }
1130
1131 float GetCursorDeviceScaleFactor() const {
1132 ash::test::CursorManagerTestApi cursor_test_api(
1133 ash::Shell::GetInstance()->cursor_manager());
1134 return cursor_test_api.GetDeviceScaleFactor();
1135 }
1136
1137 private:
1138 DISALLOW_COPY_AND_ASSIGN(
1139 DifferentDeviceScaleFactorDisplayTabDragControllerTest);
1140 };
1141
1142 namespace {
1143
1144 // The points where a tab is dragged in CursorDeviceScaleFactorStep.
1145 const struct DragPoint {
1146 int x;
1147 int y;
1148 } kDragPoints[] = {
1149 {300, 200},
1150 {399, 200},
1151 {500, 200},
1152 {400, 200},
1153 {300, 200},
1154 };
1155
1156 // The expected device scale factors before the cursor is moved to the
1157 // corresponding kDragPoints in CursorDeviceScaleFactorStep.
1158 const float kDeviceScaleFactorExpectations[] = {
1159 1.0f,
1160 1.0f,
1161 2.0f,
1162 2.0f,
1163 1.0f,
1164 };
1165
1166 COMPILE_ASSERT(
1167 arraysize(kDragPoints) == arraysize(kDeviceScaleFactorExpectations),
1168 kDragPoints_and_kDeviceScaleFactorExpectations_must_have_same_size);
1169
1170 // Drags tab to |kDragPoints[index]|, then calls the next step function.
1171 void CursorDeviceScaleFactorStep(
1172 DifferentDeviceScaleFactorDisplayTabDragControllerTest* test,
1173 TabStrip* not_attached_tab_strip,
1174 size_t index) {
1175 ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive());
1176 ASSERT_TRUE(TabDragController::IsActive());
1177
1178 if (index < arraysize(kDragPoints)) {
1179 EXPECT_EQ(kDeviceScaleFactorExpectations[index],
1180 test->GetCursorDeviceScaleFactor());
1181 const DragPoint p = kDragPoints[index];
1182 ASSERT_TRUE(test->DragInputToNotifyWhenDone(
1183 p.x, p.y, base::Bind(&CursorDeviceScaleFactorStep,
1184 test, not_attached_tab_strip, index + 1)));
1185 } else {
1186 // Finishes a serise of CursorDeviceScaleFactorStep calls and ends drag.
1187 EXPECT_EQ(1.0f, test->GetCursorDeviceScaleFactor());
1188 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync(
1189 ui_controls::LEFT, ui_controls::UP));
1190 }
1191 }
1192
1193 } // namespace
1194
1195 // Verifies cursor's device scale factor is updated when a tab is moved across
1196 // displays with different device scale factors (http://crbug.com/154183).
1197 IN_PROC_BROWSER_TEST_P(DifferentDeviceScaleFactorDisplayTabDragControllerTest,
1198 CursorDeviceScaleFactor) {
1199 // Add another tab.
1200 AddTabAndResetBrowser(browser());
1201 TabStrip* tab_strip = GetTabStripForBrowser(browser());
1202
1203 // Move the second browser to the second display.
1204 std::vector<aura::RootWindow*> roots(ash::Shell::GetAllRootWindows());
1205 ASSERT_EQ(2u, roots.size());
1206
1207 // Move to the first tab and drag it enough so that it detaches.
1208 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
1209 ASSERT_TRUE(PressInput(tab_0_center));
1210 ASSERT_TRUE(DragInputToNotifyWhenDone(
1211 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip),
1212 base::Bind(&CursorDeviceScaleFactorStep,
1213 this, tab_strip, 0)));
1214 QuitWhenNotDragging();
1215 }
1216
1118 namespace { 1217 namespace {
1119 1218
1120 class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest 1219 class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest
1121 : public TabDragControllerTest { 1220 : public TabDragControllerTest {
1122 public: 1221 public:
1123 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest() {} 1222 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest() {}
1124 1223
1125 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1224 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
1126 TabDragControllerTest::SetUpCommandLine(command_line); 1225 TabDragControllerTest::SetUpCommandLine(command_line);
1127 command_line->AppendSwitchASCII("aura-host-window-size", 1226 command_line->AppendSwitchASCII("aura-host-window-size",
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 ui_controls::LEFT, ui_controls::UP)); 1363 ui_controls::LEFT, ui_controls::UP));
1265 } 1364 }
1266 1365
1267 #endif 1366 #endif
1268 1367
1269 #if defined(USE_ASH) 1368 #if defined(USE_ASH)
1270 INSTANTIATE_TEST_CASE_P(TabDragging, 1369 INSTANTIATE_TEST_CASE_P(TabDragging,
1271 DetachToBrowserInSeparateDisplayTabDragControllerTest, 1370 DetachToBrowserInSeparateDisplayTabDragControllerTest,
1272 ::testing::Values("mouse", "touch")); 1371 ::testing::Values("mouse", "touch"));
1273 INSTANTIATE_TEST_CASE_P(TabDragging, 1372 INSTANTIATE_TEST_CASE_P(TabDragging,
1373 DifferentDeviceScaleFactorDisplayTabDragControllerTest,
1374 ::testing::Values("mouse"));
1375 INSTANTIATE_TEST_CASE_P(TabDragging,
1274 DetachToBrowserTabDragControllerTest, 1376 DetachToBrowserTabDragControllerTest,
1275 ::testing::Values("mouse", "touch")); 1377 ::testing::Values("mouse", "touch"));
1276 #else 1378 #else
1277 INSTANTIATE_TEST_CASE_P(TabDragging, 1379 INSTANTIATE_TEST_CASE_P(TabDragging,
1278 DetachToBrowserTabDragControllerTest, 1380 DetachToBrowserTabDragControllerTest,
1279 ::testing::Values("mouse")); 1381 ::testing::Values("mouse"));
1280 #endif 1382 #endif
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698