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/one_click_signin_bubble_view.h" | 5 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" | 10 #include "chrome/browser/ui/sync/one_click_signin_bubble_delegate.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
12 #include "ui/views/controls/button/label_button.h" | 12 #include "ui/views/controls/button/label_button.h" |
13 #include "ui/views/test/views_test_base.h" | 13 #include "ui/views/test/views_test_base.h" |
14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
15 | 15 |
16 class OneClickSigninBubbleViewTest : public views::ViewsTestBase { | 16 class OneClickSigninBubbleViewTest : public views::ViewsTestBase { |
17 public: | 17 public: |
18 OneClickSigninBubbleViewTest() | 18 OneClickSigninBubbleViewTest() |
19 : on_start_sync_called_(false), | 19 : on_start_sync_called_(false), |
20 mode_(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST), | 20 mode_(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST), |
21 bubble_learn_more_click_count_(0), | 21 bubble_learn_more_click_count_(0), |
22 dialog_learn_more_click_count_(0), | 22 dialog_learn_more_click_count_(0), |
23 advanced_click_count_(0), | 23 advanced_click_count_(0), |
24 anchor_widget_(NULL) { | 24 anchor_widget_(NULL) { |
25 } | 25 } |
26 | 26 |
27 virtual void SetUp() OVERRIDE { | 27 virtual void SetUp() override { |
28 views::ViewsTestBase::SetUp(); | 28 views::ViewsTestBase::SetUp(); |
29 | 29 |
30 // Create a widget to host the anchor view. | 30 // Create a widget to host the anchor view. |
31 anchor_widget_ = new views::Widget; | 31 anchor_widget_ = new views::Widget; |
32 views::Widget::InitParams widget_params = CreateParams( | 32 views::Widget::InitParams widget_params = CreateParams( |
33 views::Widget::InitParams::TYPE_WINDOW); | 33 views::Widget::InitParams::TYPE_WINDOW); |
34 anchor_widget_->Init(widget_params); | 34 anchor_widget_->Init(widget_params); |
35 anchor_widget_->Show(); | 35 anchor_widget_->Show(); |
36 } | 36 } |
37 | 37 |
38 virtual void TearDown() OVERRIDE { | 38 virtual void TearDown() override { |
39 OneClickSigninBubbleView::Hide(); | 39 OneClickSigninBubbleView::Hide(); |
40 anchor_widget_->Close(); | 40 anchor_widget_->Close(); |
41 anchor_widget_ = NULL; | 41 anchor_widget_ = NULL; |
42 views::ViewsTestBase::TearDown(); | 42 views::ViewsTestBase::TearDown(); |
43 } | 43 } |
44 | 44 |
45 protected: | 45 protected: |
46 OneClickSigninBubbleView* ShowOneClickSigninBubble( | 46 OneClickSigninBubbleView* ShowOneClickSigninBubble( |
47 BrowserWindow::OneClickSigninBubbleType bubble_type) { | 47 BrowserWindow::OneClickSigninBubbleType bubble_type) { |
48 | 48 |
(...skipping 30 matching lines...) Expand all Loading... |
79 friend class OneClickSigninBubbleTestDelegate; | 79 friend class OneClickSigninBubbleTestDelegate; |
80 | 80 |
81 class OneClickSigninBubbleTestDelegate | 81 class OneClickSigninBubbleTestDelegate |
82 : public OneClickSigninBubbleDelegate { | 82 : public OneClickSigninBubbleDelegate { |
83 public: | 83 public: |
84 // |test| is not owned by this object. | 84 // |test| is not owned by this object. |
85 explicit OneClickSigninBubbleTestDelegate( | 85 explicit OneClickSigninBubbleTestDelegate( |
86 OneClickSigninBubbleViewTest* test) : test_(test) {} | 86 OneClickSigninBubbleViewTest* test) : test_(test) {} |
87 | 87 |
88 // OneClickSigninBubbleDelegate: | 88 // OneClickSigninBubbleDelegate: |
89 virtual void OnLearnMoreLinkClicked(bool is_dialog) OVERRIDE { | 89 virtual void OnLearnMoreLinkClicked(bool is_dialog) override { |
90 if (is_dialog) | 90 if (is_dialog) |
91 ++test_->dialog_learn_more_click_count_; | 91 ++test_->dialog_learn_more_click_count_; |
92 else | 92 else |
93 ++test_->bubble_learn_more_click_count_; | 93 ++test_->bubble_learn_more_click_count_; |
94 } | 94 } |
95 virtual void OnAdvancedLinkClicked() OVERRIDE { | 95 virtual void OnAdvancedLinkClicked() override { |
96 ++test_->advanced_click_count_; | 96 ++test_->advanced_click_count_; |
97 } | 97 } |
98 | 98 |
99 private: | 99 private: |
100 OneClickSigninBubbleViewTest* test_; | 100 OneClickSigninBubbleViewTest* test_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleTestDelegate); | 102 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleTestDelegate); |
103 }; | 103 }; |
104 | 104 |
105 // Widget to host the anchor view of the bubble. Destroys itself when closed. | 105 // Widget to host the anchor view of the bubble. Destroys itself when closed. |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); | 317 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); |
318 view->AcceleratorPressed(accelerator); | 318 view->AcceleratorPressed(accelerator); |
319 | 319 |
320 // View should no longer be showing. The message loop will exit once the | 320 // View should no longer be showing. The message loop will exit once the |
321 // fade animation of the bubble is done. | 321 // fade animation of the bubble is done. |
322 content::RunAllPendingInMessageLoop(); | 322 content::RunAllPendingInMessageLoop(); |
323 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 323 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
324 EXPECT_TRUE(on_start_sync_called_); | 324 EXPECT_TRUE(on_start_sync_called_); |
325 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); | 325 EXPECT_EQ(OneClickSigninSyncStarter::UNDO_SYNC, mode_); |
326 } | 326 } |
OLD | NEW |