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/bookmarks/bookmark_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 "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" | 10 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/events/event_constants.h" | 12 #include "ui/events/event_constants.h" |
13 #include "ui/gfx/range/range.h" | 13 #include "ui/gfx/range/range.h" |
14 | 14 |
15 class BookmarkSyncPromoViewTest : public BookmarkBubbleDelegate, | 15 class BookmarkSyncPromoViewTest : public BookmarkBubbleDelegate, |
16 public testing::Test { | 16 public testing::Test { |
17 public: | 17 public: |
18 BookmarkSyncPromoViewTest() : sign_in_clicked_count_(0) {} | 18 BookmarkSyncPromoViewTest() : sign_in_clicked_count_(0) {} |
19 | 19 |
20 protected: | 20 protected: |
21 // BookmarkBubbleDelegate: | 21 // BookmarkBubbleDelegate: |
22 virtual void OnSignInLinkClicked() override { | 22 void OnSignInLinkClicked() override { ++sign_in_clicked_count_; } |
23 ++sign_in_clicked_count_; | |
24 } | |
25 | 23 |
26 // Number of times that OnSignInLinkClicked has been called. | 24 // Number of times that OnSignInLinkClicked has been called. |
27 int sign_in_clicked_count_; | 25 int sign_in_clicked_count_; |
28 | 26 |
29 private: | 27 private: |
30 DISALLOW_COPY_AND_ASSIGN(BookmarkSyncPromoViewTest); | 28 DISALLOW_COPY_AND_ASSIGN(BookmarkSyncPromoViewTest); |
31 }; | 29 }; |
32 | 30 |
33 TEST_F(BookmarkSyncPromoViewTest, SignInLink) { | 31 TEST_F(BookmarkSyncPromoViewTest, SignInLink) { |
34 scoped_ptr<BookmarkSyncPromoView> sync_promo; | 32 scoped_ptr<BookmarkSyncPromoView> sync_promo; |
35 sync_promo.reset(new BookmarkSyncPromoView(this)); | 33 sync_promo.reset(new BookmarkSyncPromoView(this)); |
36 | 34 |
37 // Simulate clicking the "Sign in" link. | 35 // Simulate clicking the "Sign in" link. |
38 views::StyledLabelListener* listener = sync_promo.get(); | 36 views::StyledLabelListener* listener = sync_promo.get(); |
39 listener->StyledLabelLinkClicked(gfx::Range(), ui::EF_NONE); | 37 listener->StyledLabelLinkClicked(gfx::Range(), ui::EF_NONE); |
40 | 38 |
41 EXPECT_EQ(1, sign_in_clicked_count_); | 39 EXPECT_EQ(1, sign_in_clicked_count_); |
42 } | 40 } |
OLD | NEW |