OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/views/controls/native/native_view_host_aura.h" | 5 #include "ui/views/controls/native/native_view_host_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/views/controls/native/native_view_host.h" | 10 #include "ui/views/controls/native/native_view_host.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // destroyed and there shouldn't be any errors. | 221 // destroyed and there shouldn't be any errors. |
222 TEST_F(NativeViewHostAuraTest, DestroyWidget) { | 222 TEST_F(NativeViewHostAuraTest, DestroyWidget) { |
223 NativeViewHostTesting::ResetDestroyedCount(); | 223 NativeViewHostTesting::ResetDestroyedCount(); |
224 CreateHost(); | 224 CreateHost(); |
225 ReleaseHost(); | 225 ReleaseHost(); |
226 EXPECT_EQ(0, NativeViewHostTesting::destroyed_count()); | 226 EXPECT_EQ(0, NativeViewHostTesting::destroyed_count()); |
227 DestroyTopLevel(); | 227 DestroyTopLevel(); |
228 EXPECT_EQ(1, NativeViewHostTesting::destroyed_count()); | 228 EXPECT_EQ(1, NativeViewHostTesting::destroyed_count()); |
229 } | 229 } |
230 | 230 |
| 231 // Test that the none fast resize path is clipped and positioned correctly. |
| 232 TEST_F(NativeViewHostAuraTest, NonFastResizePath) { |
| 233 const gfx::Rect base_rect = gfx::Rect(0, 0, 100, 100); |
| 234 CreateHost(); |
| 235 toplevel()->SetBounds(base_rect); |
| 236 native_host()->ShowWidget(base_rect.x(), base_rect.y(), |
| 237 base_rect.width(), base_rect.height()); |
| 238 EXPECT_EQ(base_rect.ToString(), |
| 239 host()->native_view()->bounds().ToString()); |
| 240 EXPECT_EQ(base_rect.ToString(), |
| 241 clipping_window()->bounds().ToString()); |
| 242 |
| 243 const gfx::Rect kTestCases[] = { |
| 244 gfx::Rect(-10, -20, 100, 100), |
| 245 gfx::Rect(0, -20, 100, 100), |
| 246 gfx::Rect(10, -20, 100, 100), |
| 247 gfx::Rect(-10, 0, 100, 100), |
| 248 gfx::Rect(0, 0, 100, 100), |
| 249 gfx::Rect(10, 0, 100, 100), |
| 250 gfx::Rect(-10, 20, 100, 100), |
| 251 gfx::Rect(0, 20, 100, 100), |
| 252 gfx::Rect(10, 20, 100, 100), |
| 253 gfx::Rect(0, 0, 200, 300), |
| 254 gfx::Rect(-50, -100, 200, 300), |
| 255 }; |
| 256 |
| 257 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
| 258 const gfx::Rect& bounds = kTestCases[i]; |
| 259 |
| 260 host()->SetBoundsRect(bounds); |
| 261 |
| 262 gfx::Rect clip_rect = gfx::IntersectRects(bounds, base_rect); |
| 263 EXPECT_EQ(clip_rect.ToString(), clipping_window()->bounds().ToString()); |
| 264 |
| 265 gfx::Rect native_view_bounds = bounds; |
| 266 native_view_bounds.Offset(-clip_rect.x(), -clip_rect.y()); |
| 267 EXPECT_EQ(native_view_bounds.ToString(), |
| 268 host()->native_view()->bounds().ToString()); |
| 269 } |
| 270 |
| 271 DestroyHost(); |
| 272 } |
| 273 |
231 } // namespace views | 274 } // namespace views |
OLD | NEW |