| 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 #include "base/memory/scoped_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // Subfolder arrow details. | 155 // Subfolder arrow details. |
| 156 TEST_F(BookmarkButtonCellTest, FolderArrow) { | 156 TEST_F(BookmarkButtonCellTest, FolderArrow) { |
| 157 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 157 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 158 const BookmarkNode* bar = model->bookmark_bar_node(); | 158 const BookmarkNode* bar = model->bookmark_bar_node(); |
| 159 const BookmarkNode* node = model->AddURL(bar, bar->child_count(), | 159 const BookmarkNode* node = model->AddURL(bar, bar->child_count(), |
| 160 ASCIIToUTF16("title"), | 160 ASCIIToUTF16("title"), |
| 161 GURL("http://www.google.com")); | 161 GURL("http://www.google.com")); |
| 162 scoped_nsobject<BookmarkButtonCell> cell( | 162 scoped_nsobject<BookmarkButtonCell> cell( |
| 163 [[BookmarkButtonCell alloc] initForNode:node | 163 [[BookmarkButtonCell alloc] initForNode:node |
| 164 menuController:nil | 164 text:@"small" |
| 165 cellText:@"small" | 165 image:nil |
| 166 cellImage:nil]); | 166 menuController:nil]); |
| 167 EXPECT_TRUE(cell.get()); | 167 EXPECT_TRUE(cell.get()); |
| 168 | 168 |
| 169 NSSize size = [cell cellSize]; | 169 NSSize size = [cell cellSize]; |
| 170 // sanity check | 170 // sanity check |
| 171 EXPECT_GE(size.width, 2); | 171 EXPECT_GE(size.width, 2); |
| 172 EXPECT_GE(size.height, 2); | 172 EXPECT_GE(size.height, 2); |
| 173 | 173 |
| 174 // Once we turn on arrow drawing make sure there is now room for it. | 174 // Once we turn on arrow drawing make sure there is now room for it. |
| 175 [cell setDrawFolderArrow:YES]; | 175 [cell setDrawFolderArrow:YES]; |
| 176 NSSize arrowSize = [cell cellSize]; | 176 NSSize arrowSize = [cell cellSize]; |
| 177 EXPECT_GT(arrowSize.width, size.width); | 177 EXPECT_GT(arrowSize.width, size.width); |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST_F(BookmarkButtonCellTest, VerticalTextOffset) { | 180 TEST_F(BookmarkButtonCellTest, VerticalTextOffset) { |
| 181 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 181 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 182 const BookmarkNode* bar = model->bookmark_bar_node(); | 182 const BookmarkNode* bar = model->bookmark_bar_node(); |
| 183 const BookmarkNode* node = model->AddURL(bar, bar->child_count(), | 183 const BookmarkNode* node = model->AddURL(bar, bar->child_count(), |
| 184 ASCIIToUTF16("title"), | 184 ASCIIToUTF16("title"), |
| 185 GURL("http://www.google.com")); | 185 GURL("http://www.google.com")); |
| 186 | 186 |
| 187 scoped_nsobject<GradientButtonCell> gradient_cell( | 187 scoped_nsobject<GradientButtonCell> gradient_cell( |
| 188 [[GradientButtonCell alloc] initTextCell:@"Testing"]); | 188 [[GradientButtonCell alloc] initTextCell:@"Testing"]); |
| 189 scoped_nsobject<BookmarkButtonCell> bookmark_cell( | 189 scoped_nsobject<BookmarkButtonCell> bookmark_cell( |
| 190 [[BookmarkButtonCell alloc] initForNode:node | 190 [[BookmarkButtonCell alloc] initForNode:node |
| 191 menuController:nil | 191 text:@"small" |
| 192 cellText:@"small" | 192 image:nil |
| 193 cellImage:nil]); | 193 menuController:nil]); |
| 194 | 194 |
| 195 ASSERT_TRUE(gradient_cell.get()); | 195 ASSERT_TRUE(gradient_cell.get()); |
| 196 ASSERT_TRUE(bookmark_cell.get()); | 196 ASSERT_TRUE(bookmark_cell.get()); |
| 197 | 197 |
| 198 EXPECT_EQ(1, [gradient_cell verticalTextOffset]); | 198 EXPECT_EQ(1, [gradient_cell verticalTextOffset]); |
| 199 EXPECT_EQ(0, [bookmark_cell verticalTextOffset]); | 199 EXPECT_EQ(0, [bookmark_cell verticalTextOffset]); |
| 200 | 200 |
| 201 EXPECT_NE([bookmark_cell verticalTextOffset], | 201 EXPECT_NE([bookmark_cell verticalTextOffset], |
| 202 [gradient_cell verticalTextOffset]); | 202 [gradient_cell verticalTextOffset]); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| OLD | NEW |