Chromium Code Reviews| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm |
| diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm |
| index e820fc1426c44f123a5e82aa03d1a96b32205e38..d9644f80331cf3d071c336fe40b5c2e46451a136 100644 |
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm |
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm |
| @@ -2,10 +2,11 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| #include "base/mac/scoped_nsobject.h" |
| +#include "base/strings/sys_string_conversions.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| -#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
| #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" |
| #include "chrome/test/base/testing_profile.h" |
| @@ -121,6 +122,7 @@ TEST_F(BookmarkButtonCellTest, BookmarkNode) { |
| node = model->other_node(); |
| [cell setBookmarkNode:node]; |
| EXPECT_EQ(node, [cell bookmarkNode]); |
| + EXPECT_EQ(node->GetTitle(), base::SysNSStringToUTF16([cell title])); |
| } |
| TEST_F(BookmarkButtonCellTest, BookmarkMouseForwarding) { |
| @@ -213,4 +215,32 @@ TEST_F(BookmarkButtonCellTest, OffTheSideCell) { |
| EXPECT_TRUE([[BookmarkButtonCell offTheSideButtonCell] |
| isKindOfClass:offTheSideButtonCellClass]); |
| } |
| + |
| +TEST_F(BookmarkButtonCellTest, CellWidthForNode) { |
| + BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
| + |
| + const BookmarkNode* bar = model->bookmark_bar_node(); |
| + const BookmarkNode* node_a = |
| + model->AddURL(bar, bar->child_count(), base::ASCIIToUTF16("A cell"), |
| + GURL("http://www.google.com")); |
| + const BookmarkNode* node_b = |
| + model->AddURL(bar, bar->child_count(), |
| + base::ASCIIToUTF16("This cell has a longer title "), |
| + GURL("http://www.google.com/a")); |
| + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| + base::scoped_nsobject<NSImage> image( |
| + rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).CopyNSImage()); |
| + CGFloat width_for_node_a = |
| + [BookmarkButtonCell cellWidthForNode:node_a image:image]; |
| + CGFloat width_for_node_b = |
| + [BookmarkButtonCell cellWidthForNode:node_b image:image]; |
| + base::scoped_nsobject<BookmarkButtonCell> bookmark_cell( |
| + [[BookmarkButtonCell alloc] initForNode:node_a |
| + text:nil |
| + image:image |
| + menuController:nil]); |
| + EXPECT_CGFLOAT_EQ([bookmark_cell cellSize].width, width_for_node_a); |
|
Elly Fong-Jones
2017/04/04 15:04:36
what is this actually testing?
lgrey
2017/04/04 15:12:27
|width_for_node_a| comes from the class method, |c
Elly Fong-Jones
2017/04/05 11:26:37
Got it - can you add a comment to that effect?
lgrey
2017/04/05 15:21:56
Done.
|
| + [bookmark_cell setBookmarkNode:node_b image:image]; |
| + EXPECT_CGFLOAT_EQ([bookmark_cell cellSize].width, width_for_node_b); |
| +} |
| } // namespace |