OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
6 #include "base/mac/scoped_nsobject.h" | 6 #include "base/mac/scoped_nsobject.h" |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 10 #include "chrome/browser/ui/cocoa/l10n_util.h" |
10 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" | 11 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
11 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" | 12 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" |
12 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
13 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
16 #include "ui/base/material_design/material_design_controller.h" | 17 #include "ui/base/material_design/material_design_controller.h" |
17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
19 #include "ui/resources/grit/ui_resources.h" | 20 #include "ui/resources/grit/ui_resources.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 [cell mouseExited:event]; | 151 [cell mouseExited:event]; |
151 EXPECT_EQ(button.get()->enters_, 1); | 152 EXPECT_EQ(button.get()->enters_, 1); |
152 EXPECT_EQ(button.get()->exits_, 3); | 153 EXPECT_EQ(button.get()->exits_, 3); |
153 } | 154 } |
154 | 155 |
155 // Confirms a cell created in a nib is initialized properly | 156 // Confirms a cell created in a nib is initialized properly |
156 TEST_F(BookmarkButtonCellTest, Awake) { | 157 TEST_F(BookmarkButtonCellTest, Awake) { |
157 base::scoped_nsobject<BookmarkButtonCell> cell( | 158 base::scoped_nsobject<BookmarkButtonCell> cell( |
158 [[BookmarkButtonCell alloc] init]); | 159 [[BookmarkButtonCell alloc] init]); |
159 [cell awakeFromNib]; | 160 [cell awakeFromNib]; |
160 EXPECT_EQ(NSLeftTextAlignment, [cell alignment]); | 161 EXPECT_EQ(NSNaturalTextAlignment, [cell alignment]); |
161 } | 162 } |
162 | 163 |
163 // Subfolder arrow details. | 164 // Subfolder arrow details. |
164 TEST_F(BookmarkButtonCellTest, FolderArrow) { | 165 TEST_F(BookmarkButtonCellTest, FolderArrow) { |
165 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); | 166 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
166 const BookmarkNode* bar = model->bookmark_bar_node(); | 167 const BookmarkNode* bar = model->bookmark_bar_node(); |
167 const BookmarkNode* node = model->AddURL(bar, bar->child_count(), | 168 const BookmarkNode* node = model->AddURL(bar, bar->child_count(), |
168 base::ASCIIToUTF16("title"), | 169 base::ASCIIToUTF16("title"), |
169 GURL("http://www.google.com")); | 170 GURL("http://www.google.com")); |
170 base::scoped_nsobject<BookmarkButtonCell> cell( | 171 base::scoped_nsobject<BookmarkButtonCell> cell( |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 base::scoped_nsobject<BookmarkButtonCell> bookmark_cell( | 240 base::scoped_nsobject<BookmarkButtonCell> bookmark_cell( |
240 [[BookmarkButtonCell alloc] initForNode:node_a | 241 [[BookmarkButtonCell alloc] initForNode:node_a |
241 text:nil | 242 text:nil |
242 image:image | 243 image:image |
243 menuController:nil]); | 244 menuController:nil]); |
244 EXPECT_CGFLOAT_EQ([bookmark_cell cellSize].width, width_for_node_a); | 245 EXPECT_CGFLOAT_EQ([bookmark_cell cellSize].width, width_for_node_a); |
245 [bookmark_cell setBookmarkNode:node_b image:image]; | 246 [bookmark_cell setBookmarkNode:node_b image:image]; |
246 EXPECT_CGFLOAT_EQ([bookmark_cell cellSize].width, width_for_node_b); | 247 EXPECT_CGFLOAT_EQ([bookmark_cell cellSize].width, width_for_node_b); |
247 } | 248 } |
248 } // namespace | 249 } // namespace |
OLD | NEW |