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

Unified Diff: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller_unittest.mm

Issue 1992633003: Add "Sign In" button to the account chooser on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller_unittest.mm b/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller_unittest.mm
index 1b623f438e1cff994e468aa377d56055bb9204eb..80419d5ed86430e5de266e1a49fe2d27e01d240f 100644
--- a/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller_unittest.mm
@@ -17,7 +17,7 @@
#import "chrome/browser/ui/cocoa/passwords/account_avatar_fetcher_manager.h"
#import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h"
#import "chrome/browser/ui/cocoa/passwords/credential_item_button.h"
-#include "chrome/browser/ui/passwords/password_dialog_controller.h"
+#include "chrome/browser/ui/passwords/password_dialog_controller_mock.h"
#include "components/autofill/core/common/password_form.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -56,24 +56,6 @@ std::unique_ptr<autofill::PasswordForm> Credential(const char* username) {
return credential;
}
-class PasswordDialogControllerMock : public PasswordDialogController {
- public:
- MOCK_CONST_METHOD0(GetLocalForms, const FormsVector&());
- MOCK_CONST_METHOD0(GetFederationsForms, const FormsVector&());
- MOCK_CONST_METHOD0(GetAccoutChooserTitle,
- std::pair<base::string16, gfx::Range>());
- MOCK_CONST_METHOD0(GetAutoSigninPromoTitle, base::string16());
- MOCK_CONST_METHOD0(GetAutoSigninText,
- std::pair<base::string16, gfx::Range>());
- MOCK_METHOD0(OnSmartLockLinkClicked, void());
- MOCK_METHOD2(OnChooseCredentials, void(
- const autofill::PasswordForm& password_form,
- password_manager::CredentialType credential_type));
- MOCK_METHOD0(OnAutoSigninOK, void());
- MOCK_METHOD0(OnAutoSigninTurnOff, void());
- MOCK_METHOD0(OnCloseDialog, void());
-};
-
// Tests for the account chooser dialog view.
class AccountChooserViewControllerTest : public CocoaTest,
public PasswordPromptBridgeInterface {
@@ -122,6 +104,8 @@ void AccountChooserViewControllerTest::SetUpAccountChooser(
EXPECT_CALL(dialog_controller_, GetAccoutChooserTitle())
.WillOnce(testing::Return(std::make_pair(base::ASCIIToUTF16(kDialogTitle),
gfx::Range(0, 5))));
+ EXPECT_CALL(dialog_controller_, ShouldShowSignInButton())
+ .WillOnce(testing::Return(local->size() == 1));
[view_controller_ view];
ASSERT_TRUE(testing::Mock::VerifyAndClearExpectations(&dialog_controller_));
}
@@ -221,6 +205,15 @@ TEST_F(AccountChooserViewControllerTest, ClickTitleLink) {
atIndex:0];
}
+TEST_F(AccountChooserViewControllerTest, ClickSignIn) {
+ PasswordDialogController::FormsVector local_forms;
+ local_forms.push_back(Credential("pizza"));
+ SetUpAccountChooser(&local_forms);
+ EXPECT_TRUE(view_controller().signInButton);
+ EXPECT_CALL(dialog_controller(), OnSignInClicked());
+ [view_controller().signInButton performClick:nil];
+}
+
TEST_F(AccountChooserViewControllerTest, ClosePromptAndHandleClick) {
// A user may press mouse down, some navigation closes the dialog, mouse up
// still sends the action. The view should not crash.
@@ -232,6 +225,8 @@ TEST_F(AccountChooserViewControllerTest, ClosePromptAndHandleClick) {
[base::mac::ObjCCastStrict<CredentialItemButton>(
[view_controller().credentialButtons objectAtIndex:0]) performClick:nil];
[view_controller().cancelButton performClick:nil];
+ EXPECT_TRUE(view_controller().signInButton);
+ [view_controller().signInButton performClick:nil];
}
TEST_F(AccountChooserViewControllerTest, CloseOnEsc) {

Powered by Google App Engine
This is Rietveld 408576698