OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | |
6 | |
7 #include "base/prefs/pref_service.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/search_engines/template_url_service.h" | |
10 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
11 #include "chrome/browser/ui/search/search.h" | |
12 #include "chrome/common/pref_names.h" | |
13 #include "chrome/common/url_constants.h" | |
14 #include "chrome/test/base/browser_with_test_window_test.h" | |
15 #include "ui/views/controls/button/text_button.h" | |
16 | |
17 typedef BrowserWithTestWindowTest BookmarkBarViewTest; | |
18 | |
19 // Verify that the apps shortcut is never visible without instant extended. | |
20 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) { | |
21 BookmarkBarView bookmark_bar_view(browser(), NULL); | |
sky
2013/03/05 01:42:58
You should make this tests block until the bookmar
beaudoin
2013/03/05 16:13:18
Looks like the test does not really need a bookmar
| |
22 bookmark_bar_view.set_owned_by_client(); | |
23 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
24 browser()->profile()->GetPrefs()->SetBoolean( | |
25 prefs::kShowAppsShortcutInBookmarkBar, true); | |
26 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
27 } | |
28 | |
29 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest { | |
30 public: | |
31 BookmarkBarViewInstantExtendedTest() { | |
32 chrome::search::EnableInstantExtendedAPIForTesting(); | |
33 } | |
34 | |
35 protected: | |
36 virtual TestingProfile* CreateProfile() OVERRIDE { | |
37 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile(); | |
38 // TemplateURLService is normally NULL during testing. Instant extended | |
39 // needs this service so set a custom factory function. | |
40 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | |
41 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService); | |
42 return profile; | |
43 } | |
44 | |
45 private: | |
46 static ProfileKeyedService* CreateTemplateURLService(Profile* profile) { | |
47 return new TemplateURLService(profile); | |
48 } | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest); | |
51 }; | |
52 | |
53 // Verify that in instant extended mode the visibility of the apps shortcut | |
54 // button properly follows the pref value. | |
55 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) { | |
56 BookmarkBarView bookmark_bar_view(browser(), NULL); | |
57 bookmark_bar_view.set_owned_by_client(); | |
58 browser()->profile()->GetPrefs()->SetBoolean( | |
59 prefs::kShowAppsShortcutInBookmarkBar, false); | |
60 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
61 browser()->profile()->GetPrefs()->SetBoolean( | |
62 prefs::kShowAppsShortcutInBookmarkBar, true); | |
63 EXPECT_TRUE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
64 // Make sure we can also properly transition from true to false. | |
65 browser()->profile()->GetPrefs()->SetBoolean( | |
66 prefs::kShowAppsShortcutInBookmarkBar, false); | |
67 EXPECT_FALSE(bookmark_bar_view.apps_page_shortcut_->visible()); | |
68 } | |
OLD | NEW |