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_sync_promo_view.h" | 5 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" | 11 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" |
| 12 #include "chrome/grit/chromium_strings.h" |
| 13 #include "chrome/grit/generated_resources.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
14 #include "ui/gfx/range/range.h" | 16 #include "ui/gfx/range/range.h" |
15 #include "ui/views/controls/styled_label.h" | 17 #include "ui/views/controls/styled_label.h" |
16 | 18 |
17 class BookmarkSyncPromoViewTest : public BookmarkBubbleDelegate, | 19 class BubbleSyncPromoViewTest : public BubbleSyncPromoDelegate, |
18 public testing::Test { | 20 public testing::Test { |
19 public: | 21 public: |
20 BookmarkSyncPromoViewTest() : sign_in_clicked_count_(0) {} | 22 BubbleSyncPromoViewTest() : sign_in_clicked_count_(0) {} |
21 | 23 |
22 protected: | 24 protected: |
23 // BookmarkBubbleDelegate: | 25 // BubbleSyncPromoDelegate: |
24 void OnSignInLinkClicked() override { ++sign_in_clicked_count_; } | 26 void OnSignInLinkClicked() override { ++sign_in_clicked_count_; } |
25 | 27 |
26 // Number of times that OnSignInLinkClicked has been called. | 28 // Number of times that OnSignInLinkClicked has been called. |
27 int sign_in_clicked_count_; | 29 int sign_in_clicked_count_; |
28 | 30 |
29 private: | 31 private: |
30 DISALLOW_COPY_AND_ASSIGN(BookmarkSyncPromoViewTest); | 32 DISALLOW_COPY_AND_ASSIGN(BubbleSyncPromoViewTest); |
31 }; | 33 }; |
32 | 34 |
33 TEST_F(BookmarkSyncPromoViewTest, SignInLink) { | 35 TEST_F(BubbleSyncPromoViewTest, SignInLink) { |
34 scoped_ptr<BookmarkSyncPromoView> sync_promo; | 36 scoped_ptr<BubbleSyncPromoView> sync_promo; |
35 sync_promo.reset(new BookmarkSyncPromoView(this)); | 37 sync_promo.reset(new BubbleSyncPromoView(this, IDS_BOOKMARK_SYNC_PROMO_LINK, |
| 38 IDS_BOOKMARK_SYNC_PROMO_MESSAGE)); |
36 | 39 |
37 // Simulate clicking the "Sign in" link. | 40 // Simulate clicking the "Sign in" link. |
38 views::StyledLabel styled_label(base::ASCIIToUTF16("test"), nullptr); | 41 views::StyledLabel styled_label(base::ASCIIToUTF16("test"), nullptr); |
39 views::StyledLabelListener* listener = sync_promo.get(); | 42 views::StyledLabelListener* listener = sync_promo.get(); |
40 listener->StyledLabelLinkClicked(&styled_label, gfx::Range(), ui::EF_NONE); | 43 listener->StyledLabelLinkClicked(&styled_label, gfx::Range(), ui::EF_NONE); |
41 | 44 |
42 EXPECT_EQ(1, sign_in_clicked_count_); | 45 EXPECT_EQ(1, sign_in_clicked_count_); |
43 } | 46 } |
OLD | NEW |