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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 ++i) { | 1545 ++i) { |
1546 NSRect frame = [[bar_ view] frame]; | 1546 NSRect frame = [[bar_ view] frame]; |
1547 frame.size.width = viewWidths[i] + bookmarks::kBookmarkRightMargin; | 1547 frame.size.width = viewWidths[i] + bookmarks::kBookmarkRightMargin; |
1548 [[bar_ view] setFrame:frame]; | 1548 [[bar_ view] setFrame:frame]; |
1549 EXPECT_EQ(offTheSideButtonIsHiddenResults[i], | 1549 EXPECT_EQ(offTheSideButtonIsHiddenResults[i], |
1550 [bar_ offTheSideButtonIsHidden]); | 1550 [bar_ offTheSideButtonIsHidden]); |
1551 EXPECT_EQ(displayedButtonCountResults[i], [bar_ displayedButtonCount]); | 1551 EXPECT_EQ(displayedButtonCountResults[i], [bar_ displayedButtonCount]); |
1552 } | 1552 } |
1553 } | 1553 } |
1554 | 1554 |
1555 class BookmarkBarControllerWithInstantExtendedTest : | 1555 TEST_F(BookmarkBarControllerTest, BookmarksWithAppsPageShortcut) { |
1556 public BookmarkBarControllerTest { | |
1557 public: | |
1558 virtual void AddCommandLineSwitches() OVERRIDE { | |
1559 CommandLine::ForCurrentProcess()->AppendSwitch( | |
1560 switches::kEnableInstantExtendedAPI); | |
1561 } | |
1562 }; | |
1563 | |
1564 TEST_F(BookmarkBarControllerWithInstantExtendedTest, | |
1565 BookmarksWithAppsPageShortcut) { | |
1566 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1556 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
1567 const BookmarkNode* root = model->bookmark_bar_node(); | 1557 const BookmarkNode* root = model->bookmark_bar_node(); |
1568 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); | 1558 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
1569 test::AddNodesFromModelString(model, root, model_string); | 1559 test::AddNodesFromModelString(model, root, model_string); |
1570 [bar_ frameDidChange]; | 1560 [bar_ frameDidChange]; |
1571 | 1561 |
1572 // Apps page shortcut button should be visible. | 1562 // Apps page shortcut button should be visible. |
1573 ASSERT_FALSE([bar_ appsPageShortcutButtonIsHidden]); | 1563 ASSERT_FALSE([bar_ appsPageShortcutButtonIsHidden]); |
1574 | 1564 |
1575 // Bookmarks should be to the right of the Apps page shortcut button. | 1565 // Bookmarks should be to the right of the Apps page shortcut button. |
1576 CGFloat apps_button_right = NSMaxX([[bar_ appsPageShortcutButton] frame]); | 1566 CGFloat apps_button_right = NSMaxX([[bar_ appsPageShortcutButton] frame]); |
1577 CGFloat right = apps_button_right; | 1567 CGFloat right = apps_button_right; |
1578 NSArray* buttons = [bar_ buttons]; | 1568 NSArray* buttons = [bar_ buttons]; |
1579 for (size_t i = 0; i < [buttons count]; ++i) { | 1569 for (size_t i = 0; i < [buttons count]; ++i) { |
1580 EXPECT_LE(right, NSMinX([[buttons objectAtIndex:i] frame])); | 1570 EXPECT_LE(right, NSMinX([[buttons objectAtIndex:i] frame])); |
1581 right = NSMaxX([[buttons objectAtIndex:i] frame]); | 1571 right = NSMaxX([[buttons objectAtIndex:i] frame]); |
1582 } | 1572 } |
1583 | 1573 |
1584 // Removing the Apps button should move every bookmark to the left. | 1574 // Removing the Apps button should move every bookmark to the left. |
1585 profile()->GetPrefs()->SetBoolean(prefs::kShowAppsShortcutInBookmarkBar, | 1575 profile()->GetPrefs()->SetBoolean(prefs::kShowAppsShortcutInBookmarkBar, |
1586 false); | 1576 false); |
1587 ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]); | 1577 ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]); |
1588 EXPECT_GT(apps_button_right, NSMinX([[buttons objectAtIndex:0] frame])); | 1578 EXPECT_GT(apps_button_right, NSMinX([[buttons objectAtIndex:0] frame])); |
1589 for (size_t i = 1; i < [buttons count]; ++i) { | 1579 for (size_t i = 1; i < [buttons count]; ++i) { |
1590 EXPECT_LE(NSMaxX([[buttons objectAtIndex:i - 1] frame]), | 1580 EXPECT_LE(NSMaxX([[buttons objectAtIndex:i - 1] frame]), |
1591 NSMinX([[buttons objectAtIndex:i] frame])); | 1581 NSMinX([[buttons objectAtIndex:i] frame])); |
1592 } | 1582 } |
1593 } | 1583 } |
1594 | 1584 |
1595 TEST_F(BookmarkBarControllerWithInstantExtendedTest, | 1585 TEST_F(BookmarkBarControllerTest, BookmarksWithoutAppsPageShortcut) { |
1596 BookmarksWithoutAppsPageShortcut) { | |
1597 // The no item containers should be to the right of the Apps button. | 1586 // The no item containers should be to the right of the Apps button. |
1598 ASSERT_FALSE([bar_ appsPageShortcutButtonIsHidden]); | 1587 ASSERT_FALSE([bar_ appsPageShortcutButtonIsHidden]); |
1599 CGFloat apps_button_right = NSMaxX([[bar_ appsPageShortcutButton] frame]); | 1588 CGFloat apps_button_right = NSMaxX([[bar_ appsPageShortcutButton] frame]); |
1600 EXPECT_LE(apps_button_right, | 1589 EXPECT_LE(apps_button_right, |
1601 NSMinX([[[bar_ buttonView] noItemTextfield] frame])); | 1590 NSMinX([[[bar_ buttonView] noItemTextfield] frame])); |
1602 EXPECT_LE(NSMaxX([[[bar_ buttonView] noItemTextfield] frame]), | 1591 EXPECT_LE(NSMaxX([[[bar_ buttonView] noItemTextfield] frame]), |
1603 NSMinX([[[bar_ buttonView] importBookmarksButton] frame])); | 1592 NSMinX([[[bar_ buttonView] importBookmarksButton] frame])); |
1604 | 1593 |
1605 // Removing the Apps button should move the no item containers to the left. | 1594 // Removing the Apps button should move the no item containers to the left. |
1606 profile()->GetPrefs()->SetBoolean(prefs::kShowAppsShortcutInBookmarkBar, | 1595 profile()->GetPrefs()->SetBoolean(prefs::kShowAppsShortcutInBookmarkBar, |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 "2f3b ] 4b "); | 2068 "2f3b ] 4b "); |
2080 actual = test::ModelStringFromNode(root); | 2069 actual = test::ModelStringFromNode(root); |
2081 EXPECT_EQ(expected, actual); | 2070 EXPECT_EQ(expected, actual); |
2082 | 2071 |
2083 // Verify that the other bookmark folder can't be deleted. | 2072 // Verify that the other bookmark folder can't be deleted. |
2084 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2073 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
2085 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2074 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
2086 } | 2075 } |
2087 | 2076 |
2088 } // namespace | 2077 } // namespace |
OLD | NEW |