| Index: ui/views/controls/native/native_view_host_aura_unittest.cc
|
| diff --git a/ui/views/controls/native/native_view_host_aura_unittest.cc b/ui/views/controls/native/native_view_host_aura_unittest.cc
|
| index a0833e02a4eb74322f002c9ea60c3b1006654964..4198650042e61eeccedae3e182346e4638b47e0d 100644
|
| --- a/ui/views/controls/native/native_view_host_aura_unittest.cc
|
| +++ b/ui/views/controls/native/native_view_host_aura_unittest.cc
|
| @@ -184,7 +184,7 @@ TEST_F(NativeViewHostAuraTest, FastResizePath) {
|
| // with the native view positioned at the origin of the clipping window and
|
| // the clipping window positioned where the native view was requested.
|
| host()->set_fast_resize(false);
|
| - native_host()->ShowWidget(5, 10, 100, 100);
|
| + native_host()->ShowWidget(5, 10, 100, 100, 100, 100);
|
| EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
|
| host()->native_view()->bounds().ToString());
|
| EXPECT_EQ(gfx::Rect(5, 10, 100, 100).ToString(),
|
| @@ -193,7 +193,7 @@ TEST_F(NativeViewHostAuraTest, FastResizePath) {
|
| // With fast resize, the native view should remain the same size but be
|
| // clipped the requested size.
|
| host()->set_fast_resize(true);
|
| - native_host()->ShowWidget(10, 25, 50, 50);
|
| + native_host()->ShowWidget(10, 25, 50, 50, 50, 50);
|
| EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
|
| host()->native_view()->bounds().ToString());
|
| EXPECT_EQ(gfx::Rect(10, 25, 50, 50).ToString(),
|
| @@ -201,7 +201,7 @@ TEST_F(NativeViewHostAuraTest, FastResizePath) {
|
|
|
| // Turning off fast resize should make the native view start resizing again.
|
| host()->set_fast_resize(false);
|
| - native_host()->ShowWidget(10, 25, 50, 50);
|
| + native_host()->ShowWidget(10, 25, 50, 50, 50, 50);
|
| EXPECT_EQ(gfx::Rect(0, 0, 50, 50).ToString(),
|
| host()->native_view()->bounds().ToString());
|
| EXPECT_EQ(gfx::Rect(10, 25, 50, 50).ToString(),
|
| @@ -210,6 +210,61 @@ TEST_F(NativeViewHostAuraTest, FastResizePath) {
|
| DestroyHost();
|
| }
|
|
|
| +// Test that the clipping and content windows' bounds are set to the correct
|
| +// values while the rendering size is not equal to the View size. During fast
|
| +// resize, the size and transform of the NativeView should not be modified.
|
| +TEST_F(NativeViewHostAuraTest, BoundsWhileScaling) {
|
| + CreateHost();
|
| + toplevel()->SetBounds(gfx::Rect(20, 20, 100, 100));
|
| + EXPECT_EQ(gfx::Transform(), host()->native_view()->transform());
|
| +
|
| + // Without fast resize, the clipping window should size to the native view
|
| + // with the native view positioned at the origin of the clipping window and
|
| + // the clipping window positioned where the native view was requested. The
|
| + // size of the native view should be 200x200 (so it's content will be
|
| + // shown at half-size).
|
| + host()->set_fast_resize(false);
|
| + native_host()->ShowWidget(5, 10, 100, 100, 200, 200);
|
| + EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
|
| + host()->native_view()->bounds().ToString());
|
| + EXPECT_EQ(gfx::Rect(5, 10, 100, 100).ToString(),
|
| + clipping_window()->bounds().ToString());
|
| + gfx::Transform expected_transform;
|
| + expected_transform.Scale(0.5, 0.5);
|
| + EXPECT_EQ(expected_transform, host()->native_view()->transform());
|
| +
|
| + // With fast resize, the native view should remain the same size but be
|
| + // clipped the requested size. Also, its transform should not be changed.
|
| + host()->set_fast_resize(true);
|
| + native_host()->ShowWidget(10, 25, 50, 50, 200, 200);
|
| + EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
|
| + host()->native_view()->bounds().ToString());
|
| + EXPECT_EQ(gfx::Rect(10, 25, 50, 50).ToString(),
|
| + clipping_window()->bounds().ToString());
|
| + EXPECT_EQ(expected_transform, host()->native_view()->transform());
|
| +
|
| + // Turning off fast resize should make the native view start resizing again,
|
| + // and its transform modified to show at the new quarter-size.
|
| + host()->set_fast_resize(false);
|
| + native_host()->ShowWidget(10, 25, 50, 50, 200, 200);
|
| + EXPECT_EQ(gfx::Rect(0, 0, 200, 200).ToString(),
|
| + host()->native_view()->bounds().ToString());
|
| + EXPECT_EQ(gfx::Rect(10, 25, 50, 50).ToString(),
|
| + clipping_window()->bounds().ToString());
|
| + expected_transform = gfx::Transform();
|
| + expected_transform.Scale(0.25, 0.25);
|
| + EXPECT_EQ(expected_transform, host()->native_view()->transform());
|
| +
|
| + // When the NativeView is detached, its original transform should be restored.
|
| + auto* const detached_view = host()->native_view();
|
| + host()->Detach();
|
| + EXPECT_EQ(gfx::Transform(), detached_view->transform());
|
| + // Attach it again so it's torn down with everything else at the end.
|
| + host()->Attach(detached_view);
|
| +
|
| + DestroyHost();
|
| +}
|
| +
|
| // Test installing and uninstalling a clip.
|
| TEST_F(NativeViewHostAuraTest, InstallClip) {
|
| CreateHost();
|
| @@ -218,7 +273,7 @@ TEST_F(NativeViewHostAuraTest, InstallClip) {
|
| // Without a clip, the clipping window should always be positioned at the
|
| // requested coordinates with the native view positioned at the origin of the
|
| // clipping window.
|
| - native_host()->ShowWidget(10, 20, 100, 100);
|
| + native_host()->ShowWidget(10, 20, 100, 100, 100, 100);
|
| EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
|
| host()->native_view()->bounds().ToString());
|
| EXPECT_EQ(gfx::Rect(10, 20, 100, 100).ToString(),
|
| @@ -226,7 +281,7 @@ TEST_F(NativeViewHostAuraTest, InstallClip) {
|
|
|
| // Clip to the bottom right quarter of the native view.
|
| native_host()->InstallClip(60, 70, 50, 50);
|
| - native_host()->ShowWidget(10, 20, 100, 100);
|
| + native_host()->ShowWidget(10, 20, 100, 100, 100, 100);
|
| EXPECT_EQ(gfx::Rect(-50, -50, 100, 100).ToString(),
|
| host()->native_view()->bounds().ToString());
|
| EXPECT_EQ(gfx::Rect(60, 70, 50, 50).ToString(),
|
| @@ -234,7 +289,7 @@ TEST_F(NativeViewHostAuraTest, InstallClip) {
|
|
|
| // Clip to the center of the native view.
|
| native_host()->InstallClip(35, 45, 50, 50);
|
| - native_host()->ShowWidget(10, 20, 100, 100);
|
| + native_host()->ShowWidget(10, 20, 100, 100, 100, 100);
|
| EXPECT_EQ(gfx::Rect(-25, -25, 100, 100).ToString(),
|
| host()->native_view()->bounds().ToString());
|
| EXPECT_EQ(gfx::Rect(35, 45, 50, 50).ToString(),
|
| @@ -243,7 +298,7 @@ TEST_F(NativeViewHostAuraTest, InstallClip) {
|
| // Uninstalling the clip should make the clipping window match the native view
|
| // again.
|
| native_host()->UninstallClip();
|
| - native_host()->ShowWidget(10, 20, 100, 100);
|
| + native_host()->ShowWidget(10, 20, 100, 100, 100, 100);
|
| EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(),
|
| host()->native_view()->bounds().ToString());
|
| EXPECT_EQ(gfx::Rect(10, 20, 100, 100).ToString(),
|
| @@ -292,7 +347,7 @@ TEST_F(NativeViewHostAuraTest, ParentAfterDetach) {
|
| TEST_F(NativeViewHostAuraTest, RemoveClippingWindowOrder) {
|
| CreateHost();
|
| toplevel()->SetBounds(gfx::Rect(20, 20, 100, 100));
|
| - native_host()->ShowWidget(10, 20, 100, 100);
|
| + native_host()->ShowWidget(10, 20, 100, 100, 100, 100);
|
|
|
| NativeViewHostWindowObserver test_observer;
|
| clipping_window()->AddObserver(&test_observer);
|
|
|