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

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: Address review comments 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
19 class OneClickSigninBubbleGtkTest : public InProcessBrowserTest { 18 class OneClickSigninBubbleGtkTest : public InProcessBrowserTest {
20 public: 19 public:
21 OneClickSigninBubbleGtkTest() 20 OneClickSigninBubbleGtkTest()
22 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 21 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
23 learn_more_callback_( 22 start_sync_callback_(
24 base::Bind(&OneClickSigninBubbleGtkTest::OnLearnMore, 23 base::Bind(&OneClickSigninBubbleGtkTest::OnStartSync,
25 weak_ptr_factory_.GetWeakPtr())),
26 advanced_callback_(
27 base::Bind(&OneClickSigninBubbleGtkTest::OnAdvanced,
28 weak_ptr_factory_.GetWeakPtr())), 24 weak_ptr_factory_.GetWeakPtr())),
29 bubble_(NULL) {} 25 bubble_(NULL) {}
30 26
31 virtual OneClickSigninBubbleGtk* MakeBubble() { 27 virtual OneClickSigninBubbleGtk* MakeBubble() {
32 return new OneClickSigninBubbleGtk( 28 return new OneClickSigninBubbleGtk(
33 static_cast<BrowserWindowGtk*>(browser()->window()), 29 static_cast<BrowserWindowGtk*>(browser()->window()),
34 learn_more_callback_, 30 start_sync_callback_);
35 advanced_callback_);
36 } 31 }
37 32
38 MOCK_METHOD0(OnLearnMore, void()); 33 MOCK_METHOD1(OnStartSync, void(OneClickSigninSyncStarter::StartSyncMode));
39 MOCK_METHOD0(OnAdvanced, void());
40 34
41 protected: 35 protected:
42 base::WeakPtrFactory<OneClickSigninBubbleGtkTest> weak_ptr_factory_; 36 base::WeakPtrFactory<OneClickSigninBubbleGtkTest> weak_ptr_factory_;
43 base::Closure learn_more_callback_; 37 BrowserWindow::StartSyncCallback start_sync_callback_;
44 base::Closure advanced_callback_;
45 38
46 // Owns itself. 39 // Owns itself.
47 OneClickSigninBubbleGtk* bubble_; 40 OneClickSigninBubbleGtk* bubble_;
48 }; 41 };
49 42
50 // Test that the dialog doesn't call any callback if the OK button is 43 // Test that the dialog calls the callback if the OK button is clicked.
51 // clicked. 44 // Callback should be called to setup sync with default settings.
52 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndOK) { 45 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndOK) {
53 EXPECT_CALL(*this, OnLearnMore()).Times(0); 46 EXPECT_CALL(*this, OnStartSync(
54 EXPECT_CALL(*this, OnAdvanced()).Times(0); 47 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(1);
55 48
56 MakeBubble()->ClickOKForTest(); 49 MakeBubble()->OnClickOK(NULL);
57 } 50 }
58 51
59 // Test that the learn more callback is run if its corresponding 52 // Test that the dialog doesn't call the callback if the Undo button is
60 // button is clicked. 53 // clicked.
61 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClickLearnMore) { 54 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndUndo) {
62 EXPECT_CALL(*this, OnLearnMore()).Times(1); 55 EXPECT_CALL(*this, OnStartSync(testing::_)).Times(0);
63 EXPECT_CALL(*this, OnAdvanced()).Times(0);
64 56
65 MakeBubble()->ClickLearnMoreForTest(); 57 MakeBubble()->OnClickUndo(NULL);
66 } 58 }
67 59
68 // Test that the advanced callback is run if its corresponding button 60 // Test that the dialog calls the callback if the advanced link is clicked.
69 // is clicked. 61 // Callback should be called to configure sync before starting.
70 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClickAdvanced) { 62 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClickAdvanced) {
71 EXPECT_CALL(*this, OnLearnMore()).Times(0); 63 EXPECT_CALL(*this,
72 EXPECT_CALL(*this, OnAdvanced()).Times(1); 64 OnStartSync(OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST)).
65 Times(1);
73 66
74 MakeBubble()->ClickAdvancedForTest(); 67 MakeBubble()->OnClickAdvancedLink(NULL);
75 } 68 }
76 69
77 } // namespace 70 // Test that the dialog calls the callback if the bubble is closed.
71 // Callback should be called to setup sync with default settings.
72 IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleGtkTest, ShowAndClose) {
73 EXPECT_CALL(*this, OnStartSync(
74 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS)).Times(1);
75
76 MakeBubble()->bubble_->Close();
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698