| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 17 #include "chrome/browser/ui/app_list/app_list_util.h" | 17 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 18 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view_test_helper.h" | 18 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view_test_helper.h" |
| 19 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 20 #include "chrome/test/base/browser_with_test_window_test.h" | 20 #include "chrome/test/base/browser_with_test_window_test.h" |
| 21 #include "chrome/test/base/scoped_testing_local_state.h" | 21 #include "chrome/test/base/scoped_testing_local_state.h" |
| 22 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
| 23 #include "components/bookmarks/browser/bookmark_model.h" | 23 #include "components/bookmarks/browser/bookmark_model.h" |
| 24 #include "components/bookmarks/common/bookmark_pref_names.h" | 24 #include "components/bookmarks/common/bookmark_pref_names.h" |
| 25 #include "components/bookmarks/test/bookmark_test_helpers.h" | 25 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 26 #include "components/prefs/pref_service.h" | 26 #include "components/prefs/pref_service.h" |
| 27 #include "components/search_engines/search_terms_data.h" | 27 #include "components/search_engines/search_terms_data.h" |
| 28 #include "components/search_engines/template_url_service.h" | 28 #include "components/search_engines/template_url_service.h" |
| 29 #include "components/search_engines/template_url_service_client.h" | 29 #include "components/search_engines/template_url_service_client.h" |
| 30 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 30 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 31 #include "ui/views/controls/button/label_button.h" | 31 #include "ui/views/controls/button/label_button.h" |
| 32 #include "ui/views/controls/button/menu_button.h" | 32 #include "ui/views/controls/button/menu_button.h" |
| 33 | 33 |
| 34 using bookmarks::BookmarkModel; | 34 using bookmarks::BookmarkModel; |
| 35 using bookmarks::BookmarkNode; | 35 using bookmarks::BookmarkNode; |
| 36 | 36 |
| 37 class BookmarkBarViewTest : public BrowserWithTestWindowTest { | 37 class BookmarkBarViewTest : public BrowserWithTestWindowTest { |
| 38 public: | 38 public: |
| 39 BookmarkBarViewTest() {} | 39 BookmarkBarViewTest() {} |
| 40 | 40 |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 bookmark_bar_view_->Layout(); | 332 bookmark_bar_view_->Layout(); |
| 333 EXPECT_EQ("a1 b1 c d1 e f1", GetStringForVisibleButtons()); | 333 EXPECT_EQ("a1 b1 c d1 e f1", GetStringForVisibleButtons()); |
| 334 } | 334 } |
| 335 | 335 |
| 336 #if !defined(OS_CHROMEOS) | 336 #if !defined(OS_CHROMEOS) |
| 337 // Verifies that the apps shortcut is shown or hidden following the policy | 337 // Verifies that the apps shortcut is shown or hidden following the policy |
| 338 // value. This policy (and the apps shortcut) isn't present on ChromeOS. | 338 // value. This policy (and the apps shortcut) isn't present on ChromeOS. |
| 339 TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) { | 339 TEST_F(BookmarkBarViewTest, ManagedShowAppsShortcutInBookmarksBar) { |
| 340 CreateBookmarkModelAndBookmarkBarView(); | 340 CreateBookmarkModelAndBookmarkBarView(); |
| 341 // By default, the pref is not managed and the apps shortcut is shown. | 341 // By default, the pref is not managed and the apps shortcut is shown. |
| 342 syncable_prefs::TestingPrefServiceSyncable* prefs = | 342 sync_preferences::TestingPrefServiceSyncable* prefs = |
| 343 profile()->GetTestingPrefService(); | 343 profile()->GetTestingPrefService(); |
| 344 EXPECT_FALSE(prefs->IsManagedPreference( | 344 EXPECT_FALSE(prefs->IsManagedPreference( |
| 345 bookmarks::prefs::kShowAppsShortcutInBookmarkBar)); | 345 bookmarks::prefs::kShowAppsShortcutInBookmarkBar)); |
| 346 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); | 346 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); |
| 347 | 347 |
| 348 // Hide the apps shortcut by policy, via the managed pref. | 348 // Hide the apps shortcut by policy, via the managed pref. |
| 349 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 349 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
| 350 new base::FundamentalValue(false)); | 350 new base::FundamentalValue(false)); |
| 351 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); | 351 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); |
| 352 | 352 |
| 353 // And try showing it via policy too. | 353 // And try showing it via policy too. |
| 354 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 354 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
| 355 new base::FundamentalValue(true)); | 355 new base::FundamentalValue(true)); |
| 356 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); | 356 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); |
| 357 } | 357 } |
| 358 #endif | 358 #endif |
| OLD | NEW |