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 "ui/display/manager/display_manager.h" | 5 #include "ui/display/manager/display_manager.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_commands_aura.h" | 7 #include "ash/accelerators/accelerator_commands_aura.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/display/display_configuration_controller.h" | 9 #include "ash/display/display_configuration_controller.h" |
10 #include "ash/display/display_util.h" | 10 #include "ash/display/display_util.h" |
(...skipping 2913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2924 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 2924 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
2925 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2); | 2925 display::DisplayIdList list = display::test::CreateDisplayIdList2(id1, id2); |
2926 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); | 2926 layout_store->RegisterLayoutForDisplayIdList(list, std::move(old_layout)); |
2927 const display::DisplayLayout& stored = | 2927 const display::DisplayLayout& stored = |
2928 layout_store->GetRegisteredDisplayLayout(list); | 2928 layout_store->GetRegisteredDisplayLayout(list); |
2929 | 2929 |
2930 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); | 2930 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); |
2931 EXPECT_EQ(id2, stored.placement_list[0].display_id); | 2931 EXPECT_EQ(id2, stored.placement_list[0].display_id); |
2932 } | 2932 } |
2933 | 2933 |
| 2934 TEST_F(DisplayManagerTest, AccelerometerSupport) { |
| 2935 display::test::DisplayManagerTestApi(display_manager()) |
| 2936 .SetFirstDisplayAsInternalDisplay(); |
| 2937 display::Screen* screen = display::Screen::GetScreen(); |
| 2938 EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_UNAVAILABLE, |
| 2939 screen->GetPrimaryDisplay().accelerometer_support()); |
| 2940 |
| 2941 display_manager()->set_internal_display_has_accelerometer(true); |
| 2942 display_manager()->UpdateDisplays(); |
| 2943 EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_AVAILABLE, |
| 2944 screen->GetPrimaryDisplay().accelerometer_support()); |
| 2945 |
| 2946 UpdateDisplay("1000x1000,800x800"); |
| 2947 EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_AVAILABLE, |
| 2948 screen->GetPrimaryDisplay().accelerometer_support()); |
| 2949 EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_UNAVAILABLE, |
| 2950 display_manager()->GetSecondaryDisplay().accelerometer_support()); |
| 2951 |
| 2952 // Secondary is now primary and should not have accelerometer support. |
| 2953 std::vector<display::ManagedDisplayInfo> display_info_list; |
| 2954 display_info_list.push_back( |
| 2955 CreateDisplayInfo(display_manager()->GetSecondaryDisplay().id(), |
| 2956 gfx::Rect(1, 1, 100, 100))); |
| 2957 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 2958 EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_UNAVAILABLE, |
| 2959 screen->GetPrimaryDisplay().accelerometer_support()); |
| 2960 |
| 2961 // Re-enable internal display. |
| 2962 display_info_list.clear(); |
| 2963 display_info_list.push_back(CreateDisplayInfo( |
| 2964 display::Display::InternalDisplayId(), gfx::Rect(1, 1, 100, 100))); |
| 2965 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 2966 EXPECT_EQ(display::Display::ACCELEROMETER_SUPPORT_AVAILABLE, |
| 2967 screen->GetPrimaryDisplay().accelerometer_support()); |
| 2968 } |
| 2969 |
2934 namespace { | 2970 namespace { |
2935 | 2971 |
2936 class DisplayManagerOrientationTest : public DisplayManagerTest { | 2972 class DisplayManagerOrientationTest : public DisplayManagerTest { |
2937 public: | 2973 public: |
2938 DisplayManagerOrientationTest() {} | 2974 DisplayManagerOrientationTest() {} |
2939 ~DisplayManagerOrientationTest() override {} | 2975 ~DisplayManagerOrientationTest() override {} |
2940 | 2976 |
2941 void SetUp() override { | 2977 void SetUp() override { |
2942 DisplayManagerTest::SetUp(); | 2978 DisplayManagerTest::SetUp(); |
2943 const float kMeanGravity = 9.8066f; | 2979 const float kMeanGravity = 9.8066f; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3207 test_api.GetCurrentOrientation()); | 3243 test_api.GetCurrentOrientation()); |
3208 | 3244 |
3209 // The orientation has alraedy been locked to secondary once, so | 3245 // The orientation has alraedy been locked to secondary once, so |
3210 // it should swtich back to the portrait secondary. | 3246 // it should swtich back to the portrait secondary. |
3211 wm::ActivateWindow(window_ps); | 3247 wm::ActivateWindow(window_ps); |
3212 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary, | 3248 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary, |
3213 test_api.GetCurrentOrientation()); | 3249 test_api.GetCurrentOrientation()); |
3214 } | 3250 } |
3215 | 3251 |
3216 } // namespace ash | 3252 } // namespace ash |
OLD | NEW |