Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up test. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/apps/app_launcher_util.h" 8 #include "chrome/browser/apps/app_launcher_util.h"
9 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" 9 #include "chrome/browser/bookmarks/bookmark_test_helpers.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search/search.h"
12 #include "chrome/browser/search_engines/template_url_service.h" 11 #include "chrome/browser/search_engines/template_url_service.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h" 12 #include "chrome/browser/search_engines/template_url_service_factory.h"
14 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/browser_with_test_window_test.h" 15 #include "chrome/test/base/browser_with_test_window_test.h"
17 #include "chrome/test/base/scoped_testing_local_state.h" 16 #include "chrome/test/base/scoped_testing_local_state.h"
18 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
19 #include "ui/views/controls/button/text_button.h" 18 #include "ui/views/controls/button/text_button.h"
20 19
21 typedef BrowserWithTestWindowTest BookmarkBarViewTest; 20 typedef BrowserWithTestWindowTest BookmarkBarViewTest;
22 21
23 // Verify that the apps shortcut is never visible without instant extended. 22 // Verify that the apps shortcut is never visible without instant extended.
24 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) { 23 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) {
25 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal()); 24 ScopedTestingLocalState local_state(TestingBrowserProcess::GetGlobal());
26 profile()->CreateBookmarkModel(true); 25 profile()->CreateBookmarkModel(true);
27 test::WaitForBookmarkModelToLoad(profile()); 26 test::WaitForBookmarkModelToLoad(profile());
28 BookmarkBarView bookmark_bar_view(browser(), NULL); 27 BookmarkBarView bookmark_bar_view(browser(), NULL);
29 bookmark_bar_view.set_owned_by_client(); 28 bookmark_bar_view.set_owned_by_client();
30 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 29 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
31 browser()->profile()->GetPrefs()->SetBoolean( 30 browser()->profile()->GetPrefs()->SetBoolean(
32 prefs::kShowAppsShortcutInBookmarkBar, true); 31 prefs::kShowAppsShortcutInBookmarkBar, true);
33 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 32 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
34 } 33 }
35 34
36 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { 35 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest {
37 public: 36 public:
38 BookmarkBarViewInstantExtendedTest() { 37 BookmarkBarViewInstantExtendedTest() {
39 chrome::EnableInstantExtendedAPIForTesting();
40 } 38 }
41 39
42 protected: 40 protected:
43 virtual TestingProfile* CreateProfile() OVERRIDE { 41 virtual TestingProfile* CreateProfile() OVERRIDE {
44 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); 42 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
45 // TemplateURLService is normally NULL during testing. Instant extended 43 // TemplateURLService is normally NULL during testing. Instant extended
46 // needs this service so set a custom factory function. 44 // needs this service so set a custom factory function.
47 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( 45 TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
48 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService); 46 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService);
49 return profile; 47 return profile;
(...skipping 28 matching lines...) Expand all
78 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 76 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
79 } else { 77 } else {
80 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); 78 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible());
81 } 79 }
82 80
83 // Make sure we can also properly transition from true to false. 81 // Make sure we can also properly transition from true to false.
84 browser()->profile()->GetPrefs()->SetBoolean( 82 browser()->profile()->GetPrefs()->SetBoolean(
85 prefs::kShowAppsShortcutInBookmarkBar, false); 83 prefs::kShowAppsShortcutInBookmarkBar, false);
86 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); 84 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible());
87 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698