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

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

Issue 12310109: Add a shortcut to open the Apps page from the bookmark bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding the missing test file... Created 7 years, 10 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
tfarina 2013/02/26 19:27:51 no (c)
tfarina 2013/02/26 19:27:51 btw we already have bookmark_bar_view_test.cc! Ye
MAD 2013/02/26 20:55:53 Done.
MAD 2013/02/26 20:55:53 But the other one is in interactive_ui_tests, you
tfarina 2013/02/26 21:14:21 Ah, in that case I'd rename to _uitest.cc
MAD 2013/02/26 21:20:06 Do you want me to do it in this CL, or you'll do i
tfarina 2013/02/26 22:34:02 No, leave it to me. I'll consider doing it in anot
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 "base/prefs/pref_service.h"
6 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/search_engines/template_url_service.h"
8 #include "chrome/browser/search_engines/template_url_service_factory.h"
9 #include "chrome/browser/ui/search/search.h"
10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
tfarina 2013/02/26 19:27:51 make this the first include.
Alexei Svitkine (slow) 2013/02/26 19:32:30 No, that's incorrect - against the style guide in
tfarina 2013/02/26 19:35:26 No, actually we have been moving the other way aro
Alexei Svitkine (slow) 2013/02/26 19:48:24 Well, all the tests I've reviewed recently didn't
MAD 2013/02/26 20:55:53 Done.
11 #include "chrome/common/pref_names.h"
12 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/browser_with_test_window_test.h"
14
15 typedef BrowserWithTestWindowTest BookmarkBarViewTest;
16
tfarina 2013/02/26 19:27:51 can you wrap in unnamed namespace?
MAD 2013/02/26 20:55:53 If I do so, I can't set the test as friend of the
tfarina 2013/02/26 21:14:21 No, private is better, leave that way so ;)
17 // Verify that the apps shortcut is never visible without instant extended.
18 TEST_F(BookmarkBarViewTest, NoAppsShortcutWithoutInstantExtended) {
19 BookmarkBarView bookmark_bar_view(browser(), NULL);
20 bookmark_bar_view.set_owned_by_client();
21 EXPECT_FALSE(bookmark_bar_view.IsAppsShortcutVisible());
22 browser()->profile()->GetPrefs()->SetBoolean(
23 prefs::kShowAppsShortcutInBookmarkBar, true);
24 EXPECT_FALSE(bookmark_bar_view.IsAppsShortcutVisible());
25 }
26
27 class BookmarkBarViewInstantExtendedTest : public BrowserWithTestWindowTest {
28 public:
29 BookmarkBarViewInstantExtendedTest() {
30 chrome::search::EnableInstantExtendedAPIForTesting();
31 }
32
33 protected:
34 virtual TestingProfile* CreateProfile() OVERRIDE {
35 TestingProfile* profile = BrowserWithTestWindowTest::CreateProfile();
36 // TemplateURLService is normally NULL during testing. Instant extended
37 // needs this service so set a custom factory function.
38 TemplateURLServiceFactory::GetInstance()->SetTestingFactory(
39 profile, &BookmarkBarViewInstantExtendedTest::CreateTemplateURLService);
40 return profile;
41 }
42
43 private:
44 static ProfileKeyedService* CreateTemplateURLService(Profile* profile) {
45 return new TemplateURLService(profile);
46 }
47
48 DISALLOW_COPY_AND_ASSIGN(BookmarkBarViewInstantExtendedTest);
49 };
50
51 // Verify that in instant extended mode the visibility of the apps shortcut
52 // button properly follows the pref value.
53 TEST_F(BookmarkBarViewInstantExtendedTest, AppsShortcutVisibility) {
54 BookmarkBarView bookmark_bar_view(browser(), NULL);
55 bookmark_bar_view.set_owned_by_client();
56 browser()->profile()->GetPrefs()->SetBoolean(
57 prefs::kShowAppsShortcutInBookmarkBar, false);
58 EXPECT_FALSE(bookmark_bar_view.IsAppsShortcutVisible());
59 browser()->profile()->GetPrefs()->SetBoolean(
60 prefs::kShowAppsShortcutInBookmarkBar, true);
61 EXPECT_TRUE(bookmark_bar_view.IsAppsShortcutVisible());
Alexei Svitkine (slow) 2013/02/26 19:29:51 Nit: Set the bool to false again to make sure it c
MAD 2013/02/26 20:55:53 Done.
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698