| 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 #include "base/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
| 6 #import "chrome/browser/cocoa/bookmark_button_cell.h" | 6 #import "chrome/browser/cocoa/bookmark_button_cell.h" |
| 7 #import "chrome/browser/cocoa/bookmark_menu.h" | 7 #import "chrome/browser/cocoa/bookmark_menu.h" |
| 8 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 class BookmarkButtonCellTest : public PlatformTest { | 14 class BookmarkButtonCellTest : public CocoaTest { |
| 15 public: | |
| 16 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | |
| 17 scoped_nsobject<NSButton> view_; | |
| 18 }; | 15 }; |
| 19 | 16 |
| 20 // Make sure it's not totally bogus | 17 // Make sure it's not totally bogus |
| 21 TEST_F(BookmarkButtonCellTest, SizeForBounds) { | 18 TEST_F(BookmarkButtonCellTest, SizeForBounds) { |
| 22 NSRect frame = NSMakeRect(0, 0, 50, 30); | 19 NSRect frame = NSMakeRect(0, 0, 50, 30); |
| 23 view_.reset([[NSButton alloc] initWithFrame:frame]); | 20 scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); |
| 24 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] | 21 scoped_nsobject<BookmarkButtonCell> cell( |
| 25 initTextCell:@"Testing"]); | 22 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); |
| 26 [view_ setCell:cell.get()]; | 23 [view setCell:cell.get()]; |
| 27 [cocoa_helper_.contentView() addSubview:view_.get()]; | 24 [[test_window() contentView] addSubview:view]; |
| 28 | 25 |
| 29 NSRect r = NSMakeRect(0, 0, 100, 100); | 26 NSRect r = NSMakeRect(0, 0, 100, 100); |
| 30 NSSize size = [cell.get() cellSizeForBounds:r]; | 27 NSSize size = [cell.get() cellSizeForBounds:r]; |
| 31 EXPECT_TRUE(size.width > 0 && size.height > 0); | 28 EXPECT_TRUE(size.width > 0 && size.height > 0); |
| 32 EXPECT_TRUE(size.width < 200 && size.height < 200); | 29 EXPECT_TRUE(size.width < 200 && size.height < 200); |
| 33 } | 30 } |
| 34 | 31 |
| 35 // Make sure the default from the base class is overridden | 32 // Make sure the default from the base class is overridden |
| 36 TEST_F(BookmarkButtonCellTest, MouseEnterStuff) { | 33 TEST_F(BookmarkButtonCellTest, MouseEnterStuff) { |
| 37 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] | 34 scoped_nsobject<BookmarkButtonCell> cell( |
| 38 initTextCell:@"Testing"]); | 35 [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); |
| 39 EXPECT_TRUE([cell.get() showsBorderOnlyWhileMouseInside]); | 36 EXPECT_TRUE([cell.get() showsBorderOnlyWhileMouseInside]); |
| 40 } | 37 } |
| 41 | 38 |
| 42 } // namespace | 39 } // namespace |
| OLD | NEW |