OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/screen_orientation_controller_chromeos.h" | 5 #include "ash/display/screen_orientation_controller_chromeos.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
11 #include "ash/common/display/display_info.h" | |
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
13 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
14 #include "ash/content/shell_content_state.h" | 13 #include "ash/content/shell_content_state.h" |
15 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
16 #include "ash/shell.h" | 15 #include "ash/shell.h" |
17 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
18 #include "ash/test/ash_test_helper.h" | 17 #include "ash/test/ash_test_helper.h" |
19 #include "ash/test/content/test_shell_content_state.h" | 18 #include "ash/test/content/test_shell_content_state.h" |
20 #include "ash/test/display_manager_test_api.h" | 19 #include "ash/test/display_manager_test_api.h" |
21 #include "ash/test/test_shell_delegate.h" | 20 #include "ash/test/test_shell_delegate.h" |
22 #include "ash/test/test_system_tray_delegate.h" | 21 #include "ash/test/test_system_tray_delegate.h" |
23 #include "base/command_line.h" | 22 #include "base/command_line.h" |
24 #include "chromeos/accelerometer/accelerometer_reader.h" | 23 #include "chromeos/accelerometer/accelerometer_reader.h" |
25 #include "chromeos/accelerometer/accelerometer_types.h" | 24 #include "chromeos/accelerometer/accelerometer_types.h" |
26 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
28 #include "content/public/test/test_browser_context.h" | 27 #include "content/public/test/test_browser_context.h" |
29 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" | 28 #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScree
nOrientationLockType.h" |
30 #include "ui/aura/window.h" | 29 #include "ui/aura/window.h" |
31 #include "ui/display/display.h" | 30 #include "ui/display/display.h" |
| 31 #include "ui/display/manager/managed_display_info.h" |
32 #include "ui/message_center/message_center.h" | 32 #include "ui/message_center/message_center.h" |
33 #include "ui/views/test/webview_test_helper.h" | 33 #include "ui/views/test/webview_test_helper.h" |
34 #include "ui/views/view.h" | 34 #include "ui/views/view.h" |
35 #include "ui/views/views_delegate.h" | 35 #include "ui/views/views_delegate.h" |
36 #include "ui/wm/public/activation_client.h" | 36 #include "ui/wm/public/activation_client.h" |
37 | 37 |
38 namespace ash { | 38 namespace ash { |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 const float kDegreesToRadians = 3.1415926f / 180.0f; | 42 const float kDegreesToRadians = 3.1415926f / 180.0f; |
43 const float kMeanGravity = -9.8066f; | 43 const float kMeanGravity = -9.8066f; |
44 | 44 |
45 DisplayInfo CreateDisplayInfo(int64_t id, const gfx::Rect& bounds) { | 45 display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, |
46 DisplayInfo info(id, "dummy", false); | 46 const gfx::Rect& bounds) { |
| 47 display::ManagedDisplayInfo info(id, "dummy", false); |
47 info.SetBounds(bounds); | 48 info.SetBounds(bounds); |
48 return info; | 49 return info; |
49 } | 50 } |
50 | 51 |
51 void EnableMaximizeMode(bool enable) { | 52 void EnableMaximizeMode(bool enable) { |
52 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 53 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
53 enable); | 54 enable); |
54 } | 55 } |
55 | 56 |
56 bool RotationLocked() { | 57 bool RotationLocked() { |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 SetInternalDisplayRotation(display::Display::ROTATE_90); | 617 SetInternalDisplayRotation(display::Display::ROTATE_90); |
617 EXPECT_TRUE(RotationLocked()); | 618 EXPECT_TRUE(RotationLocked()); |
618 } | 619 } |
619 | 620 |
620 // Verifies rotating an inactive Display is successful. | 621 // Verifies rotating an inactive Display is successful. |
621 TEST_F(ScreenOrientationControllerTest, RotateInactiveDisplay) { | 622 TEST_F(ScreenOrientationControllerTest, RotateInactiveDisplay) { |
622 const int64_t kInternalDisplayId = 9; | 623 const int64_t kInternalDisplayId = 9; |
623 const int64_t kExternalDisplayId = 10; | 624 const int64_t kExternalDisplayId = 10; |
624 const display::Display::Rotation kNewRotation = display::Display::ROTATE_180; | 625 const display::Display::Rotation kNewRotation = display::Display::ROTATE_180; |
625 | 626 |
626 const DisplayInfo internal_display_info = | 627 const display::ManagedDisplayInfo internal_display_info = |
627 CreateDisplayInfo(kInternalDisplayId, gfx::Rect(0, 0, 500, 500)); | 628 CreateDisplayInfo(kInternalDisplayId, gfx::Rect(0, 0, 500, 500)); |
628 const DisplayInfo external_display_info = | 629 const display::ManagedDisplayInfo external_display_info = |
629 CreateDisplayInfo(kExternalDisplayId, gfx::Rect(1, 1, 500, 500)); | 630 CreateDisplayInfo(kExternalDisplayId, gfx::Rect(1, 1, 500, 500)); |
630 | 631 |
631 std::vector<DisplayInfo> display_info_list_two_active; | 632 std::vector<display::ManagedDisplayInfo> display_info_list_two_active; |
632 display_info_list_two_active.push_back(internal_display_info); | 633 display_info_list_two_active.push_back(internal_display_info); |
633 display_info_list_two_active.push_back(external_display_info); | 634 display_info_list_two_active.push_back(external_display_info); |
634 | 635 |
635 std::vector<DisplayInfo> display_info_list_one_active; | 636 std::vector<display::ManagedDisplayInfo> display_info_list_one_active; |
636 display_info_list_one_active.push_back(external_display_info); | 637 display_info_list_one_active.push_back(external_display_info); |
637 | 638 |
638 // The DisplayInfo list with two active displays needs to be added first so | 639 // The display::ManagedDisplayInfo list with two active displays needs to be |
639 // that the DisplayManager can track the |internal_display_info| as inactive | 640 // added first so that the DisplayManager can track the |
640 // instead of non-existent. | 641 // |internal_display_info| as inactive instead of non-existent. |
641 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 642 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
642 display_manager->UpdateDisplaysWith(display_info_list_two_active); | 643 display_manager->UpdateDisplaysWith(display_info_list_two_active); |
643 display_manager->UpdateDisplaysWith(display_info_list_one_active); | 644 display_manager->UpdateDisplaysWith(display_info_list_one_active); |
644 | 645 |
645 test::ScopedSetInternalDisplayId set_internal(kInternalDisplayId); | 646 test::ScopedSetInternalDisplayId set_internal(kInternalDisplayId); |
646 | 647 |
647 ASSERT_NE( | 648 ASSERT_NE( |
648 kNewRotation, | 649 kNewRotation, |
649 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation()); | 650 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation()); |
650 | 651 |
651 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation( | 652 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation( |
652 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE); | 653 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE); |
653 | 654 |
654 EXPECT_EQ( | 655 EXPECT_EQ( |
655 kNewRotation, | 656 kNewRotation, |
656 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation()); | 657 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation()); |
657 } | 658 } |
658 | 659 |
659 } // namespace ash | 660 } // namespace ash |
OLD | NEW |