Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: ui/views/controls/native/native_view_host_aura_unittest.cc

Issue 27768003: aura: Fix NativeViewHostAura non fast resize clipping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/native/native_view_host_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ui/views/controls/native/native_view_host_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698