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

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

Issue 18603006: Bookmark sync promo for Views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Common layout constants Created 7 years, 5 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
OLDNEW
(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_bubble_view.h"
6
7 #include <string>
8
9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/bookmarks/bookmark_utils.h"
13 #include "chrome/browser/signin/fake_signin_manager.h"
14 #include "chrome/browser/signin/signin_manager.h"
15 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/test/base/browser_with_test_window_test.h"
18 #include "chrome/test/base/ui_test_utils.h"
19
20 namespace {
21 const char kTestBookmarkURL[] = "http://www.google.com";
22 } // namespace
23
24 class BookmarkBubbleViewTest : public BrowserWithTestWindowTest {
25 public:
26 BookmarkBubbleViewTest() {}
27
28 // testing::Test:
29 virtual void SetUp() OVERRIDE {
30 BrowserWithTestWindowTest::SetUp();
31
32 CommandLine* command_line = CommandLine::ForCurrentProcess();
33 command_line->AppendSwitch(switches::kEnableBookmarkSyncPromo);
34
35 profile()->CreateBookmarkModel(true);
36 ui_test_utils::WaitForBookmarkModelToLoad(profile());
37
38 bookmark_utils::AddIfNotBookmarked(
39 BookmarkModelFactory::GetForProfile(profile()),
40 GURL(kTestBookmarkURL),
41 string16());
42 }
43
44 virtual void TearDown() OVERRIDE {
45 // Make sure the bubble is destroyed before the profile to avoid a crash.
46 bubble_.reset();
47
48 BrowserWithTestWindowTest::TearDown();
49 }
50
51 protected:
52 // Creates a bookmark bubble view.
53 void CreateBubbleView() {
54 bubble_.reset(new BookmarkBubbleView(NULL,
55 NULL,
56 NULL,
57 profile(),
58 GURL(kTestBookmarkURL),
59 true));
60 }
61
62 void CreateSigninManager(const std::string& username) {
63 FakeSigninManager* signin_manager = static_cast<FakeSigninManager*>(
64 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
65 profile(),
66 &BookmarkBubbleViewTest::BuildFakeSignInManager));
67 signin_manager->Initialize(profile(), NULL);
68
69 if (!username.empty()) {
70 ASSERT_TRUE(signin_manager);
71 signin_manager->SetAuthenticatedUsername(username);
72 }
73 }
74
75 scoped_ptr<BookmarkBubbleView> bubble_;
76
77 private:
78 static BrowserContextKeyedService* BuildFakeSignInManager(
79 content::BrowserContext* profile) {
80 return new FakeSigninManager(static_cast<Profile*>(profile));
81 }
82
83 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewTest);
84 };
85
86 // Verifies that the sync promo is not displayed for a signed in user.
87 TEST_F(BookmarkBubbleViewTest, SyncPromoSignedIn) {
88 CreateSigninManager("fake_username");
89 CreateBubbleView();
90 bubble_->Init();
91 EXPECT_FALSE(bubble_->sync_promo_view_);
92 }
93
94 // Verifies that the sync promo is displayed for a user that is not signed in.
95 TEST_F(BookmarkBubbleViewTest, SyncPromoNotSignedIn) {
96 CreateBubbleView();
97 bubble_->Init();
98 EXPECT_TRUE(bubble_->sync_promo_view_);
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698