| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 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 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #include "base/scoped_nsobject.h" |
| 8 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 10 #import "chrome/browser/cocoa/extension_shelf_controller.h" |
| 11 #import "chrome/browser/cocoa/view_resizer_pong.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "testing/platform_test.h" |
| 14 |
| 15 namespace { |
| 16 |
| 17 class ExtensionShelfControllerTest : public PlatformTest { |
| 18 public: |
| 19 ExtensionShelfControllerTest() { |
| 20 resizeDelegate_.reset([[ViewResizerPong alloc] init]); |
| 21 |
| 22 NSRect frame = NSMakeRect(0, 0, 100, 30); |
| 23 controller_.reset([[ExtensionShelfController alloc] |
| 24 initWithBrowser:helper_.browser() |
| 25 resizeDelegate:resizeDelegate_.get()]); |
| 26 } |
| 27 |
| 28 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... |
| 29 BrowserTestHelper helper_; |
| 30 scoped_nsobject<ExtensionShelfController> controller_; |
| 31 scoped_nsobject<ViewResizerPong> resizeDelegate_; |
| 32 }; |
| 33 |
| 34 // Check that |hide:| tells the delegate to set the shelf's height to zero. |
| 35 TEST_F(ExtensionShelfControllerTest, HideSetsHeightToZero) { |
| 36 [resizeDelegate_ setHeight:10]; |
| 37 [controller_ hide:nil]; |
| 38 EXPECT_EQ(0, [resizeDelegate_ height]); |
| 39 } |
| 40 |
| 41 // Check that |show:| tells the delegate to set the shelf's height to the |
| 42 // shelf's desired height. |
| 43 TEST_F(ExtensionShelfControllerTest, ShowSetsHeightToHeight) { |
| 44 [resizeDelegate_ setHeight:0]; |
| 45 [controller_ show:nil]; |
| 46 EXPECT_GT([controller_ height], 0); |
| 47 EXPECT_EQ([controller_ height], [resizeDelegate_ height]); |
| 48 } |
| 49 |
| 50 // Test adding to the view hierarchy, mostly to ensure nothing leaks or crashes. |
| 51 TEST_F(ExtensionShelfControllerTest, Add) { |
| 52 [cocoa_helper_.contentView() addSubview:[controller_ view]]; |
| 53 [controller_ wasInsertedIntoWindow]; |
| 54 } |
| 55 |
| 56 } // namespace |
| OLD | NEW |