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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/animatable_view.h"
9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
10 #import "chrome/browser/ui/cocoa/view_resizer_pong.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h"
16 class AnimatableViewTest : public CocoaTest {
18 AnimatableViewTest() {
19 NSRect frame = NSMakeRect(0, 0, 100, 100);
20 view_.reset([[AnimatableView alloc] initWithFrame:frame]);
21 [[test_window() contentView] addSubview:view_.get()];
23 resizeDelegate_.reset([[ViewResizerPong alloc] init]);
24 [view_ setResizeDelegate:resizeDelegate_.get()];
27 base::scoped_nsobject<ViewResizerPong> resizeDelegate_;
28 base::scoped_nsobject<AnimatableView> view_;
31 // Basic view tests (AddRemove, Display).
32 TEST_VIEW(AnimatableViewTest, view_);
34 TEST_F(AnimatableViewTest, GetAndSetHeight) {
35 // Make sure the view's height starts out at 100.
36 NSRect initialFrame = [view_ frame];
37 ASSERT_EQ(100, initialFrame.size.height);
38 EXPECT_EQ(initialFrame.size.height, [view_ height]);
40 // Set it directly to 50 and make sure it takes effect.
41 [resizeDelegate_ setHeight:-1];
43 EXPECT_EQ(50, [resizeDelegate_ height]);
46 // TODO(rohitrao): Find a way to unittest the animations and delegate messages.