| OLD | NEW |
| 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/display/display_controller.h" | 5 #include "ash/display/display_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_info.h" | 8 #include "ash/display/display_info.h" |
| 9 #include "ash/display/display_layout_store.h" | 9 #include "ash/display/display_layout_store.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 float touch_radius_x_; | 339 float touch_radius_x_; |
| 340 float touch_radius_y_; | 340 float touch_radius_y_; |
| 341 float scroll_x_offset_; | 341 float scroll_x_offset_; |
| 342 float scroll_y_offset_; | 342 float scroll_y_offset_; |
| 343 float scroll_x_offset_ordinal_; | 343 float scroll_x_offset_ordinal_; |
| 344 float scroll_y_offset_ordinal_; | 344 float scroll_y_offset_ordinal_; |
| 345 | 345 |
| 346 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 346 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
| 347 }; | 347 }; |
| 348 | 348 |
| 349 gfx::Display::Rotation GetStoredRotation(int64 id) { | |
| 350 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); | |
| 351 } | |
| 352 | |
| 353 float GetStoredUIScale(int64 id) { | 349 float GetStoredUIScale(int64 id) { |
| 354 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). | 350 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). |
| 355 GetEffectiveUIScale(); | 351 GetEffectiveUIScale(); |
| 356 } | 352 } |
| 357 | 353 |
| 358 class TestMouseWatcherListener : public views::MouseWatcherListener { | 354 class TestMouseWatcherListener : public views::MouseWatcherListener { |
| 359 public: | 355 public: |
| 360 TestMouseWatcherListener() {} | 356 TestMouseWatcherListener() {} |
| 361 | 357 |
| 362 private: | 358 private: |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); | 523 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); |
| 528 } | 524 } |
| 529 | 525 |
| 530 namespace { | 526 namespace { |
| 531 | 527 |
| 532 DisplayInfo CreateDisplayInfo(int64 id, | 528 DisplayInfo CreateDisplayInfo(int64 id, |
| 533 int y, | 529 int y, |
| 534 gfx::Display::Rotation rotation) { | 530 gfx::Display::Rotation rotation) { |
| 535 DisplayInfo info(id, "", false); | 531 DisplayInfo info(id, "", false); |
| 536 info.SetBounds(gfx::Rect(0, y, 500, 500)); | 532 info.SetBounds(gfx::Rect(0, y, 500, 500)); |
| 537 info.set_rotation(rotation); | 533 info.SetRotation(rotation, gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 538 return info; | 534 return info; |
| 539 } | 535 } |
| 540 | 536 |
| 541 DisplayInfo CreateMirroredDisplayInfo(int64 id, | 537 DisplayInfo CreateMirroredDisplayInfo(int64 id, |
| 542 float device_scale_factor) { | 538 float device_scale_factor) { |
| 543 DisplayInfo info = CreateDisplayInfo(id, 0, gfx::Display::ROTATE_0); | 539 DisplayInfo info = CreateDisplayInfo(id, 0, gfx::Display::ROTATE_0); |
| 544 info.set_device_scale_factor(device_scale_factor); | 540 info.set_device_scale_factor(device_scale_factor); |
| 545 return info; | 541 return info; |
| 546 } | 542 } |
| 547 | 543 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 // No change | 652 // No change |
| 657 UpdateDisplay("400x500*2,300x300"); | 653 UpdateDisplay("400x500*2,300x300"); |
| 658 // We still call into Pre/PostDisplayConfigurationChange(). | 654 // We still call into Pre/PostDisplayConfigurationChange(). |
| 659 EXPECT_EQ(1, observer.CountAndReset()); | 655 EXPECT_EQ(1, observer.CountAndReset()); |
| 660 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 656 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 661 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 657 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 662 | 658 |
| 663 // Rotation | 659 // Rotation |
| 664 observer.GetRotationChangedCountAndReset(); // we only want to reset. | 660 observer.GetRotationChangedCountAndReset(); // we only want to reset. |
| 665 int64 primary_id = GetPrimaryDisplay().id(); | 661 int64 primary_id = GetPrimaryDisplay().id(); |
| 666 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); | 662 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, |
| 663 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 667 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 664 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 668 EXPECT_EQ(1, observer.CountAndReset()); | 665 EXPECT_EQ(1, observer.CountAndReset()); |
| 669 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 666 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 670 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 667 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 671 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); | 668 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, |
| 669 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 672 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); | 670 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); |
| 673 EXPECT_EQ(0, observer.CountAndReset()); | 671 EXPECT_EQ(0, observer.CountAndReset()); |
| 674 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 672 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 675 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 673 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 676 | 674 |
| 677 // UI scale is eanbled only on internal display. | 675 // UI scale is eanbled only on internal display. |
| 678 int64 secondary_id = GetSecondaryDisplay().id(); | 676 int64 secondary_id = GetSecondaryDisplay().id(); |
| 679 test::DisplayManagerTestApi(display_manager) | 677 test::DisplayManagerTestApi(display_manager) |
| 680 .SetInternalDisplayId(secondary_id); | 678 .SetInternalDisplayId(secondary_id); |
| 681 | 679 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1014 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1017 ui::test::EventGenerator generator1(root_windows[0]); | 1015 ui::test::EventGenerator generator1(root_windows[0]); |
| 1018 | 1016 |
| 1019 TestObserver observer; | 1017 TestObserver observer; |
| 1020 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1018 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
| 1021 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1019 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
| 1022 EXPECT_EQ("120,0 150x200", | 1020 EXPECT_EQ("120,0 150x200", |
| 1023 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1021 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1024 generator1.MoveMouseToInHost(50, 40); | 1022 generator1.MoveMouseToInHost(50, 40); |
| 1025 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); | 1023 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); |
| 1026 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); | 1024 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); |
| 1027 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 1025 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); |
| 1028 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); | 1026 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); |
| 1029 | 1027 |
| 1030 display_manager->SetDisplayRotation(display1.id(), | 1028 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, |
| 1031 gfx::Display::ROTATE_90); | 1029 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 1032 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1030 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
| 1033 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1031 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
| 1034 EXPECT_EQ("200,0 150x200", | 1032 EXPECT_EQ("200,0 150x200", |
| 1035 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1033 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1036 generator1.MoveMouseToInHost(50, 40); | 1034 generator1.MoveMouseToInHost(50, 40); |
| 1037 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); | 1035 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); |
| 1038 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 1036 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); |
| 1039 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); | 1037 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); |
| 1040 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1038 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1041 | 1039 |
| 1042 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); | 1040 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); |
| 1043 display_manager->SetLayoutForCurrentDisplays(display_layout); | 1041 display_manager->SetLayoutForCurrentDisplays(display_layout); |
| 1044 EXPECT_EQ("50,120 150x200", | 1042 EXPECT_EQ("50,120 150x200", |
| 1045 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1043 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1046 | 1044 |
| 1047 display_manager->SetDisplayRotation(display2_id, | 1045 display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, |
| 1048 gfx::Display::ROTATE_270); | 1046 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 1049 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1047 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
| 1050 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1048 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 1051 EXPECT_EQ("50,120 200x150", | 1049 EXPECT_EQ("50,120 200x150", |
| 1052 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1050 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1053 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); | 1051 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); |
| 1054 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 1052 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); |
| 1055 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1053 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1056 | 1054 |
| 1057 #if !defined(OS_WIN) | 1055 #if !defined(OS_WIN) |
| 1058 ui::test::EventGenerator generator2(root_windows[1]); | 1056 ui::test::EventGenerator generator2(root_windows[1]); |
| 1059 generator2.MoveMouseToInHost(50, 40); | 1057 generator2.MoveMouseToInHost(50, 40); |
| 1060 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); | 1058 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); |
| 1061 display_manager->SetDisplayRotation(display1.id(), | 1059 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, |
| 1062 gfx::Display::ROTATE_180); | 1060 gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 1063 | 1061 |
| 1064 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1062 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
| 1065 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1063 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 1066 // Dislay must share at least 100, so the x's offset becomes 20. | 1064 // Dislay must share at least 100, so the x's offset becomes 20. |
| 1067 EXPECT_EQ("20,200 200x150", | 1065 EXPECT_EQ("20,200 200x150", |
| 1068 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1066 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1069 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); | 1067 EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); |
| 1070 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); | 1068 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); |
| 1071 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1069 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1072 | 1070 |
| 1073 generator1.MoveMouseToInHost(50, 40); | 1071 generator1.MoveMouseToInHost(50, 40); |
| 1074 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); | 1072 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); |
| 1075 #endif | 1073 #endif |
| 1076 | 1074 |
| 1077 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1075 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1078 } | 1076 } |
| 1079 | 1077 |
| 1080 TEST_F(DisplayControllerTest, ScaleRootWindow) { | 1078 TEST_F(DisplayControllerTest, ScaleRootWindow) { |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 widget->GetNativeWindow()->GetRootWindow()); | 1450 widget->GetNativeWindow()->GetRootWindow()); |
| 1453 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); | 1451 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); |
| 1454 | 1452 |
| 1455 UpdateDisplay("300x300"); | 1453 UpdateDisplay("300x300"); |
| 1456 watcher.Stop(); | 1454 watcher.Stop(); |
| 1457 | 1455 |
| 1458 widget->CloseNow(); | 1456 widget->CloseNow(); |
| 1459 } | 1457 } |
| 1460 | 1458 |
| 1461 } // namespace ash | 1459 } // namespace ash |
| OLD | NEW |