| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/display/extended_mouse_warp_controller.h" | 5 #include "ash/display/extended_mouse_warp_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/display_layout_builder.h" | |
| 8 #include "ash/display/display_layout_store.h" | 7 #include "ash/display/display_layout_store.h" |
| 9 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/mouse_cursor_event_filter.h" | 9 #include "ash/display/mouse_cursor_event_filter.h" |
| 11 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/test/display_manager_test_api.h" | 12 #include "ash/test/display_manager_test_api.h" |
| 13 #include "ui/display/manager/display_layout.h" |
| 14 #include "ui/display/manager/display_layout_builder.h" |
| 14 #include "ui/events/test/event_generator.h" | 15 #include "ui/events/test/event_generator.h" |
| 15 #include "ui/gfx/display.h" | 16 #include "ui/gfx/display.h" |
| 16 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 | 20 |
| 20 class ExtendedMouseWarpControllerTest : public test::AshTestBase { | 21 class ExtendedMouseWarpControllerTest : public test::AshTestBase { |
| 21 public: | 22 public: |
| 22 ExtendedMouseWarpControllerTest() {} | 23 ExtendedMouseWarpControllerTest() {} |
| 23 ~ExtendedMouseWarpControllerTest() override {} | 24 ~ExtendedMouseWarpControllerTest() override {} |
| (...skipping 30 matching lines...) Expand all Loading... |
| 54 return; | 55 return; |
| 55 | 56 |
| 56 UpdateDisplay("360x360,700x700"); | 57 UpdateDisplay("360x360,700x700"); |
| 57 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 58 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 58 int64_t display_0_id = | 59 int64_t display_0_id = |
| 59 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[0]).id(); | 60 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[0]).id(); |
| 60 int64_t display_1_id = | 61 int64_t display_1_id = |
| 61 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]).id(); | 62 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]).id(); |
| 62 | 63 |
| 63 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 64 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 64 scoped_ptr<DisplayLayout> layout( | 65 scoped_ptr<display::DisplayLayout> layout( |
| 65 test::CreateDisplayLayout(DisplayPlacement::RIGHT, 0)); | 66 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0)); |
| 66 | 67 |
| 67 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); | 68 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); |
| 68 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 69 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
| 69 | 70 |
| 70 ASSERT_EQ(1U, GetWarpRegionsCount()); | 71 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 71 EXPECT_EQ(gfx::Rect(359, 16, 1, 344), GetIndicatorBounds(display_0_id)); | 72 EXPECT_EQ(gfx::Rect(359, 16, 1, 344), GetIndicatorBounds(display_0_id)); |
| 72 EXPECT_EQ(gfx::Rect(360, 0, 1, 360), GetIndicatorBounds(display_1_id)); | 73 EXPECT_EQ(gfx::Rect(360, 0, 1, 360), GetIndicatorBounds(display_1_id)); |
| 73 | 74 |
| 74 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 75 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
| 75 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id)); | 76 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 127 |
| 127 UpdateDisplay("360x360,700x700"); | 128 UpdateDisplay("360x360,700x700"); |
| 128 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 129 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 129 | 130 |
| 130 int64_t display_0_id = | 131 int64_t display_0_id = |
| 131 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[0]).id(); | 132 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[0]).id(); |
| 132 int64_t display_1_id = | 133 int64_t display_1_id = |
| 133 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]).id(); | 134 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]).id(); |
| 134 | 135 |
| 135 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 136 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 136 scoped_ptr<DisplayLayout> layout( | 137 scoped_ptr<display::DisplayLayout> layout( |
| 137 test::CreateDisplayLayout(DisplayPlacement::LEFT, 0)); | 138 test::CreateDisplayLayout(display::DisplayPlacement::LEFT, 0)); |
| 138 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); | 139 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); |
| 139 | 140 |
| 140 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 141 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
| 141 ASSERT_EQ(1U, GetWarpRegionsCount()); | 142 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 142 EXPECT_EQ(gfx::Rect(0, 16, 1, 344), GetIndicatorBounds(display_0_id)); | 143 EXPECT_EQ(gfx::Rect(0, 16, 1, 344), GetIndicatorBounds(display_0_id)); |
| 143 EXPECT_EQ(gfx::Rect(-1, 0, 1, 360), GetIndicatorBounds(display_1_id)); | 144 EXPECT_EQ(gfx::Rect(-1, 0, 1, 360), GetIndicatorBounds(display_1_id)); |
| 144 | 145 |
| 145 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 146 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
| 146 ASSERT_EQ(1U, GetWarpRegionsCount()); | 147 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 147 EXPECT_EQ(gfx::Rect(0, 0, 1, 360), GetIndicatorBounds(display_0_id)); | 148 EXPECT_EQ(gfx::Rect(0, 0, 1, 360), GetIndicatorBounds(display_0_id)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 167 return; | 168 return; |
| 168 | 169 |
| 169 UpdateDisplay("360x360,700x700"); | 170 UpdateDisplay("360x360,700x700"); |
| 170 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 171 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 171 int64_t display_0_id = | 172 int64_t display_0_id = |
| 172 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[0]).id(); | 173 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[0]).id(); |
| 173 int64_t display_1_id = | 174 int64_t display_1_id = |
| 174 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]).id(); | 175 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]).id(); |
| 175 | 176 |
| 176 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 177 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 177 scoped_ptr<DisplayLayout> layout( | 178 scoped_ptr<display::DisplayLayout> layout( |
| 178 test::CreateDisplayLayout(DisplayPlacement::TOP, 0)); | 179 test::CreateDisplayLayout(display::DisplayPlacement::TOP, 0)); |
| 179 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); | 180 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); |
| 180 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 181 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
| 181 ASSERT_EQ(1U, GetWarpRegionsCount()); | 182 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 182 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); | 183 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); |
| 183 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); | 184 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); |
| 184 | 185 |
| 185 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 186 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
| 186 ASSERT_EQ(1U, GetWarpRegionsCount()); | 187 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 187 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); | 188 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); |
| 188 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); | 189 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); |
| 189 | 190 |
| 190 layout->placement_list[0].offset = 250; | 191 layout->placement_list[0].offset = 250; |
| 191 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); | 192 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); |
| 192 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 193 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
| 193 ASSERT_EQ(1U, GetWarpRegionsCount()); | 194 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 194 EXPECT_EQ(gfx::Rect(250, 0, 110, 1), GetIndicatorBounds(display_0_id)); | 195 EXPECT_EQ(gfx::Rect(250, 0, 110, 1), GetIndicatorBounds(display_0_id)); |
| 195 EXPECT_EQ(gfx::Rect(250, -1, 110, 1), GetIndicatorBounds(display_1_id)); | 196 EXPECT_EQ(gfx::Rect(250, -1, 110, 1), GetIndicatorBounds(display_1_id)); |
| 196 | 197 |
| 197 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 198 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
| 198 ASSERT_EQ(1U, GetWarpRegionsCount()); | 199 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 199 EXPECT_EQ(gfx::Rect(250, 0, 110, 1), GetIndicatorBounds(display_0_id)); | 200 EXPECT_EQ(gfx::Rect(250, 0, 110, 1), GetIndicatorBounds(display_0_id)); |
| 200 EXPECT_EQ(gfx::Rect(250, -1, 110, 1), GetIndicatorBounds(display_1_id)); | 201 EXPECT_EQ(gfx::Rect(250, -1, 110, 1), GetIndicatorBounds(display_1_id)); |
| 201 | 202 |
| 202 layout->placement_list[0].position = DisplayPlacement::BOTTOM; | 203 layout->placement_list[0].position = display::DisplayPlacement::BOTTOM; |
| 203 layout->placement_list[0].offset = 0; | 204 layout->placement_list[0].offset = 0; |
| 204 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); | 205 display_manager->SetLayoutForCurrentDisplays(layout->Copy()); |
| 205 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 206 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
| 206 ASSERT_EQ(1U, GetWarpRegionsCount()); | 207 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 207 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id)); | 208 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id)); |
| 208 EXPECT_EQ(gfx::Rect(0, 360, 360, 1), GetIndicatorBounds(display_1_id)); | 209 EXPECT_EQ(gfx::Rect(0, 360, 360, 1), GetIndicatorBounds(display_1_id)); |
| 209 | 210 |
| 210 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 211 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
| 211 ASSERT_EQ(1U, GetWarpRegionsCount()); | 212 ASSERT_EQ(1U, GetWarpRegionsCount()); |
| 212 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id)); | 213 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id(); | 283 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id(); |
| 283 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id(); | 284 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id(); |
| 284 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id(); | 285 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id(); |
| 285 | 286 |
| 286 // Layout so that all displays touches togter like this: | 287 // Layout so that all displays touches togter like this: |
| 287 // +-----+---+ | 288 // +-----+---+ |
| 288 // | 0 | 1 | | 289 // | 0 | 1 | |
| 289 // +-+---+--++ | 290 // +-+---+--++ |
| 290 // | 2 | | 291 // | 2 | |
| 291 // +------+ | 292 // +------+ |
| 292 ash::DisplayLayoutBuilder builder(display_0_id); | 293 display::DisplayLayoutBuilder builder(display_0_id); |
| 293 builder.AddDisplayPlacement(display_1_id, display_0_id, | 294 builder.AddDisplayPlacement(display_1_id, display_0_id, |
| 294 ash::DisplayPlacement::RIGHT, 0); | 295 display::DisplayPlacement::RIGHT, 0); |
| 295 builder.AddDisplayPlacement(display_2_id, display_0_id, | 296 builder.AddDisplayPlacement(display_2_id, display_0_id, |
| 296 ash::DisplayPlacement::BOTTOM, 100); | 297 display::DisplayPlacement::BOTTOM, 100); |
| 297 | 298 |
| 298 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 299 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 299 display_manager->SetLayoutForCurrentDisplays(builder.Build()); | 300 display_manager->SetLayoutForCurrentDisplays(builder.Build()); |
| 300 ASSERT_EQ(3U, GetWarpRegionsCount()); | 301 ASSERT_EQ(3U, GetWarpRegionsCount()); |
| 301 | 302 |
| 302 // Drag from 0. | 303 // Drag from 0. |
| 303 event_filter()->ShowSharedEdgeIndicator(root_windows[0]); | 304 event_filter()->ShowSharedEdgeIndicator(root_windows[0]); |
| 304 ASSERT_EQ(3U, GetWarpRegionsCount()); | 305 ASSERT_EQ(3U, GetWarpRegionsCount()); |
| 305 const ExtendedMouseWarpController::WarpRegion* region_0 = GetWarpRegion(0); | 306 const ExtendedMouseWarpController::WarpRegion* region_0 = GetWarpRegion(0); |
| 306 const ExtendedMouseWarpController::WarpRegion* region_1 = GetWarpRegion(1); | 307 const ExtendedMouseWarpController::WarpRegion* region_1 = GetWarpRegion(1); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 333 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id(); | 334 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id(); |
| 334 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id(); | 335 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id(); |
| 335 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id(); | 336 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id(); |
| 336 | 337 |
| 337 // Layout so that 0 and 1 displays are disconnected. | 338 // Layout so that 0 and 1 displays are disconnected. |
| 338 // +-----+ +---+ | 339 // +-----+ +---+ |
| 339 // | 0 | |1 | | 340 // | 0 | |1 | |
| 340 // +-+---+-+++ | 341 // +-+---+-+++ |
| 341 // | 2 | | 342 // | 2 | |
| 342 // +------+ | 343 // +------+ |
| 343 ash::DisplayLayoutBuilder builder(display_0_id); | 344 display::DisplayLayoutBuilder builder(display_0_id); |
| 344 builder.AddDisplayPlacement(display_2_id, display_0_id, | 345 builder.AddDisplayPlacement(display_2_id, display_0_id, |
| 345 ash::DisplayPlacement::BOTTOM, 100); | 346 display::DisplayPlacement::BOTTOM, 100); |
| 346 builder.AddDisplayPlacement(display_1_id, display_2_id, | 347 builder.AddDisplayPlacement(display_1_id, display_2_id, |
| 347 ash::DisplayPlacement::TOP, 800); | 348 display::DisplayPlacement::TOP, 800); |
| 348 | 349 |
| 349 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 350 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 350 display_manager->SetLayoutForCurrentDisplays(builder.Build()); | 351 display_manager->SetLayoutForCurrentDisplays(builder.Build()); |
| 351 ASSERT_EQ(2U, GetWarpRegionsCount()); | 352 ASSERT_EQ(2U, GetWarpRegionsCount()); |
| 352 | 353 |
| 353 // Drag from 0. | 354 // Drag from 0. |
| 354 event_filter()->ShowSharedEdgeIndicator(root_windows[0]); | 355 event_filter()->ShowSharedEdgeIndicator(root_windows[0]); |
| 355 ASSERT_EQ(2U, GetWarpRegionsCount()); | 356 ASSERT_EQ(2U, GetWarpRegionsCount()); |
| 356 const ExtendedMouseWarpController::WarpRegion* region_0 = GetWarpRegion(0); | 357 const ExtendedMouseWarpController::WarpRegion* region_0 = GetWarpRegion(0); |
| 357 const ExtendedMouseWarpController::WarpRegion* region_1 = GetWarpRegion(1); | 358 const ExtendedMouseWarpController::WarpRegion* region_1 = GetWarpRegion(1); |
| 358 // between 2 and 0 | 359 // between 2 and 0 |
| 359 EXPECT_EQ(gfx::Rect(100, 499, 600, 1), | 360 EXPECT_EQ(gfx::Rect(100, 499, 600, 1), |
| 360 region_0->GetIndicatorBoundsForTest(display_0_id)); | 361 region_0->GetIndicatorBoundsForTest(display_0_id)); |
| 361 EXPECT_EQ(gfx::Rect(100, 500, 600, 1), | 362 EXPECT_EQ(gfx::Rect(100, 500, 600, 1), |
| 362 region_0->GetIndicatorBoundsForTest(display_2_id)); | 363 region_0->GetIndicatorBoundsForTest(display_2_id)); |
| 363 // between 2 and 1 | 364 // between 2 and 1 |
| 364 EXPECT_EQ(gfx::Rect(900, 499, 200, 1), | 365 EXPECT_EQ(gfx::Rect(900, 499, 200, 1), |
| 365 region_1->GetIndicatorBoundsForTest(display_1_id)); | 366 region_1->GetIndicatorBoundsForTest(display_1_id)); |
| 366 EXPECT_EQ(gfx::Rect(900, 500, 200, 1), | 367 EXPECT_EQ(gfx::Rect(900, 500, 200, 1), |
| 367 region_1->GetIndicatorBoundsForTest(display_2_id)); | 368 region_1->GetIndicatorBoundsForTest(display_2_id)); |
| 368 event_filter()->HideSharedEdgeIndicator(); | 369 event_filter()->HideSharedEdgeIndicator(); |
| 369 } | 370 } |
| 370 | 371 |
| 371 } // namespace ash | 372 } // namespace ash |
| OLD | NEW |