| 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 <string> | 8 #include <string> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 14 #include "chrome/browser/signin/fake_signin_manager_builder.h" | 14 #include "chrome/browser/signin/fake_signin_manager_builder.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" | 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 16 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" | 16 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" |
| 17 #include "chrome/test/base/browser_with_test_window_test.h" | 17 #include "chrome/test/base/browser_with_test_window_test.h" |
| 18 #include "components/bookmarks/browser/bookmark_utils.h" | 18 #include "components/bookmarks/browser/bookmark_utils.h" |
| 19 #include "components/bookmarks/test/bookmark_test_helpers.h" | 19 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 20 #include "components/signin/core/browser/signin_manager.h" | 20 #include "components/signin/core/browser/signin_manager.h" |
| 21 | 21 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 TestingProfile* CreateProfile() override { | 53 TestingProfile* CreateProfile() override { |
| 54 TestingProfile::Builder builder; | 54 TestingProfile::Builder builder; |
| 55 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), | 55 builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
| 56 BuildFakeSigninManagerBase); | 56 BuildFakeSigninManagerBase); |
| 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 scoped_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 } | 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 |
| 73 SigninManagerBase* signin_manager = static_cast<SigninManagerBase*>( | 73 SigninManagerBase* signin_manager = static_cast<SigninManagerBase*>( |
| 74 SigninManagerFactory::GetForProfile(profile())); | 74 SigninManagerFactory::GetForProfile(profile())); |
| 75 ASSERT_TRUE(signin_manager); | 75 ASSERT_TRUE(signin_manager); |
| 76 signin_manager->SetAuthenticatedAccountInfo(username, username); | 76 signin_manager->SetAuthenticatedAccountInfo(username, username); |
| 77 } | 77 } |
| 78 | 78 |
| 79 scoped_ptr<BookmarkBubbleView> bubble_; | 79 std::unique_ptr<BookmarkBubbleView> bubble_; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewTest); | 82 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewTest); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // 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. |
| 86 TEST_F(BookmarkBubbleViewTest, SyncPromoSignedIn) { | 86 TEST_F(BookmarkBubbleViewTest, SyncPromoSignedIn) { |
| 87 SetUpSigninManager("fake_username"); | 87 SetUpSigninManager("fake_username"); |
| 88 CreateBubbleView(); | 88 CreateBubbleView(); |
| 89 bubble_->Init(); | 89 bubble_->Init(); |
| 90 scoped_ptr<views::View> footnote(bubble_->CreateFootnoteView()); | 90 std::unique_ptr<views::View> footnote(bubble_->CreateFootnoteView()); |
| 91 EXPECT_FALSE(footnote); | 91 EXPECT_FALSE(footnote); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // Verifies that the sync promo is displayed for a user that is not signed in. | 94 // Verifies that the sync promo is displayed for a user that is not signed in. |
| 95 TEST_F(BookmarkBubbleViewTest, SyncPromoNotSignedIn) { | 95 TEST_F(BookmarkBubbleViewTest, SyncPromoNotSignedIn) { |
| 96 CreateBubbleView(); | 96 CreateBubbleView(); |
| 97 bubble_->Init(); | 97 bubble_->Init(); |
| 98 scoped_ptr<views::View> footnote(bubble_->CreateFootnoteView()); | 98 std::unique_ptr<views::View> footnote(bubble_->CreateFootnoteView()); |
| 99 #if defined(OS_CHROMEOS) | 99 #if defined(OS_CHROMEOS) |
| 100 EXPECT_FALSE(footnote); | 100 EXPECT_FALSE(footnote); |
| 101 #else // !defined(OS_CHROMEOS) | 101 #else // !defined(OS_CHROMEOS) |
| 102 EXPECT_TRUE(footnote); | 102 EXPECT_TRUE(footnote); |
| 103 #endif | 103 #endif |
| 104 } | 104 } |
| OLD | NEW |