Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: chrome/browser/cocoa/bookmark_button_cell_unittest.mm

Issue 391046: Fix "open all" on a folder node to open only 'marks in that folder,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/bookmark_button_cell.mm ('k') | chrome/browser/cocoa/bookmark_menu.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/cocoa_test_helper.h" 8 #import "chrome/browser/cocoa/cocoa_test_helper.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
10 11
11 namespace { 12 namespace {
12 13
13 class BookmarkButtonCellTest : public PlatformTest { 14 class BookmarkButtonCellTest : public PlatformTest {
14 public: 15 public:
15 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... 16 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
16 scoped_nsobject<NSButton> view_; 17 scoped_nsobject<NSButton> view_;
17 }; 18 };
18 19
19 // Make sure it's not totally bogus 20 // Make sure it's not totally bogus
20 TEST_F(BookmarkButtonCellTest, SizeForBounds) { 21 TEST_F(BookmarkButtonCellTest, SizeForBounds) {
21 NSRect frame = NSMakeRect(0, 0, 50, 30); 22 NSRect frame = NSMakeRect(0, 0, 50, 30);
22 view_.reset([[NSButton alloc] initWithFrame:frame]); 23 view_.reset([[NSButton alloc] initWithFrame:frame]);
23 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] 24 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc]
24 initTextCell:@"Testing"]); 25 initTextCell:@"Testing"]);
25 [view_ setCell:cell.get()]; 26 [view_ setCell:cell.get()];
26 [cocoa_helper_.contentView() addSubview:view_.get()]; 27 [cocoa_helper_.contentView() addSubview:view_.get()];
27 28
28 NSRect r = NSMakeRect(0, 0, 100, 100); 29 NSRect r = NSMakeRect(0, 0, 100, 100);
29 NSSize size = [cell.get() cellSizeForBounds:r]; 30 NSSize size = [cell.get() cellSizeForBounds:r];
30 EXPECT_TRUE(size.width > 0 && size.height > 0); 31 EXPECT_TRUE(size.width > 0 && size.height > 0);
31 EXPECT_TRUE(size.width < 200 && size.height < 200); 32 EXPECT_TRUE(size.width < 200 && size.height < 200);
32 } 33 }
33 34
34 // Make sure a cell's menu has the cell itself as the delegate. This
35 // is our convention for reusing the context menu across all bookmarks
36 // while being unambiguous when used.
37 TEST_F(BookmarkButtonCellTest, MenuDelegate) {
38 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc]
39 initTextCell:@"Testing"]);
40 EXPECT_FALSE([cell.get() menu]);
41
42 scoped_nsobject<NSMenu> menu([[NSMenu alloc] initWithTitle:@"foo"]);
43 [cell setMenu:menu.get()];
44 EXPECT_TRUE([cell.get() menu]);
45 EXPECT_EQ([[cell.get() menu] delegate], cell.get());
46 [cell setMenu:nil];
47 }
48
49 // Make sure the default from the base class is overridden 35 // Make sure the default from the base class is overridden
50 TEST_F(BookmarkButtonCellTest, MouseEnterStuff) { 36 TEST_F(BookmarkButtonCellTest, MouseEnterStuff) {
51 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] 37 scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc]
52 initTextCell:@"Testing"]); 38 initTextCell:@"Testing"]);
53 EXPECT_TRUE([cell.get() showsBorderOnlyWhileMouseInside]); 39 EXPECT_TRUE([cell.get() showsBorderOnlyWhileMouseInside]);
54 } 40 }
55 41
56 } // namespace 42 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_button_cell.mm ('k') | chrome/browser/cocoa/bookmark_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698