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/memory/scoped_ptr.h" |
7 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.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/browser/ui/views/bookmarks/bookmark_bar_view_test_helper.h" | 15 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view_test_helper.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // needs this service so set a custom factory function. | 118 // needs this service so set a custom factory function. |
118 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | 119 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( |
119 profile, &BookmarkBarViewTest::CreateTemplateURLService); | 120 profile, &BookmarkBarViewTest::CreateTemplateURLService); |
120 return profile; | 121 return profile; |
121 } | 122 } |
122 | 123 |
123 scoped_ptr<BookmarkBarViewTestHelper> test_helper_; | 124 scoped_ptr<BookmarkBarViewTestHelper> test_helper_; |
124 scoped_ptr<BookmarkBarView> bookmark_bar_view_; | 125 scoped_ptr<BookmarkBarView> bookmark_bar_view_; |
125 | 126 |
126 private: | 127 private: |
127 static KeyedService* CreateTemplateURLService( | 128 static scoped_ptr<KeyedService> CreateTemplateURLService( |
128 content::BrowserContext* profile) { | 129 content::BrowserContext* profile) { |
129 return new TemplateURLService( | 130 return make_scoped_ptr(new TemplateURLService( |
130 static_cast<Profile*>(profile)->GetPrefs(), | 131 static_cast<Profile*>(profile)->GetPrefs(), |
131 make_scoped_ptr(new SearchTermsData), NULL, | 132 make_scoped_ptr(new SearchTermsData), NULL, |
132 scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure()); | 133 scoped_ptr<TemplateURLServiceClient>(), NULL, NULL, base::Closure())); |
133 } | 134 } |
134 | 135 |
135 scoped_ptr<ScopedTestingLocalState> local_state_; | 136 scoped_ptr<ScopedTestingLocalState> local_state_; |
136 | 137 |
137 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewTest); | 138 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewTest); |
138 }; | 139 }; |
139 | 140 |
140 // Verify that in instant extended mode the visibility of the apps shortcut | 141 // Verify that in instant extended mode the visibility of the apps shortcut |
141 // button properly follows the pref value. | 142 // button properly follows the pref value. |
142 TEST_F(BookmarkBarViewTest, AppsShortcutVisibility) { | 143 TEST_F(BookmarkBarViewTest, AppsShortcutVisibility) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 357 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
357 new base::FundamentalValue(false)); | 358 new base::FundamentalValue(false)); |
358 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); | 359 EXPECT_FALSE(test_helper_->apps_page_shortcut()->visible()); |
359 | 360 |
360 // And try showing it via policy too. | 361 // And try showing it via policy too. |
361 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 362 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
362 new base::FundamentalValue(true)); | 363 new base::FundamentalValue(true)); |
363 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); | 364 EXPECT_TRUE(test_helper_->apps_page_shortcut()->visible()); |
364 } | 365 } |
365 #endif | 366 #endif |
OLD | NEW |