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

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: Address sky's comments 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 "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h"
6
7 #include "base/bind.h"
5 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
6 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
7 #include "chrome/browser/ui/views/sync/one_click_signin_bubble_view.h"
8 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
9 #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"
10 #include "ui/views/controls/button/text_button.h" 13 #include "ui/views/controls/button/text_button.h"
11 #include "ui/views/events/event.h" 14 #include "ui/views/events/event.h"
12 15
16 namespace {
17
18 void OnClickLink(Browser* browser) {
19 browser->AddSelectedTabWithURL(GURL("http://www.example.com"),
20 content::PAGE_TRANSITION_AUTO_BOOKMARK);
21 }
22
23 } // namespace
24
13 class OneClickSigninBubbleViewBrowserTest : public InProcessBrowserTest { 25 class OneClickSigninBubbleViewBrowserTest : public InProcessBrowserTest {
14 public: 26 public:
15 OneClickSigninBubbleViewBrowserTest() : InProcessBrowserTest() { } 27 OneClickSigninBubbleViewBrowserTest() {}
28
29 void ShowOneClickSigninBubble() {
30 base::Closure on_click_link_callback =
31 base::Bind(&OnClickLink, base::Unretained(browser()));
32 browser()->window()->ShowOneClickSigninBubble(on_click_link_callback,
33 on_click_link_callback);
34 }
16 35
17 private: 36 private:
18 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewBrowserTest); 37 DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleViewBrowserTest);
19 }; 38 };
20 39
21 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, Show) { 40 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, Show) {
22 browser()->window()->ShowOneClickSigninBubble(); 41 ShowOneClickSigninBubble();
23 ui_test_utils::RunAllPendingInMessageLoop(); 42 ui_test_utils::RunAllPendingInMessageLoop();
24 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); 43 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing());
25 44
26 OneClickSigninBubbleView::Hide(); 45 OneClickSigninBubbleView::Hide();
27 ui_test_utils::RunAllPendingInMessageLoop(); 46 ui_test_utils::RunAllPendingInMessageLoop();
28 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); 47 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing());
29 } 48 }
30 49
31 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, CloseButton) { 50 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, CloseButton) {
32 int initial_tab_count = browser()->tab_count(); 51 int initial_tab_count = browser()->tab_count();
33 52
34 browser()->window()->ShowOneClickSigninBubble(); 53 ShowOneClickSigninBubble();
35 ui_test_utils::RunAllPendingInMessageLoop(); 54 ui_test_utils::RunAllPendingInMessageLoop();
36 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); 55 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing());
37 56
38 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing(); 57 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing();
39 EXPECT_TRUE(view != NULL); 58 EXPECT_TRUE(view != NULL);
40 EXPECT_EQ(initial_tab_count, browser()->tab_count()); 59 EXPECT_EQ(initial_tab_count, browser()->tab_count());
41 60
42 // Simulate pressing the OK button. Set the message loop in the bubble 61 // 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. 62 // view so that it can be quit once the bubble is hidden.
44 view->set_message_loop_for_testing(MessageLoop::current()); 63 view->set_message_loop_for_testing(MessageLoop::current());
45 views::ButtonListener* listener = view; 64 views::ButtonListener* listener = view;
46 views::MouseEvent event(ui::ET_MOUSE_PRESSED, 0, 0, 0); 65 views::MouseEvent event(ui::ET_MOUSE_PRESSED, 0, 0, 0);
47 listener->ButtonPressed(view->close_button_for_testing(), event); 66 listener->ButtonPressed(view->close_button_for_testing(), event);
48 67
49 // View should no longer be showing. The message loop will exit once the 68 // View should no longer be showing. The message loop will exit once the
50 // fade animation of the bubble is done. 69 // fade animation of the bubble is done.
51 ui_test_utils::RunMessageLoop(); 70 ui_test_utils::RunMessageLoop();
52 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); 71 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing());
53 EXPECT_EQ(initial_tab_count, browser()->tab_count()); 72 EXPECT_EQ(initial_tab_count, browser()->tab_count());
54 } 73 }
55 74
56 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, ViewLink) { 75 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleViewBrowserTest, ViewLink) {
57 int initial_tab_count = browser()->tab_count(); 76 int initial_tab_count = browser()->tab_count();
58 77
59 browser()->window()->ShowOneClickSigninBubble(); 78 ShowOneClickSigninBubble();
60 ui_test_utils::RunAllPendingInMessageLoop(); 79 ui_test_utils::RunAllPendingInMessageLoop();
61 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing()); 80 EXPECT_TRUE(OneClickSigninBubbleView::IsShowing());
62 81
63 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing(); 82 OneClickSigninBubbleView* view = OneClickSigninBubbleView::view_for_testing();
64 EXPECT_TRUE(view != NULL); 83 EXPECT_TRUE(view != NULL);
65 EXPECT_EQ(initial_tab_count, browser()->tab_count()); 84 EXPECT_EQ(initial_tab_count, browser()->tab_count());
66 85
67 // Simulate pressing a link in the bubble. This should open a new tab. 86 // Simulate pressing a link in the bubble. This should open a new tab.
68 views::LinkListener* listener = view; 87 views::LinkListener* listener = view;
69 listener->LinkClicked(view->learn_more_link_for_testing(), 0); 88 listener->LinkClicked(view->learn_more_link_for_testing(), 0);
70 89
71 // View should no longer be showing and a new tab should be opened. 90 // View should no longer be showing and a new tab should be opened.
72 ui_test_utils::RunAllPendingInMessageLoop(); 91 ui_test_utils::RunAllPendingInMessageLoop();
73 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing()); 92 EXPECT_FALSE(OneClickSigninBubbleView::IsShowing());
74 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count()); 93 EXPECT_EQ(initial_tab_count + 1, browser()->tab_count());
75 } 94 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/sync/one_click_signin_bubble_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698