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