| 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" | 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell.h" |
| 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" | 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
| 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h" | 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_unittest_helper.h" |
| 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 17 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 17 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
| 18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 19 #include "components/bookmarks/browser/bookmark_model.h" | 19 #include "components/bookmarks/browser/bookmark_model.h" |
| 20 #include "components/bookmarks/test/bookmark_test_helpers.h" | 20 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #import "testing/gtest_mac.h" | 22 #import "testing/gtest_mac.h" |
| 23 #include "testing/platform_test.h" | 23 #include "testing/platform_test.h" |
| 24 #include "ui/base/cocoa/animation_utils.h" | 24 #include "ui/base/cocoa/animation_utils.h" |
| 25 #include "ui/base/cocoa/cocoa_base_utils.h" | 25 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 26 #include "ui/base/material_design/material_design_controller.h" |
| 26 | 27 |
| 27 using base::ASCIIToUTF16; | 28 using base::ASCIIToUTF16; |
| 28 using bookmarks::BookmarkModel; | 29 using bookmarks::BookmarkModel; |
| 29 using bookmarks::BookmarkNode; | 30 using bookmarks::BookmarkNode; |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const int kLotsOfNodesCount = 150; | 34 const int kLotsOfNodesCount = 150; |
| 34 | 35 |
| 35 // Deletes the bookmark corresponding to |button|. | 36 // Deletes the bookmark corresponding to |button|. |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 CGFloat widthDelta = NSWidth(visibleFrame) - NSWidth(scrollFrame); | 1312 CGFloat widthDelta = NSWidth(visibleFrame) - NSWidth(scrollFrame); |
| 1312 | 1313 |
| 1313 CGFloat menuHeight = NSHeight(menuFrame); | 1314 CGFloat menuHeight = NSHeight(menuFrame); |
| 1314 EXPECT_CGFLOAT_EQ(expectedHeight, menuHeight); | 1315 EXPECT_CGFLOAT_EQ(expectedHeight, menuHeight); |
| 1315 CGFloat scrollerWidth = NSWidth(scrollFrame); | 1316 CGFloat scrollerWidth = NSWidth(scrollFrame); |
| 1316 button = [folderController buttonWithTitleEqualTo:@"a"]; | 1317 button = [folderController buttonWithTitleEqualTo:@"a"]; |
| 1317 CGFloat buttonWidth = NSWidth([button frame]); | 1318 CGFloat buttonWidth = NSWidth([button frame]); |
| 1318 EXPECT_CGFLOAT_EQ(scrollerWidth, buttonWidth); | 1319 EXPECT_CGFLOAT_EQ(scrollerWidth, buttonWidth); |
| 1319 CGFloat visibleWidth = NSWidth(visibleFrame); | 1320 CGFloat visibleWidth = NSWidth(visibleFrame); |
| 1320 EXPECT_CGFLOAT_EQ(visibleWidth - widthDelta, buttonWidth); | 1321 EXPECT_CGFLOAT_EQ(visibleWidth - widthDelta, buttonWidth); |
| 1321 EXPECT_LT(scrollerWidth, NSWidth([folderView frame])); | 1322 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 1323 EXPECT_CGFLOAT_EQ(scrollerWidth, NSWidth([folderView frame])); |
| 1324 } else { |
| 1325 EXPECT_LT(scrollerWidth, NSWidth([folderView frame])); |
| 1326 } |
| 1322 | 1327 |
| 1323 // Add a wider bookmark and make sure the button widths match. | 1328 // Add a wider bookmark and make sure the button widths match. |
| 1324 int reallyWideButtonNumber = folder->child_count(); | 1329 int reallyWideButtonNumber = folder->child_count(); |
| 1325 model->AddURL(folder, reallyWideButtonNumber, | 1330 model->AddURL(folder, reallyWideButtonNumber, |
| 1326 ASCIIToUTF16("A really, really, really, really, really, " | 1331 ASCIIToUTF16("A really, really, really, really, really, " |
| 1327 "really long name"), | 1332 "really long name"), |
| 1328 GURL("http://www.google.com/a")); | 1333 GURL("http://www.google.com/a")); |
| 1329 BookmarkButton* bigButton = | 1334 BookmarkButton* bigButton = |
| 1330 [folderController buttonWithTitleEqualTo: | 1335 [folderController buttonWithTitleEqualTo: |
| 1331 @"A really, really, really, really, really, really long name"]; | 1336 @"A really, really, really, really, really, really long name"]; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 DeleteBookmark([folder parentButton], profile()); | 1671 DeleteBookmark([folder parentButton], profile()); |
| 1667 EXPECT_FALSE([folder folderController]); | 1672 EXPECT_FALSE([folder folderController]); |
| 1668 } | 1673 } |
| 1669 | 1674 |
| 1670 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so | 1675 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so |
| 1671 // they are hard to test. Factor out "fire timers" into routines | 1676 // they are hard to test. Factor out "fire timers" into routines |
| 1672 // which can be overridden to fire immediately to make behavior | 1677 // which can be overridden to fire immediately to make behavior |
| 1673 // confirmable. | 1678 // confirmable. |
| 1674 // There is a similar problem with mouseEnteredButton: and | 1679 // There is a similar problem with mouseEnteredButton: and |
| 1675 // mouseExitedButton:. | 1680 // mouseExitedButton:. |
| OLD | NEW |