| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/aura/test/aura_test_base.h" | 5 #include "ui/aura/test/aura_test_base.h" |
| 6 #include "ui/aura/test/test_screen.h" | 6 #include "ui/aura/test/test_screen.h" |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/compositor/layer.h" | 8 #include "ui/compositor/layer.h" |
| 9 | 9 |
| 10 namespace aura { | 10 namespace aura { |
| 11 | 11 |
| 12 using WindowTreeHostTest = test::AuraTestBase; | 12 using WindowTreeHostTest = test::AuraTestBase; |
| 13 | 13 |
| 14 TEST_F(WindowTreeHostTest, DPIWindowSize) { | 14 TEST_F(WindowTreeHostTest, DPIWindowSize) { |
| 15 gfx::Rect starting_bounds(0, 0, 800, 600); | 15 gfx::Rect starting_bounds(0, 0, 800, 600); |
| 16 EXPECT_EQ(starting_bounds.size(), host()->compositor()->size()); | 16 EXPECT_EQ(starting_bounds.size(), host()->compositor()->size()); |
| 17 EXPECT_EQ(starting_bounds, host()->GetBounds()); | 17 EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); |
| 18 EXPECT_EQ(starting_bounds, root_window()->bounds()); | 18 EXPECT_EQ(starting_bounds, root_window()->bounds()); |
| 19 | 19 |
| 20 test_screen()->SetDeviceScaleFactor(1.5f); | 20 test_screen()->SetDeviceScaleFactor(1.5f); |
| 21 EXPECT_EQ(starting_bounds, host()->GetBounds()); | 21 EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); |
| 22 // Size should be rounded up after scaling. | 22 // Size should be rounded up after scaling. |
| 23 EXPECT_EQ(gfx::Rect(0, 0, 534, 400), root_window()->bounds()); | 23 EXPECT_EQ(gfx::Rect(0, 0, 534, 400), root_window()->bounds()); |
| 24 | 24 |
| 25 gfx::Transform transform; | 25 gfx::Transform transform; |
| 26 transform.Translate(0, 1.1f); | 26 transform.Translate(0, 1.1f); |
| 27 host()->SetRootTransform(transform); | 27 host()->SetRootTransform(transform); |
| 28 EXPECT_EQ(gfx::Rect(0, 1, 534, 401), root_window()->bounds()); | 28 EXPECT_EQ(gfx::Rect(0, 1, 534, 401), root_window()->bounds()); |
| 29 | 29 |
| 30 gfx::Insets padding(1, 2, 3, 4); | 30 gfx::Insets padding(1, 2, 3, 4); |
| 31 // Padding is in physical pixels. | 31 // Padding is in physical pixels. |
| 32 host()->SetOutputSurfacePadding(padding); | 32 host()->SetOutputSurfacePadding(padding); |
| 33 gfx::Rect padded_rect = starting_bounds; | 33 gfx::Rect padded_rect = starting_bounds; |
| 34 padded_rect.Inset(-padding); | 34 padded_rect.Inset(-padding); |
| 35 EXPECT_EQ(padded_rect.size(), host()->compositor()->size()); | 35 EXPECT_EQ(padded_rect.size(), host()->compositor()->size()); |
| 36 EXPECT_EQ(starting_bounds, host()->GetBounds()); | 36 EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); |
| 37 EXPECT_EQ(gfx::Rect(1, 1, 534, 401), root_window()->bounds()); | 37 EXPECT_EQ(gfx::Rect(1, 1, 534, 401), root_window()->bounds()); |
| 38 EXPECT_EQ(gfx::Vector2dF(0, 0), | 38 EXPECT_EQ(gfx::Vector2dF(0, 0), |
| 39 host()->compositor()->root_layer()->subpixel_position_offset()); | 39 host()->compositor()->root_layer()->subpixel_position_offset()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace aura | 42 } // namespace aura |
| OLD | NEW |