| 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_test_helpers.h" | 8 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 10 #include "chrome/browser/search/search.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_factory.h" | 12 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 13 #include "chrome/browser/ui/app_list/app_list_util.h" | 13 #include "chrome/browser/ui/app_list/app_list_util.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/test/base/browser_with_test_window_test.h" | 16 #include "chrome/test/base/browser_with_test_window_test.h" |
| 17 #include "chrome/test/base/scoped_testing_local_state.h" | 17 #include "chrome/test/base/scoped_testing_local_state.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "ui/views/controls/button/text_button.h" | 19 #include "ui/views/controls/button/text_button.h" |
| 20 | 20 |
| 21 typedef BrowserWithTestWindowTest BookmarkBarViewTest; | 21 typedef BrowserWithTestWindowTest BookmarkBarViewTest; |
| 22 | 22 |
| 23 // Verify that the apps shortcut is never visible without instant extended. | |
| 24 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) { | |
| 25 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); | |
| 26 profile()->CreateBookmarkModel(true); | |
| 27 test::WaitForBookmarkModelToLoad(profile()); | |
| 28 BookmarkBarView bookmark_bar_view(browser(), NULL); | |
| 29 bookmark_bar_view.set_owned_by_client(); | |
| 30 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
| 31 browser()->profile()->GetPrefs()->SetBoolean( | |
| 32 prefs::kShowAppsShortcutInBookmarkBar, true); | |
| 33 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
| 34 } | |
| 35 | |
| 36 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { | 23 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { |
| 37 public: | 24 public: |
| 38 BookmarkBarViewInstantExtendedTest() { | 25 BookmarkBarViewInstantExtendedTest() { |
| 39 chrome::EnableInstantExtendedAPIForTesting(); | |
| 40 } | 26 } |
| 41 | 27 |
| 42 protected: | 28 protected: |
| 43 virtual TestingProfile* CreateProfile() OVERRIDE { | 29 virtual TestingProfile* CreateProfile() OVERRIDE { |
| 44 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); | 30 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); |
| 45 // TemplateURLService is normally NULL during testing. Instant extended | 31 // TemplateURLService is normally NULL during testing. Instant extended |
| 46 // needs this service so set a custom factory function. | 32 // needs this service so set a custom factory function. |
| 47 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | 33 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( |
| 48 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService); | 34 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService); |
| 49 return profile; | 35 return profile; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 78 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 64 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 79 } else { | 65 } else { |
| 80 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); | 66 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 81 } | 67 } |
| 82 | 68 |
| 83 // Make sure we can also properly transition from true to false. | 69 // Make sure we can also properly transition from true to false. |
| 84 browser()->profile()->GetPrefs()->SetBoolean( | 70 browser()->profile()->GetPrefs()->SetBoolean( |
| 85 prefs::kShowAppsShortcutInBookmarkBar, false); | 71 prefs::kShowAppsShortcutInBookmarkBar, false); |
| 86 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 72 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 87 } | 73 } |
| OLD | NEW |