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

Side by Side 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: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/search_engines/template_url_service.h"
10 #include "chrome/browser/search_engines/template_url_service_factory.h"
11 #include "chrome/browser/ui/search/search.h"
12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/browser_with_test_window_test.h"
15
16 typedef BrowserWithTestWindowTest BookmarkBarViewTest;
17
18 // Verify that the apps shortcut is never visible without instant extended.
19 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) {
20 BookmarkBarView bookmark_bar_view(browser(), NULL);
21 bookmark_bar_view.set_owned_by_client();
22 EXPECT_FALSE(bookmark_bar_view.IsAppsShortcutVisibleForTesting());
23 browser()->profile()->GetPrefs()->SetBoolean(
24 prefs::kShowAppsShortcutInBookmarkBar, true);
25 EXPECT_FALSE(bookmark_bar_view.IsAppsShortcutVisibleForTesting());
26 }
27
28 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest {
29 public:
30 BookmarkBarViewInstantExtendedTest() {
31 chrome::search::EnableInstantExtendedAPIForTesting();
32 }
33
34 protected:
35 virtual TestingProfile* CreateProfile() OVERRIDE {
36 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
37 // TemplateURLService is normally NULL during testing. Instant extended
38 // needs this service so set a custom factory function.
39 TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
40 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService);
41 return profile;
42 }
43
44 private:
45 static ProfileKeyedService* CreateTemplateURLService(Profile* profile) {
46 return new TemplateURLService(profile);
47 }
48
49 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest);
50 };
51
52 // Verify that in instant extended mode the visibility of the apps shortcut
53 // button properly follows the pref value.
54 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) {
55 BookmarkBarView bookmark_bar_view(browser(), NULL);
56 bookmark_bar_view.set_owned_by_client();
57 browser()->profile()->GetPrefs()->SetBoolean(
58 prefs::kShowAppsShortcutInBookmarkBar, false);
59 EXPECT_FALSE(bookmark_bar_view.IsAppsShortcutVisibleForTesting());
60 browser()->profile()->GetPrefs()->SetBoolean(
61 prefs::kShowAppsShortcutInBookmarkBar, true);
62 EXPECT_TRUE(bookmark_bar_view.IsAppsShortcutVisibleForTesting());
63 // Make sure we can also properly transition from true to false.
64 browser()->profile()->GetPrefs()->SetBoolean(
65 prefs::kShowAppsShortcutInBookmarkBar, false);
66 EXPECT_FALSE(bookmark_bar_view.IsAppsShortcutVisibleForTesting());
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698