| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 #import <Cocoa/Cocoa.h> | |
| 6 | |
| 7 #include "base/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
| 8 #import "chrome/browser/cocoa/page_info_window_controller.h" | 6 #import "chrome/browser/cocoa/page_info_window_controller.h" |
| 9 #include "chrome/browser/cocoa/browser_test_helper.h" | 7 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 11 #include "chrome/common/pref_names.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 #include "testing/platform_test.h" | |
| 14 | 9 |
| 15 class PageInfoWindowControllerTest : public PlatformTest { | 10 class PageInfoWindowControllerTest : public CocoaTest { |
| 16 virtual void SetUp() { | 11 virtual void SetUp() { |
| 17 controller_.reset([[PageInfoWindowController alloc] init]); | 12 CocoaTest::SetUp(); |
| 13 controller_ = [[PageInfoWindowController alloc] init]; |
| 14 EXPECT_TRUE([controller_ window]); |
| 15 } |
| 16 |
| 17 virtual void TearDown() { |
| 18 [controller_ close]; |
| 19 CocoaTest::TearDown(); |
| 18 } | 20 } |
| 19 | 21 |
| 20 public: | 22 public: |
| 21 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | |
| 22 BrowserTestHelper helper_; | 23 BrowserTestHelper helper_; |
| 23 scoped_nsobject<PageInfoWindowController> controller_; | 24 PageInfoWindowController* controller_; |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 | 27 |
| 27 TEST_F(PageInfoWindowControllerTest, TestImages) { | 28 TEST_F(PageInfoWindowControllerTest, TestImages) { |
| 28 [controller_ window]; // Force nib load. | |
| 29 EXPECT_TRUE([controller_ goodImg]); | 29 EXPECT_TRUE([controller_ goodImg]); |
| 30 EXPECT_TRUE([controller_ badImg]); | 30 EXPECT_TRUE([controller_ badImg]); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 TEST_F(PageInfoWindowControllerTest, TestGrow) { | 34 TEST_F(PageInfoWindowControllerTest, TestGrow) { |
| 35 [controller_ window]; // Force nib load. | |
| 36 NSRect frame = [[controller_ window] frame]; | 35 NSRect frame = [[controller_ window] frame]; |
| 37 [controller_ setShowHistoryBox:YES]; | 36 [controller_ setShowHistoryBox:YES]; |
| 38 NSRect newFrame = [[controller_ window] frame]; | 37 NSRect newFrame = [[controller_ window] frame]; |
| 39 EXPECT_GE(newFrame.size.height, frame.size.height); | 38 EXPECT_GE(newFrame.size.height, frame.size.height); |
| 40 EXPECT_LE(newFrame.origin.y, frame.origin.y); | 39 EXPECT_LE(newFrame.origin.y, frame.origin.y); |
| 41 } | 40 } |
| 42 | 41 |
| 43 | 42 |
| 44 TEST_F(PageInfoWindowControllerTest, TestShrink) { | 43 TEST_F(PageInfoWindowControllerTest, TestShrink) { |
| 45 [controller_ window]; // Force nib to load. | |
| 46 [controller_ setShowHistoryBox:YES]; | 44 [controller_ setShowHistoryBox:YES]; |
| 47 NSRect frame = [[controller_ window] frame]; | 45 NSRect frame = [[controller_ window] frame]; |
| 48 [controller_ setShowHistoryBox:NO]; | 46 [controller_ setShowHistoryBox:NO]; |
| 49 NSRect newFrame = [[controller_ window] frame]; | 47 NSRect newFrame = [[controller_ window] frame]; |
| 50 EXPECT_LE(newFrame.size.height, frame.size.height); | 48 EXPECT_LE(newFrame.size.height, frame.size.height); |
| 51 EXPECT_GE(newFrame.origin.y, frame.origin.y); | 49 EXPECT_GE(newFrame.origin.y, frame.origin.y); |
| 52 } | 50 } |
| OLD | NEW |