| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 float touch_radius_x_; | 345 float touch_radius_x_; |
| 346 float touch_radius_y_; | 346 float touch_radius_y_; |
| 347 float scroll_x_offset_; | 347 float scroll_x_offset_; |
| 348 float scroll_y_offset_; | 348 float scroll_y_offset_; |
| 349 float scroll_x_offset_ordinal_; | 349 float scroll_x_offset_ordinal_; |
| 350 float scroll_y_offset_ordinal_; | 350 float scroll_y_offset_ordinal_; |
| 351 | 351 |
| 352 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 352 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
| 353 }; | 353 }; |
| 354 | 354 |
| 355 gfx::Display::Rotation GetStoredRotation(int64 id) { |
| 356 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation(); |
| 357 } |
| 358 |
| 355 float GetStoredUIScale(int64 id) { | 359 float GetStoredUIScale(int64 id) { |
| 356 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). | 360 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). |
| 357 GetEffectiveUIScale(); | 361 GetEffectiveUIScale(); |
| 358 } | 362 } |
| 359 | 363 |
| 360 #if defined(USE_X11) | 364 #if defined(USE_X11) |
| 361 void GetPrimaryAndSeconary(aura::Window** primary, | 365 void GetPrimaryAndSeconary(aura::Window** primary, |
| 362 aura::Window** secondary) { | 366 aura::Window** secondary) { |
| 363 *primary = Shell::GetPrimaryRootWindow(); | 367 *primary = Shell::GetPrimaryRootWindow(); |
| 364 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 368 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); | 550 EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); |
| 547 } | 551 } |
| 548 | 552 |
| 549 namespace { | 553 namespace { |
| 550 | 554 |
| 551 DisplayInfo CreateDisplayInfo(int64 id, | 555 DisplayInfo CreateDisplayInfo(int64 id, |
| 552 int y, | 556 int y, |
| 553 gfx::Display::Rotation rotation) { | 557 gfx::Display::Rotation rotation) { |
| 554 DisplayInfo info(id, "", false); | 558 DisplayInfo info(id, "", false); |
| 555 info.SetBounds(gfx::Rect(0, y, 500, 500)); | 559 info.SetBounds(gfx::Rect(0, y, 500, 500)); |
| 556 info.SetRotation(rotation, gfx::Display::ROTATION_SOURCE_ACTIVE); | 560 info.set_rotation(rotation); |
| 557 return info; | 561 return info; |
| 558 } | 562 } |
| 559 | 563 |
| 560 DisplayInfo CreateMirroredDisplayInfo(int64 id, | 564 DisplayInfo CreateMirroredDisplayInfo(int64 id, |
| 561 float device_scale_factor) { | 565 float device_scale_factor) { |
| 562 DisplayInfo info = CreateDisplayInfo(id, 0, gfx::Display::ROTATE_0); | 566 DisplayInfo info = CreateDisplayInfo(id, 0, gfx::Display::ROTATE_0); |
| 563 info.set_device_scale_factor(device_scale_factor); | 567 info.set_device_scale_factor(device_scale_factor); |
| 564 return info; | 568 return info; |
| 565 } | 569 } |
| 566 | 570 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 // No change | 679 // No change |
| 676 UpdateDisplay("400x500*2,300x300"); | 680 UpdateDisplay("400x500*2,300x300"); |
| 677 // We still call into Pre/PostDisplayConfigurationChange(). | 681 // We still call into Pre/PostDisplayConfigurationChange(). |
| 678 EXPECT_EQ(1, observer.CountAndReset()); | 682 EXPECT_EQ(1, observer.CountAndReset()); |
| 679 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 683 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 680 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 684 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 681 | 685 |
| 682 // Rotation | 686 // Rotation |
| 683 observer.GetRotationChangedCountAndReset(); // we only want to reset. | 687 observer.GetRotationChangedCountAndReset(); // we only want to reset. |
| 684 int64 primary_id = GetPrimaryDisplay().id(); | 688 int64 primary_id = GetPrimaryDisplay().id(); |
| 685 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, | 689 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); |
| 686 gfx::Display::ROTATION_SOURCE_ACTIVE); | |
| 687 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 690 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 688 EXPECT_EQ(1, observer.CountAndReset()); | 691 EXPECT_EQ(1, observer.CountAndReset()); |
| 689 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 692 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 690 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 693 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 691 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90, | 694 display_manager->SetDisplayRotation(primary_id, gfx::Display::ROTATE_90); |
| 692 gfx::Display::ROTATION_SOURCE_ACTIVE); | |
| 693 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); | 695 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); |
| 694 EXPECT_EQ(0, observer.CountAndReset()); | 696 EXPECT_EQ(0, observer.CountAndReset()); |
| 695 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); | 697 EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); |
| 696 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); | 698 EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); |
| 697 | 699 |
| 698 // UI scale is eanbled only on internal display. | 700 // UI scale is eanbled only on internal display. |
| 699 int64 secondary_id = GetSecondaryDisplay().id(); | 701 int64 secondary_id = GetSecondaryDisplay().id(); |
| 700 test::DisplayManagerTestApi(display_manager) | 702 test::DisplayManagerTestApi(display_manager) |
| 701 .SetInternalDisplayId(secondary_id); | 703 .SetInternalDisplayId(secondary_id); |
| 702 | 704 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1039 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1038 ui::test::EventGenerator generator1(root_windows[0]); | 1040 ui::test::EventGenerator generator1(root_windows[0]); |
| 1039 | 1041 |
| 1040 TestObserver observer; | 1042 TestObserver observer; |
| 1041 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1043 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
| 1042 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1044 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
| 1043 EXPECT_EQ("120,0 150x200", | 1045 EXPECT_EQ("120,0 150x200", |
| 1044 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1046 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1045 generator1.MoveMouseToInHost(50, 40); | 1047 generator1.MoveMouseToInHost(50, 40); |
| 1046 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); | 1048 EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); |
| 1047 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); | 1049 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); |
| 1048 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); | 1050 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
| 1049 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); | 1051 EXPECT_EQ(0, observer.GetRotationChangedCountAndReset()); |
| 1050 | 1052 |
| 1051 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, | 1053 display_manager->SetDisplayRotation(display1.id(), |
| 1052 gfx::Display::ROTATION_SOURCE_ACTIVE); | 1054 gfx::Display::ROTATE_90); |
| 1053 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1055 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
| 1054 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); | 1056 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); |
| 1055 EXPECT_EQ("200,0 150x200", | 1057 EXPECT_EQ("200,0 150x200", |
| 1056 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1058 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1057 generator1.MoveMouseToInHost(50, 40); | 1059 generator1.MoveMouseToInHost(50, 40); |
| 1058 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); | 1060 EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); |
| 1059 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); | 1061 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
| 1060 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); | 1062 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); |
| 1061 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1063 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1062 | 1064 |
| 1063 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); | 1065 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); |
| 1064 display_manager->SetLayoutForCurrentDisplays(display_layout); | 1066 display_manager->SetLayoutForCurrentDisplays(display_layout); |
| 1065 EXPECT_EQ("50,120 150x200", | 1067 EXPECT_EQ("50,120 150x200", |
| 1066 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1068 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1067 | 1069 |
| 1068 display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, | 1070 display_manager->SetDisplayRotation(display2_id, |
| 1069 gfx::Display::ROTATION_SOURCE_ACTIVE); | 1071 gfx::Display::ROTATE_270); |
| 1070 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); | 1072 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); |
| 1071 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1073 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 1072 EXPECT_EQ("50,120 200x150", | 1074 EXPECT_EQ("50,120 200x150", |
| 1073 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1075 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1074 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); | 1076 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); |
| 1075 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); | 1077 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
| 1076 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1078 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1077 | 1079 |
| 1078 #if !defined(OS_WIN) | 1080 #if !defined(OS_WIN) |
| 1079 ui::test::EventGenerator generator2(root_windows[1]); | 1081 ui::test::EventGenerator generator2(root_windows[1]); |
| 1080 generator2.MoveMouseToInHost(50, 40); | 1082 generator2.MoveMouseToInHost(50, 40); |
| 1081 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); | 1083 EXPECT_EQ("179,25", event_handler.GetLocationAndReset()); |
| 1082 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, | 1084 display_manager->SetDisplayRotation(display1.id(), |
| 1083 gfx::Display::ROTATION_SOURCE_ACTIVE); | 1085 gfx::Display::ROTATE_180); |
| 1084 | 1086 |
| 1085 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); | 1087 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); |
| 1086 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); | 1088 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); |
| 1087 // Dislay must share at least 100, so the x's offset becomes 20. | 1089 // Dislay must share at least 100, so the x's offset becomes 20. |
| 1088 EXPECT_EQ("20,200 200x150", | 1090 EXPECT_EQ("20,200 200x150", |
| 1089 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); | 1091 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
| 1090 EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); | 1092 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); |
| 1091 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); | 1093 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); |
| 1092 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); | 1094 EXPECT_EQ(1, observer.GetRotationChangedCountAndReset()); |
| 1093 | 1095 |
| 1094 generator1.MoveMouseToInHost(50, 40); | 1096 generator1.MoveMouseToInHost(50, 40); |
| 1095 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); | 1097 EXPECT_EQ("69,159", event_handler.GetLocationAndReset()); |
| 1096 #endif | 1098 #endif |
| 1097 | 1099 |
| 1098 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 1100 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 1099 } | 1101 } |
| 1100 | 1102 |
| 1101 TEST_F(DisplayControllerTest, ScaleRootWindow) { | 1103 TEST_F(DisplayControllerTest, ScaleRootWindow) { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 widget->GetNativeWindow()->GetRootWindow()); | 1501 widget->GetNativeWindow()->GetRootWindow()); |
| 1500 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); | 1502 event_generator.MoveMouseToCenterOf(widget->GetNativeWindow()); |
| 1501 | 1503 |
| 1502 UpdateDisplay("300x300"); | 1504 UpdateDisplay("300x300"); |
| 1503 watcher.Stop(); | 1505 watcher.Stop(); |
| 1504 | 1506 |
| 1505 widget->CloseNow(); | 1507 widget->CloseNow(); |
| 1506 } | 1508 } |
| 1507 | 1509 |
| 1508 } // namespace ash | 1510 } // namespace ash |
| OLD | NEW |