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