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

Side by Side Diff: chrome/browser/ui/gtk/one_click_signin_bubble_gtk_browsertest.cc

Issue 10332185: Update behavior of one-click infobar to remove modal dialog, add "undo". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make GTK ok and undo buttons the same size horizontally Created 8 years, 7 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/gtk/one_click_signin_bubble_gtk.h" 5 #include "chrome/browser/ui/gtk/one_click_signin_bubble_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
14 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
14 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 17
17 namespace { 18 namespace {
18 19
19 class OneClickSigninBubbleGtkTest : public InProcessBrowserTest { 20 class OneClickSigninBubbleGtkTest : public InProcessBrowserTest {
20 public: 21 public:
21 OneClickSigninBubbleGtkTest() 22 OneClickSigninBubbleGtkTest()
22 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 23 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
23 learn_more_callback_( 24 start_sync_callback_(
24 base::Bind(&OneClickSigninBubbleGtkTest::OnLearnMore, 25 base::Bind(&OneClickSigninBubbleGtkTest::OnStartSync,
25 weak_ptr_factory_.GetWeakPtr())),
26 advanced_callback_(
27 base::Bind(&OneClickSigninBubbleGtkTest::OnAdvanced,
28 weak_ptr_factory_.GetWeakPtr())), 26 weak_ptr_factory_.GetWeakPtr())),
29 bubble_(NULL) {} 27 bubble_(NULL) {}
30 28
31 virtual OneClickSigninBubbleGtk* MakeBubble() { 29 virtual OneClickSigninBubbleGtk* MakeBubble() {
32 return new OneClickSigninBubbleGtk( 30 return new OneClickSigninBubbleGtk(
33 static_cast<BrowserWindowGtk*>(browser()->window()), 31 static_cast<BrowserWindowGtk*>(browser()->window()),
34 learn_more_callback_, 32 start_sync_callback_);
35 advanced_callback_);
36 } 33 }
37 34
38 MOCK_METHOD0(OnLearnMore, void()); 35 MOCK_METHOD1(OnStartSync, void(OneClickSigninSyncStarter::StartSyncMode));
39 MOCK_METHOD0(OnAdvanced, void());
40 36
41 protected: 37 protected:
42 base::WeakPtrFactory<OneClickSigninBubbleGtkTest> weak_ptr_factory_; 38 base::WeakPtrFactory<OneClickSigninBubbleGtkTest> weak_ptr_factory_;
43 base::Closure learn_more_callback_; 39 BrowserWindow::StartSyncCallback start_sync_callback_;
44 base::Closure advanced_callback_;
45 40
46 // Owns itself. 41 // Owns itself.
47 OneClickSigninBubbleGtk* bubble_; 42 OneClickSigninBubbleGtk* bubble_;
48 }; 43 };
49 44
50 // Test that the dialog doesn't call any callback if the OK button is 45 // Test that the dialog calls the callback if the OK button is clicked.
51 // clicked. 46 // Callback should be called to setup sync with default settings.
52 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndOK) { 47 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndOK) {
53 EXPECT_CALL(*this, OnLearnMore()).Times(0); 48 EXPECT_CALL(*this,
54 EXPECT_CALL(*this, OnAdvanced()).Times(0); 49 OnStartSync(
Peter Kasting 2012/05/24 22:25:18 Nit: Unusual indenting (see earlier comment) (2 pl
Roger Tawa OOO till Jul 10th 2012/05/25 16:04:08 Same as before. Please suggest an alternative ind
50 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).
51 Times(1);
55 52
56 MakeBubble()->ClickOKForTest(); 53 MakeBubble()->ClickOKForTest();
57 } 54 }
58 55
59 // Test that the learn more callback is run if its corresponding 56 // Test that the dialog doesn't calls the callback if the Undo button is
Peter Kasting 2012/05/24 22:25:18 Nit: calls -> call
Roger Tawa OOO till Jul 10th 2012/05/25 16:04:08 Done.
60 // button is clicked. 57 // clicked.
61 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClickLearnMore) { 58 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndUndo) {
62 EXPECT_CALL(*this, OnLearnMore()).Times(1); 59 EXPECT_CALL(*this, OnStartSync(testing::_)).Times(0);
63 EXPECT_CALL(*this, OnAdvanced()).Times(0);
64 60
65 MakeBubble()->ClickLearnMoreForTest(); 61 MakeBubble()->ClickUndoForTest();
66 } 62 }
67 63
68 // Test that the advanced callback is run if its corresponding button 64 // Test that the dialog calls the callback if the advanced link is clicked.
69 // is clicked. 65 // Callback should be called to configure sync before starting.
70 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClickAdvanced) { 66 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClickAdvanced) {
71 EXPECT_CALL(*this, OnLearnMore()).Times(0); 67 EXPECT_CALL(*this,
72 EXPECT_CALL(*this, OnAdvanced()).Times(1); 68 OnStartSync(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST)).
69 Times(1);
73 70
74 MakeBubble()->ClickAdvancedForTest(); 71 MakeBubble()->ClickAdvancedForTest();
75 } 72 }
76 73
74 // Test that the dialog calls the callback if the bubble is closed.
75 // Callback should be called to setup sync with default settings.
76 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClose) {
77 EXPECT_CALL(*this,
78 OnStartSync(
79 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).
80 Times(1);
81
82 MakeBubble()->CloseForTest();
83 }
84
77 } // namespace 85 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698