| 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_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_commands_aura.h" | 7 #include "ash/accelerators/accelerator_commands_aura.h" |
| 8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
| 27 #include "ui/aura/client/aura_constants.h" | 27 #include "ui/aura/client/aura_constants.h" |
| 28 #include "ui/aura/env.h" | 28 #include "ui/aura/env.h" |
| 29 #include "ui/aura/window_observer.h" | 29 #include "ui/aura/window_observer.h" |
| 30 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/display/display.h" | 32 #include "ui/display/display.h" |
| 33 #include "ui/display/display_observer.h" | 33 #include "ui/display/display_observer.h" |
| 34 #include "ui/display/manager/display_layout_builder.h" | 34 #include "ui/display/manager/display_layout_builder.h" |
| 35 #include "ui/display/manager/display_layout_store.h" | 35 #include "ui/display/manager/display_layout_store.h" |
| 36 #include "ui/display/manager/display_manager_utilities.h" |
| 36 #include "ui/display/manager/managed_display_info.h" | 37 #include "ui/display/manager/managed_display_info.h" |
| 37 #include "ui/display/screen.h" | 38 #include "ui/display/screen.h" |
| 38 #include "ui/events/test/event_generator.h" | 39 #include "ui/events/test/event_generator.h" |
| 39 #include "ui/gfx/font_render_params.h" | 40 #include "ui/gfx/font_render_params.h" |
| 40 | 41 |
| 41 namespace ash { | 42 namespace ash { |
| 42 | 43 |
| 43 using std::vector; | 44 using std::vector; |
| 44 using std::string; | 45 using std::string; |
| 45 | 46 |
| (...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 EXPECT_EQ(internal_id, internal_display_id); | 2128 EXPECT_EQ(internal_id, internal_display_id); |
| 2128 | 2129 |
| 2129 display_info_list.clear(); | 2130 display_info_list.clear(); |
| 2130 display_info_list.push_back(external_display_info); | 2131 display_info_list.push_back(external_display_info); |
| 2131 display_manager()->OnNativeDisplaysChanged(display_info_list); | 2132 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 2132 EXPECT_EQ(1U, display_manager()->active_display_list().size()); | 2133 EXPECT_EQ(1U, display_manager()->active_display_list().size()); |
| 2133 | 2134 |
| 2134 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); | 2135 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); |
| 2135 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); | 2136 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); |
| 2136 | 2137 |
| 2137 const ui::ManagedDisplayInfo& info = | 2138 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true)); |
| 2138 display_manager()->GetDisplayInfo(internal_id); | 2139 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false)); |
| 2139 | |
| 2140 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, true)); | |
| 2141 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, false)); | |
| 2142 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); | 2140 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); |
| 2143 | |
| 2144 ui::ManagedDisplayInfo invalid_info; | |
| 2145 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, true)); | |
| 2146 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, false)); | |
| 2147 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); | |
| 2148 } | 2141 } |
| 2149 | 2142 |
| 2150 // Make sure that bad layout information is ignored and does not crash. | 2143 // Make sure that bad layout information is ignored and does not crash. |
| 2151 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { | 2144 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { |
| 2152 if (!SupportsMultipleDisplays()) | 2145 if (!SupportsMultipleDisplays()) |
| 2153 return; | 2146 return; |
| 2154 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); | 2147 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); |
| 2155 display::DisplayLayoutBuilder builder(1); | 2148 display::DisplayLayoutBuilder builder(1); |
| 2156 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); | 2149 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); |
| 2157 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); | 2150 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 EXPECT_EQ(display::Display::ROTATE_90, | 2321 EXPECT_EQ(display::Display::ROTATE_90, |
| 2329 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); | 2322 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); |
| 2330 EXPECT_EQ(display::Display::ROTATE_90, | 2323 EXPECT_EQ(display::Display::ROTATE_90, |
| 2331 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); | 2324 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); |
| 2332 } | 2325 } |
| 2333 | 2326 |
| 2334 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { | 2327 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { |
| 2335 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 2328 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
| 2336 int64_t id1 = 10001; | 2329 int64_t id1 = 10001; |
| 2337 int64_t id2 = 10002; | 2330 int64_t id2 = 10002; |
| 2338 ASSERT_TRUE(CompareDisplayIds(id1, id2)); | 2331 ASSERT_TRUE(ui::CompareDisplayIds(id1, id2)); |
| 2339 display::DisplayLayoutBuilder good_builder(id1); | 2332 display::DisplayLayoutBuilder good_builder(id1); |
| 2340 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); | 2333 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); |
| 2341 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); | 2334 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); |
| 2342 | 2335 |
| 2343 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); | 2336 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); |
| 2344 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); | 2337 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); |
| 2345 | 2338 |
| 2346 display::DisplayLayoutBuilder bad(id1); | 2339 display::DisplayLayoutBuilder bad(id1); |
| 2347 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); | 2340 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); |
| 2348 | 2341 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2370 const display::DisplayLayout& stored = | 2363 const display::DisplayLayout& stored = |
| 2371 layout_store->GetRegisteredDisplayLayout(list); | 2364 layout_store->GetRegisteredDisplayLayout(list); |
| 2372 | 2365 |
| 2373 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); | 2366 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); |
| 2374 EXPECT_EQ(id2, stored.placement_list[0].display_id); | 2367 EXPECT_EQ(id2, stored.placement_list[0].display_id); |
| 2375 } | 2368 } |
| 2376 | 2369 |
| 2377 #endif // OS_CHROMEOS | 2370 #endif // OS_CHROMEOS |
| 2378 | 2371 |
| 2379 } // namespace ash | 2372 } // namespace ash |
| OLD | NEW |