| 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/screen_util.h" | 5 #include "ash/screen_util.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/wm_screen_util.h" | 7 #include "ash/common/wm/wm_screen_util.h" |
| 8 #include "ash/common/wm_lookup.h" | 8 #include "ash/common/wm_lookup.h" |
| 9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_md_test_base.h" | 11 #include "ash/test/ash_md_test_base.h" |
| 12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/display/manager/display_manager.h" | 16 #include "ui/display/manager/display_manager.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/widget/widget_delegate.h" | 18 #include "ui/views/widget/widget_delegate.h" |
| 19 #include "ui/wm/core/coordinate_conversion.h" |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 namespace test { | 22 namespace test { |
| 22 | 23 |
| 23 using ScreenUtilTest = AshMDTestBase; | 24 using ScreenUtilTest = AshMDTestBase; |
| 24 | 25 |
| 25 INSTANTIATE_TEST_CASE_P( | 26 INSTANTIATE_TEST_CASE_P( |
| 26 /* prefix intentionally left blank due to only one parameterization */, | 27 /* prefix intentionally left blank due to only one parameterization */, |
| 27 ScreenUtilTest, | 28 ScreenUtilTest, |
| 28 testing::Values(MaterialDesignController::NON_MATERIAL, | 29 testing::Values(MaterialDesignController::NON_MATERIAL, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 UpdateDisplay("600x600,500x500"); | 90 UpdateDisplay("600x600,500x500"); |
| 90 | 91 |
| 91 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( | 92 views::Widget* primary = views::Widget::CreateWindowWithContextAndBounds( |
| 92 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); | 93 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
| 93 primary->Show(); | 94 primary->Show(); |
| 94 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( | 95 views::Widget* secondary = views::Widget::CreateWindowWithContextAndBounds( |
| 95 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); | 96 NULL, CurrentContext(), gfx::Rect(610, 10, 100, 100)); |
| 96 secondary->Show(); | 97 secondary->Show(); |
| 97 | 98 |
| 98 EXPECT_EQ("0,0 100x100", | 99 EXPECT_EQ("0,0 100x100", |
| 99 ScreenUtil::ConvertRectFromScreen(primary->GetNativeView(), | 100 ::wm::ConvertRectFromScreen(primary->GetNativeView(), |
| 100 gfx::Rect(10, 10, 100, 100)) | 101 gfx::Rect(10, 10, 100, 100)) |
| 101 .ToString()); | 102 .ToString()); |
| 102 EXPECT_EQ("10,10 100x100", | 103 EXPECT_EQ("10,10 100x100", |
| 103 ScreenUtil::ConvertRectFromScreen(secondary->GetNativeView(), | 104 ::wm::ConvertRectFromScreen(secondary->GetNativeView(), |
| 104 gfx::Rect(620, 20, 100, 100)) | 105 gfx::Rect(620, 20, 100, 100)) |
| 105 .ToString()); | 106 .ToString()); |
| 106 | 107 |
| 107 EXPECT_EQ("40,40 100x100", | 108 EXPECT_EQ("40,40 100x100", |
| 108 ScreenUtil::ConvertRectToScreen(primary->GetNativeView(), | 109 ::wm::ConvertRectToScreen(primary->GetNativeView(), |
| 109 gfx::Rect(30, 30, 100, 100)) | 110 gfx::Rect(30, 30, 100, 100)) |
| 110 .ToString()); | 111 .ToString()); |
| 111 EXPECT_EQ("650,50 100x100", | 112 EXPECT_EQ("650,50 100x100", |
| 112 ScreenUtil::ConvertRectToScreen(secondary->GetNativeView(), | 113 ::wm::ConvertRectToScreen(secondary->GetNativeView(), |
| 113 gfx::Rect(40, 40, 100, 100)) | 114 gfx::Rect(40, 40, 100, 100)) |
| 114 .ToString()); | 115 .ToString()); |
| 115 } | 116 } |
| 116 | 117 |
| 117 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { | 118 TEST_P(ScreenUtilTest, ShelfDisplayBoundsInUnifiedDesktop) { |
| 118 display_manager()->SetUnifiedDesktopEnabled(true); | 119 display_manager()->SetUnifiedDesktopEnabled(true); |
| 119 | 120 |
| 120 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 121 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 121 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); | 122 NULL, CurrentContext(), gfx::Rect(10, 10, 100, 100)); |
| 122 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget); | 123 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget); |
| 123 | 124 |
| 124 UpdateDisplay("500x400"); | 125 UpdateDisplay("500x400"); |
| 125 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); | 126 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); |
| 126 | 127 |
| 127 UpdateDisplay("500x400,600x400"); | 128 UpdateDisplay("500x400,600x400"); |
| 128 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); | 129 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); |
| 129 | 130 |
| 130 // Move to the 2nd physical display. Shelf's display still should be | 131 // Move to the 2nd physical display. Shelf's display still should be |
| 131 // the first. | 132 // the first. |
| 132 widget->SetBounds(gfx::Rect(800, 0, 100, 100)); | 133 widget->SetBounds(gfx::Rect(800, 0, 100, 100)); |
| 133 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString()); | 134 ASSERT_EQ("800,0 100x100", widget->GetWindowBoundsInScreen().ToString()); |
| 134 | 135 |
| 135 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); | 136 EXPECT_EQ("0,0 500x400", wm::GetDisplayBoundsWithShelf(window).ToString()); |
| 136 | 137 |
| 137 UpdateDisplay("600x500"); | 138 UpdateDisplay("600x500"); |
| 138 EXPECT_EQ("0,0 600x500", wm::GetDisplayBoundsWithShelf(window).ToString()); | 139 EXPECT_EQ("0,0 600x500", wm::GetDisplayBoundsWithShelf(window).ToString()); |
| 139 } | 140 } |
| 140 | 141 |
| 141 } // namespace test | 142 } // namespace test |
| 142 } // namespace ash | 143 } // namespace ash |
| OLD | NEW |