OLD | NEW |
---|---|
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 "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
11 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
12 #include "chrome/browser/ui/app_list/app_list_util.h" | 12 #include "chrome/browser/ui/app_list/app_list_util.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/base/browser_with_test_window_test.h" | 15 #include "chrome/test/base/browser_with_test_window_test.h" |
16 #include "chrome/test/base/scoped_testing_local_state.h" | 16 #include "chrome/test/base/scoped_testing_local_state.h" |
17 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
18 #include "chrome/test/base/testing_pref_service_syncable.h" | |
18 #include "components/bookmarks/test/bookmark_test_helpers.h" | 19 #include "components/bookmarks/test/bookmark_test_helpers.h" |
19 #include "ui/views/controls/button/text_button.h" | 20 #include "ui/views/controls/button/text_button.h" |
20 | 21 |
21 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { | 22 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { |
22 public: | 23 public: |
23 BookmarkBarViewInstantExtendedTest() { | 24 BookmarkBarViewInstantExtendedTest() { |
24 } | 25 } |
25 | 26 |
26 protected: | 27 protected: |
27 virtual TestingProfile* CreateProfile() OVERRIDE { | 28 virtual TestingProfile* CreateProfile() OVERRIDE { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 64 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
64 } else { | 65 } else { |
65 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); | 66 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); |
66 } | 67 } |
67 | 68 |
68 // Make sure we can also properly transition from true to false. | 69 // Make sure we can also properly transition from true to false. |
69 browser()->profile()->GetPrefs()->SetBoolean( | 70 browser()->profile()->GetPrefs()->SetBoolean( |
70 prefs::kShowAppsShortcutInBookmarkBar, false); | 71 prefs::kShowAppsShortcutInBookmarkBar, false); |
71 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 72 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
72 } | 73 } |
74 | |
75 class BookmarkBarViewTest : public BrowserWithTestWindowTest { | |
sky
2014/06/03 23:08:50
Move this inside ifdef. Also, we typically use a t
Joao da Silva
2014/06/04 11:13:42
Done.
| |
76 }; | |
77 | |
78 #if !defined(OS_CHROMEOS) | |
79 // Verifies that the apps shortcut is shown or hidden following the policy | |
80 // value. This policy (and the apps shortcut) isn't present on ChromeOS. | |
81 TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) { | |
82 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); | |
83 profile()->CreateBookmarkModel(true); | |
84 test::WaitForBookmarkModelToLoad( | |
85 BookmarkModelFactory::GetForProfile(profile())); | |
86 BookmarkBarView bookmark_bar_view(browser(), NULL); | |
87 bookmark_bar_view.set_owned_by_client(); | |
88 | |
89 // By default the pref is not managed and the apps shortcut is shown. | |
bartfab (slow)
2014/06/04 10:55:20
Nit: s/default/default,/
Joao da Silva
2014/06/04 11:13:42
Done.
| |
90 TestingPrefServiceSyncable* prefs = profile()->GetTestingPrefService(); | |
91 EXPECT_FALSE( | |
92 prefs->IsManagedPreference(prefs::kShowAppsShortcutInBookmarkBar)); | |
93 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
94 | |
95 // Hide the apps shortcut by policy, via the managed pref. | |
96 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, | |
97 new base::FundamentalValue(false)); | |
bartfab (slow)
2014/06/04 10:55:20
Nit: #include "base/values.h"
Joao da Silva
2014/06/04 11:13:42
Done.
| |
98 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
99 | |
100 // And try showing it via policy too. | |
101 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, | |
102 new base::FundamentalValue(true)); | |
103 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
104 } | |
105 #endif | |
OLD | NEW |