| OLD | NEW |
| (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 "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 12 #include "chrome/browser/signin/fake_signin_manager.h" |
| 13 #include "chrome/browser/signin/signin_manager.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chrome/test/base/ui_test_utils.h" |
| 20 |
| 21 namespace { |
| 22 const char kTestBookmarkURL[] = "http://www.google.com"; |
| 23 } // namespace |
| 24 |
| 25 class BookmarkBubbleViewBrowserTest : public InProcessBrowserTest { |
| 26 public: |
| 27 BookmarkBubbleViewBrowserTest() {} |
| 28 |
| 29 // content::BrowserTestBase: |
| 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 31 command_line->AppendSwitch(switches::kEnableBookmarkSyncPromo); |
| 32 } |
| 33 |
| 34 virtual void SetUpOnMainThread() OVERRIDE { |
| 35 bookmark_utils::AddIfNotBookmarked( |
| 36 BookmarkModelFactory::GetForProfile(browser()->profile()), |
| 37 GURL(kTestBookmarkURL), |
| 38 string16()); |
| 39 } |
| 40 |
| 41 protected: |
| 42 void ShowBookmarkBubble() { |
| 43 browser()->window()->ShowBookmarkBubble(GURL(kTestBookmarkURL), true); |
| 44 } |
| 45 |
| 46 private: |
| 47 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleViewBrowserTest); |
| 48 }; |
| 49 |
| 50 // Verifies that the sync promo is not displayed for a signed in user. |
| 51 IN_PROC_BROWSER_TEST_F(BookmarkBubbleViewBrowserTest, SyncPromoSignedIn) { |
| 52 SigninManager* signin = SigninManagerFactory::GetForProfile( |
| 53 browser()->profile()); |
| 54 signin->SetAuthenticatedUsername("fake_username"); |
| 55 |
| 56 ShowBookmarkBubble(); |
| 57 ASSERT_TRUE(BookmarkBubbleView::IsShowing()); |
| 58 EXPECT_FALSE(BookmarkBubbleView::bookmark_bubble_->sync_promo_view_); |
| 59 } |
| 60 |
| 61 // Verifies that the sync promo is displayed for a user that is not signed in. |
| 62 IN_PROC_BROWSER_TEST_F(BookmarkBubbleViewBrowserTest, SyncPromoNotSignedIn) { |
| 63 ShowBookmarkBubble(); |
| 64 ASSERT_TRUE(BookmarkBubbleView::IsShowing()); |
| 65 EXPECT_TRUE(BookmarkBubbleView::bookmark_bubble_->sync_promo_view_); |
| 66 } |
| OLD | NEW |