| 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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
| 11 #include "chrome/browser/search_engines/template_url_service_factory.h" | 11 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/base/browser_with_test_window_test.h" | 14 #include "chrome/test/base/browser_with_test_window_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "ui/views/controls/button/text_button.h" | 16 #include "ui/views/controls/button/text_button.h" |
| 16 | 17 |
| 17 typedef BrowserWithTestWindowTest BookmarkBarViewTest; | 18 typedef BrowserWithTestWindowTest BookmarkBarViewTest; |
| 18 | 19 |
| 19 // Verify that the apps shortcut is never visible without instant extended. | 20 // Verify that the apps shortcut is never visible without instant extended. |
| 20 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) { | 21 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) { |
| 21 profile()->CreateBookmarkModel(true); | 22 profile()->CreateBookmarkModel(true); |
| 22 profile()->BlockUntilBookmarkModelLoaded(); | 23 ui_test_utils::WaitForBookmarkModelToLoad(profile()); |
| 23 BookmarkBarView bookmark_bar_view(browser(), NULL); | 24 BookmarkBarView bookmark_bar_view(browser(), NULL); |
| 24 bookmark_bar_view.set_owned_by_client(); | 25 bookmark_bar_view.set_owned_by_client(); |
| 25 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 26 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 26 browser()->profile()->GetPrefs()->SetBoolean( | 27 browser()->profile()->GetPrefs()->SetBoolean( |
| 27 prefs::kShowAppsShortcutInBookmarkBar, true); | 28 prefs::kShowAppsShortcutInBookmarkBar, true); |
| 28 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 29 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 29 } | 30 } |
| 30 | 31 |
| 31 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { | 32 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { |
| 32 public: | 33 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 return new TemplateURLService(profile); | 50 return new TemplateURLService(profile); |
| 50 } | 51 } |
| 51 | 52 |
| 52 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest); | 53 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 // Verify that in instant extended mode the visibility of the apps shortcut | 56 // Verify that in instant extended mode the visibility of the apps shortcut |
| 56 // button properly follows the pref value. | 57 // button properly follows the pref value. |
| 57 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) { | 58 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) { |
| 58 profile()->CreateBookmarkModel(true); | 59 profile()->CreateBookmarkModel(true); |
| 59 profile()->BlockUntilBookmarkModelLoaded(); | 60 ui_test_utils::WaitForBookmarkModelToLoad(profile()); |
| 60 BookmarkBarView bookmark_bar_view(browser(), NULL); | 61 BookmarkBarView bookmark_bar_view(browser(), NULL); |
| 61 bookmark_bar_view.set_owned_by_client(); | 62 bookmark_bar_view.set_owned_by_client(); |
| 62 browser()->profile()->GetPrefs()->SetBoolean( | 63 browser()->profile()->GetPrefs()->SetBoolean( |
| 63 prefs::kShowAppsShortcutInBookmarkBar, false); | 64 prefs::kShowAppsShortcutInBookmarkBar, false); |
| 64 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 65 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 65 browser()->profile()->GetPrefs()->SetBoolean( | 66 browser()->profile()->GetPrefs()->SetBoolean( |
| 66 prefs::kShowAppsShortcutInBookmarkBar, true); | 67 prefs::kShowAppsShortcutInBookmarkBar, true); |
| 67 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); | 68 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 68 // Make sure we can also properly transition from true to false. | 69 // Make sure we can also properly transition from true to false. |
| 69 browser()->profile()->GetPrefs()->SetBoolean( | 70 browser()->profile()->GetPrefs()->SetBoolean( |
| 70 prefs::kShowAppsShortcutInBookmarkBar, false); | 71 prefs::kShowAppsShortcutInBookmarkBar, false); |
| 71 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | 72 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); |
| 72 } | 73 } |
| OLD | NEW |