| 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 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 EXPECT_EQ(internal_id, internal_display_id); | 2135 EXPECT_EQ(internal_id, internal_display_id); |
| 2135 | 2136 |
| 2136 display_info_list.clear(); | 2137 display_info_list.clear(); |
| 2137 display_info_list.push_back(external_display_info); | 2138 display_info_list.push_back(external_display_info); |
| 2138 display_manager()->OnNativeDisplaysChanged(display_info_list); | 2139 display_manager()->OnNativeDisplaysChanged(display_info_list); |
| 2139 EXPECT_EQ(1U, display_manager()->active_display_list().size()); | 2140 EXPECT_EQ(1U, display_manager()->active_display_list().size()); |
| 2140 | 2141 |
| 2141 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); | 2142 EXPECT_TRUE(display_manager()->IsActiveDisplayId(external_id)); |
| 2142 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); | 2143 EXPECT_FALSE(display_manager()->IsActiveDisplayId(internal_id)); |
| 2143 | 2144 |
| 2144 const display::ManagedDisplayInfo& info = | 2145 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(true)); |
| 2145 display_manager()->GetDisplayInfo(internal_id); | 2146 EXPECT_FALSE(display_manager()->ZoomInternalDisplay(false)); |
| 2146 | |
| 2147 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, true)); | |
| 2148 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(info, false)); | |
| 2149 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); | 2147 EXPECT_FALSE(SetDisplayUIScale(internal_id, 1.0f)); |
| 2150 | |
| 2151 display::ManagedDisplayInfo invalid_info; | |
| 2152 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, true)); | |
| 2153 EXPECT_FALSE(!!GetDisplayModeForNextUIScale(invalid_info, false)); | |
| 2154 EXPECT_FALSE(SetDisplayUIScale(display::Display::kInvalidDisplayID, 1.0f)); | |
| 2155 } | 2148 } |
| 2156 | 2149 |
| 2157 // Make sure that bad layout information is ignored and does not crash. | 2150 // Make sure that bad layout information is ignored and does not crash. |
| 2158 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { | 2151 TEST_P(DisplayManagerTest, DontRegisterBadConfig) { |
| 2159 if (!SupportsMultipleDisplays()) | 2152 if (!SupportsMultipleDisplays()) |
| 2160 return; | 2153 return; |
| 2161 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); | 2154 display::DisplayIdList list = ash::test::CreateDisplayIdList2(1, 2); |
| 2162 display::DisplayLayoutBuilder builder(1); | 2155 display::DisplayLayoutBuilder builder(1); |
| 2163 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); | 2156 builder.AddDisplayPlacement(2, 1, display::DisplayPlacement::LEFT, 0); |
| 2164 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); | 2157 builder.AddDisplayPlacement(3, 1, display::DisplayPlacement::BOTTOM, 0); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2336 EXPECT_EQ(display::Display::ROTATE_90, | 2329 EXPECT_EQ(display::Display::ROTATE_90, |
| 2337 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); | 2330 info.GetRotation(display::Display::ROTATION_SOURCE_USER)); |
| 2338 EXPECT_EQ(display::Display::ROTATE_90, | 2331 EXPECT_EQ(display::Display::ROTATE_90, |
| 2339 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); | 2332 info.GetRotation(display::Display::ROTATION_SOURCE_ACTIVE)); |
| 2340 } | 2333 } |
| 2341 | 2334 |
| 2342 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { | 2335 TEST_P(DisplayManagerTest, RejectInvalidLayoutData) { |
| 2343 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); | 2336 display::DisplayLayoutStore* layout_store = display_manager()->layout_store(); |
| 2344 int64_t id1 = 10001; | 2337 int64_t id1 = 10001; |
| 2345 int64_t id2 = 10002; | 2338 int64_t id2 = 10002; |
| 2346 ASSERT_TRUE(CompareDisplayIds(id1, id2)); | 2339 ASSERT_TRUE(display::CompareDisplayIds(id1, id2)); |
| 2347 display::DisplayLayoutBuilder good_builder(id1); | 2340 display::DisplayLayoutBuilder good_builder(id1); |
| 2348 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); | 2341 good_builder.SetSecondaryPlacement(id2, display::DisplayPlacement::LEFT, 0); |
| 2349 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); | 2342 std::unique_ptr<display::DisplayLayout> good(good_builder.Build()); |
| 2350 | 2343 |
| 2351 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); | 2344 display::DisplayIdList good_list = test::CreateDisplayIdList2(id1, id2); |
| 2352 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); | 2345 layout_store->RegisterLayoutForDisplayIdList(good_list, good->Copy()); |
| 2353 | 2346 |
| 2354 display::DisplayLayoutBuilder bad(id1); | 2347 display::DisplayLayoutBuilder bad(id1); |
| 2355 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); | 2348 bad.SetSecondaryPlacement(id2, display::DisplayPlacement::BOTTOM, 0); |
| 2356 | 2349 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2378 const display::DisplayLayout& stored = | 2371 const display::DisplayLayout& stored = |
| 2379 layout_store->GetRegisteredDisplayLayout(list); | 2372 layout_store->GetRegisteredDisplayLayout(list); |
| 2380 | 2373 |
| 2381 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); | 2374 EXPECT_EQ(id1, stored.placement_list[0].parent_display_id); |
| 2382 EXPECT_EQ(id2, stored.placement_list[0].display_id); | 2375 EXPECT_EQ(id2, stored.placement_list[0].display_id); |
| 2383 } | 2376 } |
| 2384 | 2377 |
| 2385 #endif // OS_CHROMEOS | 2378 #endif // OS_CHROMEOS |
| 2386 | 2379 |
| 2387 } // namespace ash | 2380 } // namespace ash |
| OLD | NEW |