| 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> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/ptr_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/values.h" | 12 #include "base/values.h" |
| 11 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 15 #include "chrome/browser/ui/app_list/app_list_util.h" | 17 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 16 #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" |
| 17 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 18 #include "chrome/test/base/browser_with_test_window_test.h" | 20 #include "chrome/test/base/browser_with_test_window_test.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // BrowserWithTestWindowTest: | 114 // BrowserWithTestWindowTest: |
| 113 TestingProfile* CreateProfile() override { | 115 TestingProfile* CreateProfile() override { |
| 114 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); | 116 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); |
| 115 // TemplateURLService is normally NULL during testing. Instant extended | 117 // TemplateURLService is normally NULL during testing. Instant extended |
| 116 // needs this service so set a custom factory function. | 118 // needs this service so set a custom factory function. |
| 117 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | 119 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( |
| 118 profile, &BookmarkBarViewTest::CreateTemplateURLService); | 120 profile, &BookmarkBarViewTest::CreateTemplateURLService); |
| 119 return profile; | 121 return profile; |
| 120 } | 122 } |
| 121 | 123 |
| 122 scoped_ptr<BookmarkBarViewTestHelper> test_helper_; | 124 std::unique_ptr<BookmarkBarViewTestHelper> test_helper_; |
| 123 scoped_ptr<BookmarkBarView> bookmark_bar_view_; | 125 std::unique_ptr<BookmarkBarView> bookmark_bar_view_; |
| 124 | 126 |
| 125 private: | 127 private: |
| 126 static scoped_ptr<KeyedService> CreateTemplateURLService( | 128 static std::unique_ptr<KeyedService> CreateTemplateURLService( |
| 127 content::BrowserContext* profile) { | 129 content::BrowserContext* profile) { |
| 128 return make_scoped_ptr(new TemplateURLService( | 130 return base::WrapUnique( |
| 129 static_cast<Profile*>(profile)->GetPrefs(), | 131 new TemplateURLService(static_cast<Profile*>(profile)->GetPrefs(), |
| 130 make_scoped_ptr(new SearchTermsData), NULL, | 132 base::WrapUnique(new SearchTermsData), NULL, |
| 131 scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure())); | 133 std::unique_ptr<TemplateURLServiceClient>(), |
| 134 NULL, NULL, base::Closure())); |
| 132 } | 135 } |
| 133 | 136 |
| 134 scoped_ptr<ScopedTestingLocalState> local_state_; | 137 std::unique_ptr<ScopedTestingLocalState> local_state_; |
| 135 | 138 |
| 136 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewTest); | 139 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewTest); |
| 137 }; | 140 }; |
| 138 | 141 |
| 139 // Verify that in instant extended mode the visibility of the apps shortcut | 142 // Verify that in instant extended mode the visibility of the apps shortcut |
| 140 // button properly follows the pref value. | 143 // button properly follows the pref value. |
| 141 TEST_F(BookmarkBarViewTest, AppsShortcutVisibility) { | 144 TEST_F(BookmarkBarViewTest, AppsShortcutVisibility) { |
| 142 CreateBookmarkModelAndBookmarkBarView(); | 145 CreateBookmarkModelAndBookmarkBarView(); |
| 143 browser()->profile()->GetPrefs()->SetBoolean( | 146 browser()->profile()->GetPrefs()->SetBoolean( |
| 144 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false); | 147 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 348 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
| 346 new base::FundamentalValue(false)); | 349 new base::FundamentalValue(false)); |
| 347 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); | 350 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); |
| 348 | 351 |
| 349 // And try showing it via policy too. | 352 // And try showing it via policy too. |
| 350 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 353 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
| 351 new base::FundamentalValue(true)); | 354 new base::FundamentalValue(true)); |
| 352 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); | 355 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); |
| 353 } | 356 } |
| 354 #endif | 357 #endif |
| OLD | NEW |