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