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

Unified Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc

Issue 12386088: Add a shortcut to open the Apps page from the bookmark bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased and answered sky's comments. Created 7 years, 10 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
Index: chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..912ff74fe2cdf61ff57248a28ce1a7790a6b7de3
--- /dev/null
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
@@ -0,0 +1,72 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
+
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/browser/ui/search/search.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/base/browser_with_test_window_test.h"
+#include "ui/views/controls/button/text_button.h"
+
+typedef BrowserWithTestWindowTest BookmarkBarViewTest;
+
+// Verify that the apps shortcut is never visible without instant extended.
+TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) {
+ profile()->CreateBookmarkModel(true);
+ profile()->BlockUntilBookmarkModelLoaded();
+ BookmarkBarView bookmark_bar_view(browser(), NULL);
+ bookmark_bar_view.set_owned_by_client();
+ EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
+ browser()->profile()->GetPrefs()->SetBoolean(
+ prefs::kShowAppsShortcutInBookmarkBar, true);
+ EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
+}
+
+class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest {
+ public:
+ BookmarkBarViewInstantExtendedTest() {
+ chrome::search::EnableInstantExtendedAPIForTesting();
+ }
+
+ protected:
+ virtual TestingProfile* CreateProfile() OVERRIDE {
+ TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
+ // TemplateURLService is normally NULL during testing. Instant extended
+ // needs this service so set a custom factory function.
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
+ profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService);
+ return profile;
+ }
+
+ private:
+ static ProfileKeyedService* CreateTemplateURLService(Profile* profile) {
+ return new TemplateURLService(profile);
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest);
+};
+
+// Verify that in instant extended mode the visibility of the apps shortcut
+// button properly follows the pref value.
+TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) {
+ profile()->CreateBookmarkModel(true);
+ profile()->BlockUntilBookmarkModelLoaded();
+ BookmarkBarView bookmark_bar_view(browser(), NULL);
+ bookmark_bar_view.set_owned_by_client();
+ browser()->profile()->GetPrefs()->SetBoolean(
+ prefs::kShowAppsShortcutInBookmarkBar, false);
+ EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
+ browser()->profile()->GetPrefs()->SetBoolean(
+ prefs::kShowAppsShortcutInBookmarkBar, true);
+ EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());
+ // Make sure we can also properly transition from true to false.
+ browser()->profile()->GetPrefs()->SetBoolean(
+ prefs::kShowAppsShortcutInBookmarkBar, false);
+ EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
+}

Powered by Google App Engine
This is Rietveld 408576698