Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1618)

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm

Issue 14262013: On Mac, ensure messages displayed in the bookmark bar do not overlap with the Apps bookmark button. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Answered comments, added tests. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
index c96fe37d757d385e0ad236bc8142078a02d0e3ec..e500c0c52e5e059a3ecdfdc3c8478ff3d8620bdf 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm
@@ -25,6 +25,8 @@
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#import "chrome/browser/ui/cocoa/view_resizer_pong.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/model_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
@@ -339,6 +341,7 @@ class BookmarkBarControllerTest : public BookmarkBarControllerTestBase {
virtual void SetUp() {
BookmarkBarControllerTestBase::SetUp();
ASSERT_TRUE(browser());
+ AddCommandLineSwitches();
bar_.reset(
[[BookmarkBarControllerNoOpen alloc]
@@ -350,6 +353,8 @@ class BookmarkBarControllerTest : public BookmarkBarControllerTestBase {
InstallAndToggleBar(bar_.get());
}
+ virtual void AddCommandLineSwitches() {}
+
BookmarkBarControllerNoOpen* noOpenBar() {
return (BookmarkBarControllerNoOpen*)bar_.get();
}
@@ -1542,6 +1547,66 @@ TEST_F(BookmarkBarControllerTest, LastBookmarkResizeBehavior) {
}
}
+class BookmarkBarControllerWithInstantExtendedTest :
+ public BookmarkBarControllerTest {
+ public:
+ virtual void AddCommandLineSwitches() {
Alexei Svitkine (slow) 2013/04/16 16:29:13 Nit: OVERRIDE
beaudoin 2013/04/16 20:49:56 Done.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableInstantExtendedAPI);
+ }
+};
+
+TEST_F(BookmarkBarControllerWithInstantExtendedTest,
+ BookmarksWithAppsPageShortcut) {
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile());
+ const BookmarkNode* root = model->bookmark_bar_node();
+ const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b ");
+ model_test_utils::AddNodesFromModelString(model, root, model_string);
+ [bar_ frameDidChange];
+
+ // Apps page shortcut button should be visible.
+ ASSERT_FALSE([bar_ appsPageShortcutButtonIsHidden]);
+
+ // Bookmarks should be to the right of the Apps page shortcut button.
+ CGFloat apps_button_right = NSMaxX([[bar_ appsPageShortcutButton] frame]);
+ CGFloat right = apps_button_right;
+ NSArray* buttons = [bar_ buttons];
+ for (size_t i = 0; i < [buttons count]; ++i) {
+ EXPECT_LE(right, NSMinX([[buttons objectAtIndex:i] frame]));
+ right = NSMaxX([[buttons objectAtIndex:i] frame]);
+ }
+
+ // Removing the Apps button should move every bookmark to the left.
+ profile()->GetPrefs()->SetBoolean(prefs::kShowAppsShortcutInBookmarkBar,
+ false);
+ ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]);
+ EXPECT_GT(apps_button_right, NSMinX([[buttons objectAtIndex:0] frame]));
+ for (size_t i = 1; i < [buttons count]; ++i) {
+ EXPECT_LE(NSMaxX([[buttons objectAtIndex:i - 1] frame]),
+ NSMinX([[buttons objectAtIndex:i] frame]));
+ }
+}
+
+TEST_F(BookmarkBarControllerWithInstantExtendedTest,
+ BookmarksWithoutAppsPageShortcut) {
+ // The no item containers should be to the right of the Apps button.
+ ASSERT_FALSE([bar_ appsPageShortcutButtonIsHidden]);
+ CGFloat apps_button_right = NSMaxX([[bar_ appsPageShortcutButton] frame]);
+ EXPECT_LE(apps_button_right,
+ NSMinX([[[bar_ buttonView] noItemTextfield] frame]));
+ EXPECT_LE(NSMaxX([[[bar_ buttonView] noItemTextfield] frame]),
+ NSMinX([[[bar_ buttonView] importBookmarksButton] frame]));
+
+ // Removing the Apps button should move the no item containers to the left.
+ profile()->GetPrefs()->SetBoolean(prefs::kShowAppsShortcutInBookmarkBar,
+ false);
+ ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]);
+ EXPECT_GT(apps_button_right,
+ NSMinX([[[bar_ buttonView] noItemTextfield] frame]));
+ EXPECT_LE(NSMaxX([[[bar_ buttonView] noItemTextfield] frame]),
+ NSMinX([[[bar_ buttonView] importBookmarksButton] frame]));
+}
+
class BookmarkBarControllerOpenAllTest : public BookmarkBarControllerTest {
public:
virtual void SetUp() {
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698