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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc

Issue 490123003: Move bookmark_pref_names.* into bookmarks namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Verify that in instant extended mode the visibility of the apps shortcut 52 // Verify that in instant extended mode the visibility of the apps shortcut
53 // button properly follows the pref value. 53 // button properly follows the pref value.
54 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) { 54 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) {
55 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); 55 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
56 profile()->CreateBookmarkModel(true); 56 profile()->CreateBookmarkModel(true);
57 test::WaitForBookmarkModelToLoad( 57 test::WaitForBookmarkModelToLoad(
58 BookmarkModelFactory::GetForProfile(profile())); 58 BookmarkModelFactory::GetForProfile(profile()));
59 BookmarkBarView bookmark_bar_view(browser(), NULL); 59 BookmarkBarView bookmark_bar_view(browser(), NULL);
60 bookmark_bar_view.set_owned_by_client(); 60 bookmark_bar_view.set_owned_by_client();
61 browser()->profile()->GetPrefs()->SetBoolean( 61 browser()->profile()->GetPrefs()->SetBoolean(
62 prefs::kShowAppsShortcutInBookmarkBar, false); 62 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false);
63 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 63 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
64 64
65 // Try to make the Apps shortcut visible. Its visibility depends on whether 65 // Try to make the Apps shortcut visible. Its visibility depends on whether
66 // the app launcher is enabled. 66 // the app launcher is enabled.
67 browser()->profile()->GetPrefs()->SetBoolean( 67 browser()->profile()->GetPrefs()->SetBoolean(
68 prefs::kShowAppsShortcutInBookmarkBar, true); 68 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, true);
69 if (IsAppLauncherEnabled()) { 69 if (IsAppLauncherEnabled()) {
70 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 70 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
71 } else { 71 } else {
72 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); 72 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());
73 } 73 }
74 74
75 // Make sure we can also properly transition from true to false. 75 // Make sure we can also properly transition from true to false.
76 browser()->profile()->GetPrefs()->SetBoolean( 76 browser()->profile()->GetPrefs()->SetBoolean(
77 prefs::kShowAppsShortcutInBookmarkBar, false); 77 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false);
78 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 78 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
79 } 79 }
80 80
81 #if !defined(OS_CHROMEOS) 81 #if !defined(OS_CHROMEOS)
82 typedef BrowserWithTestWindowTest BookmarkBarViewTest; 82 typedef BrowserWithTestWindowTest BookmarkBarViewTest;
83 83
84 // Verifies that the apps shortcut is shown or hidden following the policy 84 // Verifies that the apps shortcut is shown or hidden following the policy
85 // value. This policy (and the apps shortcut) isn't present on ChromeOS. 85 // value. This policy (and the apps shortcut) isn't present on ChromeOS.
86 TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) { 86 TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) {
87 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); 87 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
88 profile()->CreateBookmarkModel(true); 88 profile()->CreateBookmarkModel(true);
89 test::WaitForBookmarkModelToLoad( 89 test::WaitForBookmarkModelToLoad(
90 BookmarkModelFactory::GetForProfile(profile())); 90 BookmarkModelFactory::GetForProfile(profile()));
91 BookmarkBarView bookmark_bar_view(browser(), NULL); 91 BookmarkBarView bookmark_bar_view(browser(), NULL);
92 bookmark_bar_view.set_owned_by_client(); 92 bookmark_bar_view.set_owned_by_client();
93 93
94 // By default, the pref is not managed and the apps shortcut is shown. 94 // By default, the pref is not managed and the apps shortcut is shown.
95 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); 95 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService();
96 EXPECT_FALSE( 96 EXPECT_FALSE(prefs->IsManagedPreference(
97 prefs->IsManagedPreference(prefs::kShowAppsShortcutInBookmarkBar)); 97 bookmarks::prefs::kShowAppsShortcutInBookmarkBar));
98 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); 98 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());
99 99
100 // Hide the apps shortcut by policy, via the managed pref. 100 // Hide the apps shortcut by policy, via the managed pref.
101 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, 101 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar,
102 new base::FundamentalValue(false)); 102 new base::FundamentalValue(false));
103 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 103 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
104 104
105 // And try showing it via policy too. 105 // And try showing it via policy too.
106 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, 106 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar,
107 new base::FundamentalValue(true)); 107 new base::FundamentalValue(true));
108 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); 108 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());
109 } 109 }
110 #endif 110 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698