| 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 "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" |
| 11 #include "chrome/browser/search_engines/template_url_service.h" | 11 #include "chrome/browser/search_engines/template_url_service.h" |
| 12 #include "chrome/browser/search_engines/template_url_service_client.h" |
| 12 #include "chrome/browser/search_engines/template_url_service_factory.h" | 13 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 13 #include "chrome/browser/ui/app_list/app_list_util.h" | 14 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/test/base/browser_with_test_window_test.h" | 17 #include "chrome/test/base/browser_with_test_window_test.h" |
| 17 #include "chrome/test/base/scoped_testing_local_state.h" | 18 #include "chrome/test/base/scoped_testing_local_state.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chrome/test/base/testing_pref_service_syncable.h" | 20 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 20 #include "components/bookmarks/test/bookmark_test_helpers.h" | 21 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 22 #include "components/search_engines/search_terms_data.h" |
| 21 #include "ui/views/controls/button/label_button.h" | 23 #include "ui/views/controls/button/label_button.h" |
| 22 | 24 |
| 23 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { | 25 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { |
| 24 public: | 26 public: |
| 25 BookmarkBarViewInstantExtendedTest() { | 27 BookmarkBarViewInstantExtendedTest() { |
| 26 } | 28 } |
| 27 | 29 |
| 28 protected: | 30 protected: |
| 29 virtual TestingProfile* CreateProfile() OVERRIDE { | 31 virtual TestingProfile* CreateProfile() OVERRIDE { |
| 30 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); | 32 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); |
| 31 // TemplateURLService is normally NULL during testing. Instant extended | 33 // TemplateURLService is normally NULL during testing. Instant extended |
| 32 // needs this service so set a custom factory function. | 34 // needs this service so set a custom factory function. |
| 33 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | 35 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( |
| 34 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService); | 36 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService); |
| 35 return profile; | 37 return profile; |
| 36 } | 38 } |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 static KeyedService* CreateTemplateURLService( | 41 static KeyedService* CreateTemplateURLService( |
| 40 content::BrowserContext* profile) { | 42 content::BrowserContext* profile) { |
| 41 return new TemplateURLService(static_cast<Profile*>(profile), NULL, | 43 return new TemplateURLService( |
| 42 base::Closure()); | 44 static_cast<Profile*>(profile)->GetPrefs(), |
| 45 make_scoped_ptr(new SearchTermsData), NULL, |
| 46 scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure()); |
| 43 } | 47 } |
| 44 | 48 |
| 45 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest); | 49 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest); |
| 46 }; | 50 }; |
| 47 | 51 |
| 48 // 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 |
| 49 // button properly follows the pref value. | 53 // button properly follows the pref value. |
| 50 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) { | 54 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) { |
| 51 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); | 55 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); |
| 52 profile()->CreateBookmarkModel(true); | 56 profile()->CreateBookmarkModel(true); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, | 101 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, |
| 98 new base::FundamentalValue(false)); | 102 new base::FundamentalValue(false)); |
| 99 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 103 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 100 | 104 |
| 101 // And try showing it via policy too. | 105 // And try showing it via policy too. |
| 102 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, | 106 prefs->SetManagedPref(prefs::kShowAppsShortcutInBookmarkBar, |
| 103 new base::FundamentalValue(true)); | 107 new base::FundamentalValue(true)); |
| 104 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); | 108 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 105 } | 109 } |
| 106 #endif | 110 #endif |
| OLD | NEW |