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

Side by Side Diff: chrome/browser/ui/cocoa/fast_resize_view_unittest.mm

Issue 469003006: Remove --disable-core-animation flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@erikchen_patch
Patch Set: Rebase Created 6 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/mac/scoped_nsobject.h"
6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
7 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
8
9 namespace {
10
11 class FastResizeViewTest : public CocoaTest {
12 public:
13 FastResizeViewTest() {
14 NSRect frame = NSMakeRect(0, 0, 100, 30);
15 base::scoped_nsobject<FastResizeView> view(
16 [[FastResizeView alloc] initWithFrame:frame]);
17 view_ = view.get();
18 [[test_window() contentView] addSubview:view_];
19
20 base::scoped_nsobject<NSView> childView(
21 [[NSView alloc] initWithFrame:frame]);
22 childView_ = childView.get();
23 [view_ addSubview:childView_];
24 }
25
26 FastResizeView* view_;
27 NSView* childView_;
28 };
29
30 TEST_VIEW(FastResizeViewTest, view_);
31
32 TEST_F(FastResizeViewTest, TestResizingOfChildren) {
33 NSRect squareFrame = NSMakeRect(0, 0, 200, 200);
34 NSRect rectFrame = NSMakeRect(1, 1, 150, 300);
35
36 // Test that changing the view's frame also changes the child's frame.
37 [view_ setFrame:squareFrame];
38 EXPECT_TRUE(NSEqualRects([view_ bounds], [childView_ frame]));
39
40 // Turn fast resize mode on and change the view's frame. This time, the child
41 // should not resize, but it should be anchored to the top left.
42 [view_ setFastResizeMode:YES];
43 [view_ setFrame:NSMakeRect(15, 30, 250, 250)];
44 EXPECT_TRUE(NSEqualSizes([childView_ frame].size, squareFrame.size));
45 EXPECT_EQ(NSMinX([view_ bounds]), NSMinX([childView_ frame]));
46 EXPECT_EQ(NSMaxY([view_ bounds]), NSMaxY([childView_ frame]));
47
48 // Another resize with fast resize mode on.
49 [view_ setFrame:rectFrame];
50 EXPECT_TRUE(NSEqualSizes([childView_ frame].size, squareFrame.size));
51 EXPECT_EQ(NSMinX([view_ bounds]), NSMinX([childView_ frame]));
52 EXPECT_EQ(NSMaxY([view_ bounds]), NSMaxY([childView_ frame]));
53
54 // Turn fast resize mode off. This should initiate an immediate resize, even
55 // though we haven't called setFrame directly.
56 [view_ setFastResizeMode:NO];
57 EXPECT_TRUE(NSEqualRects([view_ frame], rectFrame));
58 EXPECT_TRUE(NSEqualRects([view_ bounds], [childView_ frame]));
59 }
60
61 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/fast_resize_view.mm ('k') | chrome/browser/ui/cocoa/find_bar/find_bar_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698