| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return builder.Build().release(); | 57 return builder.Build().release(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 // Creates a bookmark bubble view. | 61 // Creates a bookmark bubble view. |
| 62 void CreateBubbleView() { | 62 void CreateBubbleView() { |
| 63 std::unique_ptr<BubbleSyncPromoDelegate> delegate; | 63 std::unique_ptr<BubbleSyncPromoDelegate> delegate; |
| 64 bubble_.reset(new BookmarkBubbleView(NULL, NULL, std::move(delegate), | 64 bubble_.reset(new BookmarkBubbleView(NULL, NULL, std::move(delegate), |
| 65 profile(), GURL(kTestBookmarkURL), | 65 profile(), GURL(kTestBookmarkURL), |
| 66 true)); | 66 true)); |
| 67 bubble_->Init(); |
| 68 } |
| 69 |
| 70 std::unique_ptr<views::View> CreateFootnoteView() { |
| 71 return base::WrapUnique(bubble_->CreateFootnoteView()); |
| 67 } | 72 } |
| 68 | 73 |
| 69 void SetUpSigninManager(const std::string& username) { | 74 void SetUpSigninManager(const std::string& username) { |
| 70 if (username.empty()) | 75 if (username.empty()) |
| 71 return; | 76 return; |
| 72 | 77 |
| 73 SigninManagerBase* signin_manager = static_cast<SigninManagerBase*>( | 78 SigninManagerBase* signin_manager = static_cast<SigninManagerBase*>( |
| 74 SigninManagerFactory::GetForProfile(profile())); | 79 SigninManagerFactory::GetForProfile(profile())); |
| 75 ASSERT_TRUE(signin_manager); | 80 ASSERT_TRUE(signin_manager); |
| 76 signin_manager->SetAuthenticatedAccountInfo(username, username); | 81 signin_manager->SetAuthenticatedAccountInfo(username, username); |
| 77 } | 82 } |
| 78 | 83 |
| 79 std::unique_ptr<BookmarkBubbleView> bubble_; | 84 std::unique_ptr<BookmarkBubbleView> bubble_; |
| 80 | 85 |
| 81 private: | 86 private: |
| 82 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewTest); | 87 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewTest); |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 // Verifies that the sync promo is not displayed for a signed in user. | 90 // Verifies that the sync promo is not displayed for a signed in user. |
| 86 TEST_F(BookmarkBubbleViewTest, SyncPromoSignedIn) { | 91 TEST_F(BookmarkBubbleViewTest, SyncPromoSignedIn) { |
| 87 SetUpSigninManager("fake_username"); | 92 SetUpSigninManager("fake_username"); |
| 88 CreateBubbleView(); | 93 CreateBubbleView(); |
| 89 bubble_->Init(); | 94 std::unique_ptr<views::View> footnote = CreateFootnoteView(); |
| 90 std::unique_ptr<views::View> footnote(bubble_->CreateFootnoteView()); | |
| 91 EXPECT_FALSE(footnote); | 95 EXPECT_FALSE(footnote); |
| 92 } | 96 } |
| 93 | 97 |
| 94 // Verifies that the sync promo is displayed for a user that is not signed in. | 98 // Verifies that the sync promo is displayed for a user that is not signed in. |
| 95 TEST_F(BookmarkBubbleViewTest, SyncPromoNotSignedIn) { | 99 TEST_F(BookmarkBubbleViewTest, SyncPromoNotSignedIn) { |
| 96 CreateBubbleView(); | 100 CreateBubbleView(); |
| 97 bubble_->Init(); | 101 std::unique_ptr<views::View> footnote = CreateFootnoteView(); |
| 98 std::unique_ptr<views::View> footnote(bubble_->CreateFootnoteView()); | |
| 99 #if defined(OS_CHROMEOS) | 102 #if defined(OS_CHROMEOS) |
| 100 EXPECT_FALSE(footnote); | 103 EXPECT_FALSE(footnote); |
| 101 #else // !defined(OS_CHROMEOS) | 104 #else // !defined(OS_CHROMEOS) |
| 102 EXPECT_TRUE(footnote); | 105 EXPECT_TRUE(footnote); |
| 103 #endif | 106 #endif |
| 104 } | 107 } |
| OLD | NEW |