OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
12 #include "content/public/common/page_transition_types.h" | 12 #include "content/public/common/page_transition_types.h" |
13 #include "ui/views/controls/button/text_button.h" | 13 #include "ui/views/controls/button/text_button.h" |
14 #include "ui/views/events/event.h" | 14 #include "ui/views/events/event.h" |
15 | 15 |
16 class OneClickSigninBubbleViewBrowserTest : public InProcessBrowserTest { | 16 class OneClickSigninBubbleViewBrowserTest : public InProcessBrowserTest { |
17 public: | 17 public: |
18 OneClickSigninBubbleViewBrowserTest() | 18 OneClickSigninBubbleViewBrowserTest() |
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 } | 21 } |
22 | 22 |
23 OneClickSigninBubbleView* ShowOneClickSigninBubble() { | 23 OneClickSigninBubbleView* ShowOneClickSigninBubble() { |
24 browser()->window()->ShowOneClickSigninBubble( | 24 browser()->window()->ShowOneClickSigninBubble( |
25 base::Bind(&OneClickSigninBubbleViewBrowserTest::OnStartSync, this)); | 25 base::Bind(&OneClickSigninBubbleViewBrowserTest::OnStartSync, this)); |
26 | 26 |
27 ui_test_utils::RunAllPendingInMessageLoop(); | 27 content::RunAllPendingInMessageLoop(); |
28 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); | 28 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); |
29 | 29 |
30 OneClickSigninBubbleView* view = | 30 OneClickSigninBubbleView* view = |
31 OneClickSigninBubbleView::view_for_testing(); | 31 OneClickSigninBubbleView::view_for_testing(); |
32 EXPECT_TRUE(view != NULL); | 32 EXPECT_TRUE(view != NULL); |
33 | 33 |
34 // Simulate pressing a link in the bubble. This should open a new tab. | 34 // Simulate pressing a link in the bubble. This should open a new tab. |
35 view->message_loop_for_testing_ = MessageLoop::current(); | 35 view->message_loop_for_testing_ = MessageLoop::current(); |
36 return view; | 36 return view; |
37 } | 37 } |
38 | 38 |
39 void OnStartSync(OneClickSigninSyncStarter::StartSyncMode mode) { | 39 void OnStartSync(OneClickSigninSyncStarter::StartSyncMode mode) { |
40 on_start_sync_called_ = true; | 40 on_start_sync_called_ = true; |
41 mode_ = mode; | 41 mode_ = mode; |
42 } | 42 } |
43 | 43 |
44 protected: | 44 protected: |
45 bool on_start_sync_called_; | 45 bool on_start_sync_called_; |
46 OneClickSigninSyncStarter::StartSyncMode mode_; | 46 OneClickSigninSyncStarter::StartSyncMode mode_; |
47 | 47 |
48 private: | 48 private: |
49 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewBrowserTest); | 49 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewBrowserTest); |
50 }; | 50 }; |
51 | 51 |
52 // Disabled. See http://crbug.com/132348 | 52 // Disabled. See http://crbug.com/132348 |
53 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, DISABLED_Show) { | 53 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, DISABLED_Show) { |
54 ShowOneClickSigninBubble(); | 54 ShowOneClickSigninBubble(); |
55 ui_test_utils::RunAllPendingInMessageLoop(); | 55 content::RunAllPendingInMessageLoop(); |
56 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); | 56 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); |
57 | 57 |
58 OneClickSigninBubbleView::Hide(); | 58 OneClickSigninBubbleView::Hide(); |
59 ui_test_utils::RunAllPendingInMessageLoop(); | 59 content::RunAllPendingInMessageLoop(); |
60 EXPECT_TRUE(on_start_sync_called_); | 60 EXPECT_TRUE(on_start_sync_called_); |
61 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); | 61 EXPECT_EQ(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, mode_); |
62 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 62 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
63 } | 63 } |
64 | 64 |
65 // Disabled. See http://crbug.com/132348 | 65 // Disabled. See http://crbug.com/132348 |
66 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, DISABLED_OkButton) { | 66 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, DISABLED_OkButton) { |
67 OneClickSigninBubbleView* view = ShowOneClickSigninBubble(); | 67 OneClickSigninBubbleView* view = ShowOneClickSigninBubble(); |
68 | 68 |
69 // Simulate pressing the OK button. Set the message loop in the bubble | 69 // Simulate pressing the OK button. Set the message loop in the bubble |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 views::View* view = one_click_view; | 141 views::View* view = one_click_view; |
142 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); | 142 const ui::Accelerator accelerator(ui::VKEY_ESCAPE, 0); |
143 view->AcceleratorPressed(accelerator); | 143 view->AcceleratorPressed(accelerator); |
144 | 144 |
145 // View should no longer be showing. The message loop will exit once the | 145 // View should no longer be showing. The message loop will exit once the |
146 // fade animation of the bubble is done. | 146 // fade animation of the bubble is done. |
147 content::RunMessageLoop(); | 147 content::RunMessageLoop(); |
148 EXPECT_FALSE(on_start_sync_called_); | 148 EXPECT_FALSE(on_start_sync_called_); |
149 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); | 149 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); |
150 } | 150 } |
OLD | NEW |