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