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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell_unittest.mm

Issue 2794123002: [Mac] Bookmark button cell updates (Closed)
Patch Set: Add comment to test Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..32b0de8a468c382596d02cfcdf342a5aa7c83900 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,34 @@ TEST_F(BookmarkButtonCellTest, OffTheSideCell) {
EXPECT_TRUE([[BookmarkButtonCell offTheSideButtonCell]
isKindOfClass:offTheSideButtonCellClass]);
}
+
+// Ensure the |cellWidthForNode:image:| class method reports the same
+// width as an instantiated cell with the same node and image.
+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);
+ [bookmark_cell setBookmarkNode:node_b image:image];
+ EXPECT_CGFLOAT_EQ([bookmark_cell cellSize].width, width_for_node_b);
+}
} // namespace
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698