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_bubble_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 NULL, | 62 NULL, |
63 delegate.Pass(), | 63 delegate.Pass(), |
64 profile(), | 64 profile(), |
65 GURL(kTestBookmarkURL), | 65 GURL(kTestBookmarkURL), |
66 true)); | 66 true)); |
67 } | 67 } |
68 | 68 |
69 void SetUpSigninManager(const std::string& username) { | 69 void SetUpSigninManager(const std::string& username) { |
70 if (username.empty()) | 70 if (username.empty()) |
71 return; | 71 return; |
| 72 |
72 SigninManagerBase* signin_manager = static_cast<SigninManagerBase*>( | 73 SigninManagerBase* signin_manager = static_cast<SigninManagerBase*>( |
73 SigninManagerFactory::GetForProfile(profile())); | 74 SigninManagerFactory::GetForProfile(profile())); |
74 ASSERT_TRUE(signin_manager); | 75 ASSERT_TRUE(signin_manager); |
75 signin_manager->SetAuthenticatedUsername(username); | 76 signin_manager->SetAuthenticatedAccountInfo(username, username); |
76 } | 77 } |
77 | 78 |
78 scoped_ptr<BookmarkBubbleView> bubble_; | 79 scoped_ptr<BookmarkBubbleView> bubble_; |
79 | 80 |
80 private: | 81 private: |
81 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewTest); | 82 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewTest); |
82 }; | 83 }; |
83 | 84 |
84 // Verifies that the sync promo is not displayed for a signed in user. | 85 // Verifies that the sync promo is not displayed for a signed in user. |
85 TEST_F(BookmarkBubbleViewTest, SyncPromoSignedIn) { | 86 TEST_F(BookmarkBubbleViewTest, SyncPromoSignedIn) { |
86 SetUpSigninManager("fake_username"); | 87 SetUpSigninManager("fake_username"); |
87 CreateBubbleView(); | 88 CreateBubbleView(); |
88 bubble_->Init(); | 89 bubble_->Init(); |
89 EXPECT_FALSE(bubble_->sync_promo_view_); | 90 EXPECT_FALSE(bubble_->sync_promo_view_); |
90 } | 91 } |
91 | 92 |
92 // Verifies that the sync promo is displayed for a user that is not signed in. | 93 // Verifies that the sync promo is displayed for a user that is not signed in. |
93 TEST_F(BookmarkBubbleViewTest, SyncPromoNotSignedIn) { | 94 TEST_F(BookmarkBubbleViewTest, SyncPromoNotSignedIn) { |
94 CreateBubbleView(); | 95 CreateBubbleView(); |
95 bubble_->Init(); | 96 bubble_->Init(); |
96 #if defined(OS_CHROMEOS) | 97 #if defined(OS_CHROMEOS) |
97 EXPECT_FALSE(bubble_->sync_promo_view_); | 98 EXPECT_FALSE(bubble_->sync_promo_view_); |
98 #else // !defined(OS_CHROMEOS) | 99 #else // !defined(OS_CHROMEOS) |
99 EXPECT_TRUE(bubble_->sync_promo_view_); | 100 EXPECT_TRUE(bubble_->sync_promo_view_); |
100 #endif | 101 #endif |
101 } | 102 } |
OLD | NEW |