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

Unified Diff: chrome/browser/ui/cocoa/one_click_signin_bubble_controller_browsertest.mm

Issue 13845022: Mac: Display a native bubble (instead of the JS one) after the web signin flow. (branched from http… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ntpBubble
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/one_click_signin_bubble_controller_browsertest.mm
diff --git a/chrome/browser/ui/cocoa/one_click_signin_bubble_controller_browsertest.mm b/chrome/browser/ui/cocoa/one_click_signin_bubble_controller_browsertest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..f495de704fa7b4deb5046fd04afd81ab382eb24f
--- /dev/null
+++ b/chrome/browser/ui/cocoa/one_click_signin_bubble_controller_browsertest.mm
@@ -0,0 +1,97 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/one_click_signin_bubble_controller.h"
+
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_finder.h"
+#import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
+#import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#import "testing/gtest_mac.h"
+
+class OneClickSigninBubbleControllerTest : public InProcessBrowserTest {
+ public:
+ OneClickSigninBubbleControllerTest()
+ : InProcessBrowserTest(),
Alexei Svitkine (slow) 2013/04/24 15:26:27 Nit: I don't think you need to explicitly call the
noms (inactive) 2013/04/25 18:29:58 Done.
+ controller_(NULL),
+ sync_mode_(OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS),
+ callback_count_(0) {
+ }
+
+ protected:
+ virtual void SetUpOnMainThread() OVERRIDE {
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ BrowserWindow::StartSyncCallback callback = base::Bind(
+ &OneClickSigninBubbleControllerTest::OnStartSyncCallback,
+ base::Unretained(this));
+
+ BrowserWindowCocoa* browser_window =
+ static_cast<BrowserWindowCocoa*>(browser()->window());
+ controller_.reset([[OneClickSigninBubbleController alloc]
+ initWithBrowserWindowController:browser_window->cocoa_controller()
+ webContents:web_contents
+ errorMessage:nil
+ callback:callback]);
+ [controller_ showWindow:nil];
+ EXPECT_NSEQ(@"OneClickSigninBubble",
+ [[controller_ viewController] nibName]);
+ }
+
+ scoped_nsobject<OneClickSigninBubbleController> controller_;
Alexei Svitkine (slow) 2013/04/24 15:26:27 Make all variables private and provide accessors t
+ OneClickSigninSyncStarter::StartSyncMode sync_mode_;
Alexei Svitkine (slow) 2013/04/24 15:26:27 Are you using this anywhere?
noms (inactive) 2013/04/25 18:29:58 Done.
+ int callback_count_;
+
+ private:
+ void OnStartSyncCallback(OneClickSigninSyncStarter::StartSyncMode mode) {
+ sync_mode_ = mode;
+ ++callback_count_;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(OneClickSigninBubbleControllerTest);
+};
+
+// Test that the bubble does not start sync if the OK button is clicked.
+IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, OK) {
+ [[controller_ viewController] ok:nil];
+ EXPECT_EQ(0, callback_count_);
+}
+
+// Test that the bubble does not start sync if the Undo button is clicked.
+IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Undo) {
+ [[controller_ viewController] onClickUndo:nil];
+ EXPECT_EQ(0, callback_count_);
+}
+
+// Test that the bubble does not start sync if the bubble is closed.
+IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Close) {
+ [controller_ close];
+ EXPECT_EQ(0, callback_count_);
+}
+
+// Test that the advanced page is opened in the current tab and that
+// the bubble does not start sync.
+IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, Advanced) {
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+ [[controller_ viewController] onClickAdvancedLink:nil];
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+ EXPECT_EQ(0, callback_count_);
+}
+
+// Test that clicking the learn more link opens a new tab and that
+// the bubble does not start sync.
+IN_PROC_BROWSER_TEST_F(OneClickSigninBubbleControllerTest, LearnMore) {
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+ [[controller_ viewController] textView:nil
+ clickedOnLink:nil
Alexei Svitkine (slow) 2013/04/24 15:26:27 Nit: Align the :'s.
noms (inactive) 2013/04/25 18:29:58 Done.
+ atIndex:0];
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ EXPECT_EQ(2, browser()->tab_strip_model()->count());
+ EXPECT_EQ(0, callback_count_);
+}

Powered by Google App Engine
This is Rietveld 408576698