| 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/cocoa_test_helper.h" | 7 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 initTextCell:@"Testing"]); | 23 initTextCell:@"Testing"]); |
| 24 [view_ setCell:cell.get()]; | 24 [view_ setCell:cell.get()]; |
| 25 [cocoa_helper_.contentView() addSubview:view_.get()]; | 25 [cocoa_helper_.contentView() addSubview:view_.get()]; |
| 26 | 26 |
| 27 NSRect r = NSMakeRect(0, 0, 100, 100); | 27 NSRect r = NSMakeRect(0, 0, 100, 100); |
| 28 NSSize size = [cell.get() cellSizeForBounds:r]; | 28 NSSize size = [cell.get() cellSizeForBounds:r]; |
| 29 EXPECT_TRUE(size.width > 0 && size.height > 0); | 29 EXPECT_TRUE(size.width > 0 && size.height > 0); |
| 30 EXPECT_TRUE(size.width < 200 && size.height < 200); | 30 EXPECT_TRUE(size.width < 200 && size.height < 200); |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Make sure a cell's menu has the cell itself as the delegate. This |
| 34 // is our convention for reusing the context menu across all bookmarks |
| 35 // while being unambiguous when used. |
| 36 TEST_F(BookmarkButtonCellTest, MenuDelegate) { |
| 37 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] |
| 38 initTextCell:@"Testing"]); |
| 39 EXPECT_FALSE([cell.get() menu]); |
| 40 |
| 41 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@"foo"]); |
| 42 [cell setMenu:menu.get()]; |
| 43 EXPECT_TRUE([cell.get() menu]); |
| 44 EXPECT_EQ([[cell.get() menu] delegate], cell.get()); |
| 45 [cell setMenu:nil]; |
| 46 } |
| 47 |
| 48 // Make sure the default from the base class is overridden |
| 49 TEST_F(BookmarkButtonCellTest, MouseEnterStuff) { |
| 50 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] |
| 51 initTextCell:@"Testing"]); |
| 52 EXPECT_TRUE([cell.get() showsBorderOnlyWhileMouseInside]); |
| 53 } |
| 33 | 54 |
| 34 } // namespace | 55 } // namespace |
| OLD | NEW |