Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: chrome/browser/ui/views/sync/one_click_signin_bubble_view_browsertest.cc

Issue 9863032: [Sync] [Mac] Implement one-click signin bubble for OS X (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/bind.h"
5 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
6 #include "chrome/browser/ui/browser_window.h" 7 #include "chrome/browser/ui/browser_window.h"
7 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h" 8 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h"
sky 2012/03/28 14:49:17 nit: this should be the first include.
akalin 2012/03/28 15:19:21 Done.
8 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
9 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/common/page_transition_types.h"
10 #include "ui/views/controls/button/text_button.h" 12 #include "ui/views/controls/button/text_button.h"
11 #include "ui/views/events/event.h" 13 #include "ui/views/events/event.h"
12 14
15 namespace {
16
17 void OnClickLink(Browser* browser) {
18 browser->AddSelectedTabWithURL(GURL("http://www.example.com"),
19 content::PAGE_TRANSITION_AUTO_BOOKMARK);
20 }
21
22 } // namespace
23
13 class OneClickSigninBubbleViewBrowserTest : public InProcessBrowserTest { 24 class OneClickSigninBubbleViewBrowserTest : public InProcessBrowserTest {
14 public: 25 public:
15 OneClickSigninBubbleViewBrowserTest() : InProcessBrowserTest() { } 26 OneClickSigninBubbleViewBrowserTest() {}
27
28 void ShowOneClickSigninBubble() {
29 base::Closure on_click_link_callback =
30 base::Bind(&OnClickLink, base::Unretained(browser()));
31 browser()->window()->ShowOneClickSigninBubble(on_click_link_callback,
32 on_click_link_callback);
33 }
16 34
17 private: 35 private:
18 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewBrowserTest); 36 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewBrowserTest);
19 }; 37 };
20 38
21 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, Show) { 39 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, Show) {
22 browser()->window()->ShowOneClickSigninBubble(); 40 ShowOneClickSigninBubble();
23 ui_test_utils::RunAllPendingInMessageLoop(); 41 ui_test_utils::RunAllPendingInMessageLoop();
24 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); 42 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing());
25 43
26 OneClickSigninBubbleView::Hide(); 44 OneClickSigninBubbleView::Hide();
27 ui_test_utils::RunAllPendingInMessageLoop(); 45 ui_test_utils::RunAllPendingInMessageLoop();
28 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); 46 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing());
29 } 47 }
30 48
31 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, CloseButton) { 49 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, CloseButton) {
32 int initial_tab_count = browser()->tab_count(); 50 int initial_tab_count = browser()->tab_count();
33 51
34 browser()->window()->ShowOneClickSigninBubble(); 52 ShowOneClickSigninBubble();
35 ui_test_utils::RunAllPendingInMessageLoop(); 53 ui_test_utils::RunAllPendingInMessageLoop();
36 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); 54 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing());
37 55
38 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing(); 56 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing();
39 EXPECT_TRUE(view != NULL); 57 EXPECT_TRUE(view != NULL);
40 EXPECT_EQ(initial_tab_count, browser()->tab_count()); 58 EXPECT_EQ(initial_tab_count, browser()->tab_count());
41 59
42 // Simulate pressing the OK button. Set the message loop in the bubble 60 // Simulate pressing the OK button. Set the message loop in the bubble
43 // view so that it can be quit once the bubble is hidden. 61 // view so that it can be quit once the bubble is hidden.
44 view->set_message_loop_for_testing(MessageLoop::current()); 62 view->set_message_loop_for_testing(MessageLoop::current());
45 views::ButtonListener* listener = view; 63 views::ButtonListener* listener = view;
46 views::MouseEvent event(ui::ET_MOUSE_PRESSED, 0, 0, 0); 64 views::MouseEvent event(ui::ET_MOUSE_PRESSED, 0, 0, 0);
47 listener->ButtonPressed(view->close_button_for_testing(), event); 65 listener->ButtonPressed(view->close_button_for_testing(), event);
48 66
49 // View should no longer be showing. The message loop will exit once the 67 // View should no longer be showing. The message loop will exit once the
50 // fade animation of the bubble is done. 68 // fade animation of the bubble is done.
51 ui_test_utils::RunMessageLoop(); 69 ui_test_utils::RunMessageLoop();
52 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); 70 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing());
53 EXPECT_EQ(initial_tab_count, browser()->tab_count()); 71 EXPECT_EQ(initial_tab_count, browser()->tab_count());
54 } 72 }
55 73
56 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, ViewLink) { 74 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, ViewLink) {
57 int initial_tab_count = browser()->tab_count(); 75 int initial_tab_count = browser()->tab_count();
58 76
59 browser()->window()->ShowOneClickSigninBubble(); 77 ShowOneClickSigninBubble();
60 ui_test_utils::RunAllPendingInMessageLoop(); 78 ui_test_utils::RunAllPendingInMessageLoop();
61 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); 79 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing());
62 80
63 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing(); 81 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing();
64 EXPECT_TRUE(view != NULL); 82 EXPECT_TRUE(view != NULL);
65 EXPECT_EQ(initial_tab_count, browser()->tab_count()); 83 EXPECT_EQ(initial_tab_count, browser()->tab_count());
66 84
67 // Simulate pressing a link in the bubble. This should open a new tab. 85 // Simulate pressing a link in the bubble. This should open a new tab.
68 views::LinkListener* listener = view; 86 views::LinkListener* listener = view;
69 listener->LinkClicked(view->learn_more_link_for_testing(), 0); 87 listener->LinkClicked(view->learn_more_link_for_testing(), 0);
70 88
71 // View should no longer be showing and a new tab should be opened. 89 // View should no longer be showing and a new tab should be opened.
72 ui_test_utils::RunAllPendingInMessageLoop(); 90 ui_test_utils::RunAllPendingInMessageLoop();
73 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); 91 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing());
74 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); 92 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count());
75 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698