| 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 7653cc905c31ba106fc6e6d4b920b754f9a4289b..8f3759a5f0318fab9b03b4f681f77e992ac2cd70 100644
|
| --- a/ui/views/controls/native/native_view_host_aura_unittest.cc
|
| +++ b/ui/views/controls/native/native_view_host_aura_unittest.cc
|
| @@ -59,6 +59,16 @@ class NativeViewHostAuraTest : public ViewsTestBase {
|
| host_.reset();
|
| }
|
|
|
| + gfx::Point CalculateNewNativeViewOrigin(gfx::Rect input_rect,
|
| + gfx::Rect native_rect) {
|
| + return native_host()->CalculateNewNativeViewOrigin(input_rect, native_rect);
|
| + }
|
| +
|
| + gfx::Point CalculateClipOrigin(gfx::Rect input_rect,
|
| + gfx::Rect native_rect) {
|
| + return native_host()->CalculateClipOrigin(input_rect, native_rect);
|
| + }
|
| +
|
| private:
|
| scoped_ptr<Widget> toplevel_;
|
| scoped_ptr<NativeViewHost> host_;
|
| @@ -95,4 +105,103 @@ TEST_F(NativeViewHostAuraTest, HostViewPropertyKey) {
|
| EXPECT_FALSE(child_win->GetProperty(views::kHostViewKey));
|
| }
|
|
|
| +// Tests that the values being calculated by CalculateNewNativeViewOrigin are
|
| +// correct.
|
| +TEST_F(NativeViewHostAuraTest, CalculateNewNativeViewOrigin) {
|
| + CreateHost();
|
| +
|
| + gfx::Rect clip_rect(50, 50, 50, 50);
|
| + gfx::Rect contents_rect(0, 0, 100, 100);
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_NORTHWEST);
|
| + EXPECT_EQ(gfx::Point(50, 50),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_NORTH);
|
| + EXPECT_EQ(gfx::Point(25, 50),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_NORTHEAST);
|
| + EXPECT_EQ(gfx::Point(0, 50),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_EAST);
|
| + EXPECT_EQ(gfx::Point(0, 25),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_SOUTHEAST);
|
| + EXPECT_EQ(gfx::Point(0, 0),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_SOUTH);
|
| + EXPECT_EQ(gfx::Point(25, 0),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_SOUTHWEST);
|
| + EXPECT_EQ(gfx::Point(50, 0),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_WEST);
|
| + EXPECT_EQ(gfx::Point(50, 25),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_CENTER);
|
| + EXPECT_EQ(gfx::Point(25, 25),
|
| + CalculateNewNativeViewOrigin(clip_rect, contents_rect));
|
| +}
|
| +
|
| +// Tests that the values being calculated by CalculateClipOrigin are
|
| +// correct.
|
| +TEST_F(NativeViewHostAuraTest, CalculateClipOrigin) {
|
| + CreateHost();
|
| +
|
| + gfx::Rect clip_rect(50, 50, 50, 50);
|
| + gfx::Rect contents_rect(0, 0, 100, 100);
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_NORTHWEST);
|
| + contents_rect.set_origin(gfx::Point(50, 50));
|
| + EXPECT_EQ(gfx::Point(0,0),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_NORTH);
|
| + contents_rect.set_origin(gfx::Point(25, 50));
|
| + EXPECT_EQ(gfx::Point(-25, 0),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_NORTHEAST);
|
| + contents_rect.set_origin(gfx::Point(0, 50));
|
| + EXPECT_EQ(gfx::Point(-50, 0),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_EAST);
|
| + contents_rect.set_origin(gfx::Point(0, 25));
|
| + EXPECT_EQ(gfx::Point(-50, -25),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_SOUTHEAST);
|
| + contents_rect.set_origin(gfx::Point(0, 0));
|
| + EXPECT_EQ(gfx::Point(-50, -50),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_SOUTH);
|
| + contents_rect.set_origin(gfx::Point(25, 0));
|
| + EXPECT_EQ(gfx::Point(-25, -50),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_SOUTHWEST);
|
| + contents_rect.set_origin(gfx::Point(50, 0));
|
| + EXPECT_EQ(gfx::Point(0, -50),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_WEST);
|
| + contents_rect.set_origin(gfx::Point(50, 25));
|
| + EXPECT_EQ(gfx::Point(0, -25),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +
|
| + host()->set_fast_resize_gravity(NativeViewHost::GRAVITY_CENTER);
|
| + contents_rect.set_origin(gfx::Point(25, 25));
|
| + EXPECT_EQ(gfx::Point(-25, -25),
|
| + CalculateClipOrigin(clip_rect, contents_rect));
|
| +}
|
| +
|
| } // namespace views
|
|
|