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

Unified Diff: components/password_manager/content/browser/credential_manager_impl_unittest.cc

Issue 1762603002: Switch components/password_manager code from IPC messages to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gyp Created 4 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/content/browser/credential_manager_impl_unittest.cc
diff --git a/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
similarity index 70%
rename from components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc
rename to components/password_manager/content/browser/credential_manager_impl_unittest.cc
index 77219ee179e472df168391f1d10b876ad8d7f825..e5129d1071c94c92a7b4234cbdbb3aa08c98c202 100644
--- a/components/password_manager/content/browser/credential_manager_dispatcher_unittest.cc
+++ b/components/password_manager/content/browser/credential_manager_impl_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/password_manager/content/browser/credential_manager_dispatcher.h"
+#include "components/password_manager/content/browser/credential_manager_impl.h"
#include <stdint.h>
@@ -17,7 +17,7 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
-#include "components/password_manager/content/common/credential_manager_messages.h"
+#include "components/password_manager/content/public/type_converters.h"
#include "components/password_manager/core/browser/credential_manager_password_form_manager.h"
#include "components/password_manager/core/browser/mock_affiliated_match_helper.h"
#include "components/password_manager/core/browser/password_manager.h"
@@ -31,6 +31,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_renderer_host.h"
+#include "mojo/common/url_type_converters.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -43,9 +44,6 @@ namespace password_manager {
namespace {
-// Chosen by fair dice roll. Guaranteed to be random.
-const int kRequestId = 4;
-
const char kTestWebOrigin[] = "https://example.com/";
const char kTestAndroidRealm1[] = "android://hash@com.example.one.android/";
const char kTestAndroidRealm2[] = "android://hash@com.example.two.android/";
@@ -134,11 +132,11 @@ class MockPasswordManagerClient : public StubPasswordManagerClient {
DISALLOW_COPY_AND_ASSIGN(MockPasswordManagerClient);
};
-class TestCredentialManagerDispatcher : public CredentialManagerDispatcher {
+class TestCredentialManagerImpl : public CredentialManagerImpl {
public:
- TestCredentialManagerDispatcher(content::WebContents* web_contents,
- PasswordManagerClient* client,
- PasswordManagerDriver* driver);
+ TestCredentialManagerImpl(content::WebContents* web_contents,
+ PasswordManagerClient* client,
+ PasswordManagerDriver* driver);
private:
base::WeakPtr<PasswordManagerDriver> GetDriver() override;
@@ -146,15 +144,14 @@ class TestCredentialManagerDispatcher : public CredentialManagerDispatcher {
base::WeakPtr<PasswordManagerDriver> driver_;
};
-TestCredentialManagerDispatcher::TestCredentialManagerDispatcher(
+TestCredentialManagerImpl::TestCredentialManagerImpl(
content::WebContents* web_contents,
PasswordManagerClient* client,
PasswordManagerDriver* driver)
- : CredentialManagerDispatcher(web_contents, client),
+ : CredentialManagerImpl(web_contents, client),
driver_(driver->AsWeakPtr()) {}
-base::WeakPtr<PasswordManagerDriver>
-TestCredentialManagerDispatcher::GetDriver() {
+base::WeakPtr<PasswordManagerDriver> TestCredentialManagerImpl::GetDriver() {
return driver_;
}
@@ -178,12 +175,27 @@ class SlightlyLessStubbyPasswordManagerDriver
PasswordManager password_manager_;
};
+// Callbacks from CredentialManagerImpl methods
+
+void RespondCallback(bool* called) {
+ *called = true;
+}
+
+void GetCredentialCallback(bool* called,
+ mojom::CredentialManagerError* out_error,
+ mojom::CredentialInfoPtr* out_info,
+ mojom::CredentialManagerError error,
+ mojom::CredentialInfoPtr info) {
+ *called = true;
+ *out_error = error;
+ *out_info = std::move(info);
+}
+
} // namespace
-class CredentialManagerDispatcherTest
- : public content::RenderViewHostTestHarness {
+class CredentialManagerImplTest : public content::RenderViewHostTestHarness {
public:
- CredentialManagerDispatcherTest() {}
+ CredentialManagerImplTest() {}
void SetUp() override {
content::RenderViewHostTestHarness::SetUp();
@@ -192,8 +204,9 @@ class CredentialManagerDispatcherTest
new testing::NiceMock<MockPasswordManagerClient>(store_.get()));
stub_driver_.reset(
new SlightlyLessStubbyPasswordManagerDriver(client_.get()));
- dispatcher_.reset(new TestCredentialManagerDispatcher(
+ cm_service_impl_.reset(new TestCredentialManagerImpl(
web_contents(), client_.get(), stub_driver_.get()));
+
Anand Mistry (off Chromium) 2016/03/18 01:24:13 Don't introduce new whitespace unnecessarily.
leonhsl(Using Gerrit) 2016/03/18 10:02:16 Done.
ON_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage())
.WillByDefault(testing::Return(true));
ON_CALL(*client_, IsOffTheRecord()).WillByDefault(testing::Return(false));
@@ -250,11 +263,21 @@ class CredentialManagerDispatcherTest
}
void TearDown() override {
+ cm_service_impl_.reset();
+
store_->ShutdownOnUIThread();
content::RenderViewHostTestHarness::TearDown();
}
- void ExpectZeroClickSignInFailure() {
+ void ExpectZeroClickSignInFailure(bool zero_click_only,
+ bool include_passwords,
+ const std::vector<GURL>& federations) {
+ bool called = false;
+ mojom::CredentialManagerError error;
+ mojom::CredentialInfoPtr credential;
+ CallGet(zero_click_only, include_passwords, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
+
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _))
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_))
@@ -262,18 +285,21 @@ class CredentialManagerDispatcherTest
RunAllPendingTasks();
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- ASSERT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param send_param;
- CredentialManagerMsg_SendCredential::Read(message, &send_param);
-
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY,
- std::get<1>(send_param).type);
+ EXPECT_TRUE(called);
+ EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error);
+ EXPECT_EQ(mojom::CredentialType::EMPTY, credential->type);
}
- void ExpectZeroClickSignInSuccess(CredentialType type) {
+ void ExpectZeroClickSignInSuccess(bool zero_click_only,
+ bool include_passwords,
+ const std::vector<GURL>& federations,
+ mojom::CredentialType type) {
+ bool called = false;
+ mojom::CredentialManagerError error;
+ mojom::CredentialInfoPtr credential;
+ CallGet(zero_click_only, include_passwords, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
+
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _))
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_))
@@ -281,17 +307,50 @@ class CredentialManagerDispatcherTest
RunAllPendingTasks();
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- ASSERT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param send_param;
- CredentialManagerMsg_SendCredential::Read(message, &send_param);
+ EXPECT_TRUE(called);
+ EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error);
+ EXPECT_EQ(type, credential->type);
+ }
+
+ void ExpectCredentialType(bool zero_click_only,
+ bool include_passwords,
+ const std::vector<GURL>& federations,
+ mojom::CredentialType type) {
+ bool called = false;
+ mojom::CredentialManagerError error;
+ mojom::CredentialInfoPtr credential;
+ CallGet(zero_click_only, include_passwords, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
+
+ RunAllPendingTasks();
+
+ EXPECT_TRUE(called);
+ EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error);
+ EXPECT_EQ(type, credential->type);
+ }
+
+ CredentialManagerImpl* cm_service_impl() { return cm_service_impl_.get(); }
+
+ // Helpers for testing CredentialManagerImpl methods.
+ void CallStore(const CredentialInfo& info,
+ const CredentialManagerImpl::StoreCallback& callback) {
+ mojom::CredentialInfoPtr credential = mojom::CredentialInfo::From(info);
+ cm_service_impl_->Store(std::move(credential), callback);
+ }
- EXPECT_EQ(type, std::get<1>(send_param).type);
+ void CallRequireUserMediation(
+ const CredentialManagerImpl::RequireUserMediationCallback& callback) {
+ cm_service_impl_->RequireUserMediation(callback);
}
- CredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); }
+ void CallGet(bool zero_click_only,
+ bool include_passwords,
+ const std::vector<GURL>& federations,
+ const CredentialManagerImpl::GetCallback& callback) {
+ cm_service_impl_->Get(zero_click_only, include_passwords,
+ mojo::Array<mojo::String>::From(federations),
+ callback);
+ }
protected:
autofill::PasswordForm form_;
@@ -302,46 +361,44 @@ class CredentialManagerDispatcherTest
scoped_refptr<TestPasswordStore> store_;
scoped_ptr<testing::NiceMock<MockPasswordManagerClient>> client_;
scoped_ptr<SlightlyLessStubbyPasswordManagerDriver> stub_driver_;
- scoped_ptr<CredentialManagerDispatcher> dispatcher_;
+
+ scoped_ptr<CredentialManagerImpl> cm_service_impl_;
};
-TEST_F(CredentialManagerDispatcherTest, IsZeroClickAllowed) {
+TEST_F(CredentialManagerImplTest, IsZeroClickAllowed) {
// IsZeroClickAllowed is uneffected by the first-run status.
client_->set_zero_click_enabled(true);
client_->set_first_run_seen(true);
- EXPECT_TRUE(dispatcher()->IsZeroClickAllowed());
+ EXPECT_TRUE(cm_service_impl()->IsZeroClickAllowed());
client_->set_zero_click_enabled(true);
client_->set_first_run_seen(false);
- EXPECT_TRUE(dispatcher()->IsZeroClickAllowed());
+ EXPECT_TRUE(cm_service_impl()->IsZeroClickAllowed());
client_->set_zero_click_enabled(false);
client_->set_first_run_seen(true);
- EXPECT_FALSE(dispatcher()->IsZeroClickAllowed());
+ EXPECT_FALSE(cm_service_impl()->IsZeroClickAllowed());
client_->set_zero_click_enabled(false);
client_->set_first_run_seen(false);
- EXPECT_FALSE(dispatcher()->IsZeroClickAllowed());
+ EXPECT_FALSE(cm_service_impl()->IsZeroClickAllowed());
}
-TEST_F(CredentialManagerDispatcherTest, CredentialManagerOnStore) {
+TEST_F(CredentialManagerImplTest, CredentialManagerOnStore) {
CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
_, CredentialSourceType::CREDENTIAL_SOURCE_API))
.Times(testing::Exactly(1));
- dispatcher()->OnStore(kRequestId, info);
-
- const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- process()->sink().ClearMessages();
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
// Allow the PasswordFormManager to talk to the password store, determine
// that the form is new, and set it as pending.
RunAllPendingTasks();
+ EXPECT_TRUE(called);
+
EXPECT_TRUE(client_->pending_manager()->HasCompletedMatching());
autofill::PasswordForm new_form =
@@ -354,31 +411,28 @@ TEST_F(CredentialManagerDispatcherTest, CredentialManagerOnStore) {
EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, new_form.scheme);
}
-TEST_F(CredentialManagerDispatcherTest, CredentialManagerStoreOverwrite) {
+TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwrite) {
// Populate the PasswordStore with a form.
store_->AddLogin(form_);
RunAllPendingTasks();
- // Calling 'OnStore' with a credential that matches |form_| should update
+ // Calling 'Store' with a credential that matches |form_| should update
// the password without prompting the user.
CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
info.password = base::ASCIIToUTF16("Totally new password.");
- dispatcher()->OnStore(kRequestId, info);
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
_, CredentialSourceType::CREDENTIAL_SOURCE_API))
.Times(testing::Exactly(0));
- const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- process()->sink().ClearMessages();
-
// Allow the PasswordFormManager to talk to the password store, determine
// the form is a match for an existing form, and update the PasswordStore.
RunAllPendingTasks();
+ EXPECT_TRUE(called);
+
TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
EXPECT_EQ(1U, passwords.size());
EXPECT_EQ(1U, passwords[form_.signon_realm].size());
@@ -386,8 +440,7 @@ TEST_F(CredentialManagerDispatcherTest, CredentialManagerStoreOverwrite) {
passwords[form_.signon_realm][0].password_value);
}
-TEST_F(CredentialManagerDispatcherTest,
- CredentialManagerStoreOverwriteZeroClick) {
+TEST_F(CredentialManagerImplTest, CredentialManagerStoreOverwriteZeroClick) {
// Set the global zero click flag on, and populate the PasswordStore with a
// form that's set to skip zero click.
client_->set_zero_click_enabled(true);
@@ -395,12 +448,12 @@ TEST_F(CredentialManagerDispatcherTest,
store_->AddLogin(form_);
RunAllPendingTasks();
- // Calling 'OnStore' with a credential that matches |form_| should update
+ // Calling 'Store' with a credential that matches |form_| should update
// the password without prompting the user.
CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
info.password = base::ASCIIToUTF16("Totally new password.");
- dispatcher()->OnStore(kRequestId, info);
- process()->sink().ClearMessages();
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
// Allow the PasswordFormManager to talk to the password store, determine
// the form is a match for an existing form, and update the PasswordStore.
@@ -411,7 +464,7 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerSignInWithSavingDisabledForCurrentPage) {
CredentialInfo info(form_, CredentialType::CREDENTIAL_TYPE_PASSWORD);
EXPECT_CALL(*client_, IsSavingAndFillingEnabledForCurrentPage())
@@ -420,21 +473,16 @@ TEST_F(CredentialManagerDispatcherTest,
_, CredentialSourceType::CREDENTIAL_SOURCE_API))
.Times(testing::Exactly(0));
- dispatcher()->OnStore(kRequestId, info);
-
- const uint32_t kMsgID = CredentialManagerMsg_AcknowledgeStore::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- process()->sink().ClearMessages();
+ bool called = false;
+ CallStore(info, base::Bind(&RespondCallback, &called));
RunAllPendingTasks();
+ EXPECT_TRUE(called);
EXPECT_FALSE(client_->pending_manager());
}
-TEST_F(CredentialManagerDispatcherTest,
- CredentialManagerOnRequireUserMediation) {
+TEST_F(CredentialManagerImplTest, CredentialManagerOnRequireUserMediation) {
store_->AddLogin(form_);
store_->AddLogin(cross_origin_form_);
RunAllPendingTasks();
@@ -446,15 +494,12 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click);
EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click);
- dispatcher()->OnRequireUserMediation(kRequestId);
+ bool called = false;
+ CallRequireUserMediation(base::Bind(&RespondCallback, &called));
+
RunAllPendingTasks();
- const uint32_t kMsgID =
- CredentialManagerMsg_AcknowledgeRequireUserMediation::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- process()->sink().ClearMessages();
+ EXPECT_TRUE(called);
passwords = store_->stored_passwords();
EXPECT_EQ(2U, passwords.size());
@@ -464,7 +509,7 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_FALSE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequireUserMediationIncognito) {
EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true));
store_->AddLogin(form_);
@@ -475,15 +520,11 @@ TEST_F(CredentialManagerDispatcherTest,
ASSERT_EQ(1U, passwords[form_.signon_realm].size());
EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click);
- dispatcher()->OnRequireUserMediation(kRequestId);
+ bool called = false;
+ CallRequireUserMediation(base::Bind(&RespondCallback, &called));
RunAllPendingTasks();
- const uint32_t kMsgID =
- CredentialManagerMsg_AcknowledgeRequireUserMediation::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- process()->sink().ClearMessages();
+ EXPECT_TRUE(called);
passwords = store_->stored_passwords();
ASSERT_EQ(1U, passwords.size());
@@ -491,7 +532,7 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_FALSE(passwords[form_.signon_realm][0].skip_zero_click);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequireUserMediationWithAffiliation) {
store_->AddLogin(form_);
store_->AddLogin(cross_origin_form_);
@@ -506,7 +547,7 @@ TEST_F(CredentialManagerDispatcherTest,
affiliated_realms.push_back(kTestAndroidRealm1);
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
RunAllPendingTasks();
TestPasswordStore::PasswordMap passwords = store_->stored_passwords();
@@ -516,9 +557,9 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_FALSE(passwords[affiliated_form1_.signon_realm][0].skip_zero_click);
EXPECT_FALSE(passwords[affiliated_form2_.signon_realm][0].skip_zero_click);
- dispatcher()->OnRequireUserMediation(kRequestId);
+ bool called = false;
+ CallRequireUserMediation(base::Bind(&RespondCallback, &called));
RunAllPendingTasks();
- process()->sink().ClearMessages();
passwords = store_->stored_passwords();
EXPECT_EQ(4U, passwords.size());
@@ -528,7 +569,7 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_FALSE(passwords[affiliated_form2_.signon_realm][0].skip_zero_click);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithEmptyPasswordStore) {
std::vector<GURL> federations;
EXPECT_CALL(*client_, PromptUserToSavePasswordPtr(
@@ -538,21 +579,10 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, false, true, federations);
-
- RunAllPendingTasks();
-
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param param;
- CredentialManagerMsg_SendCredential::Read(message, &param);
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, std::get<1>(param).type);
- process()->sink().ClearMessages();
+ ExpectCredentialType(false, true, federations, mojom::CredentialType::EMPTY);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) {
store_->AddLogin(cross_origin_form_);
@@ -564,21 +594,10 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, false, true, federations);
-
- RunAllPendingTasks();
-
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param param;
- CredentialManagerMsg_SendCredential::Read(message, &param);
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, std::get<1>(param).type);
- process()->sink().ClearMessages();
+ ExpectCredentialType(false, true, federations, mojom::CredentialType::EMPTY);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithFullPasswordStore) {
client_->set_zero_click_enabled(false);
store_->AddLogin(form_);
@@ -588,39 +607,39 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(1));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, false, true, federations);
+ bool called = false;
+ mojom::CredentialManagerError error;
+ mojom::CredentialInfoPtr credential;
+ CallGet(false, true, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
RunAllPendingTasks();
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
+ EXPECT_TRUE(called);
+ EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error);
}
TEST_F(
- CredentialManagerDispatcherTest,
+ CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithZeroClickOnlyEmptyPasswordStore) {
std::vector<GURL> federations;
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _))
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+ bool called = false;
+ mojom::CredentialManagerError error;
+ mojom::CredentialInfoPtr credential;
+ CallGet(true, true, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
RunAllPendingTasks();
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param send_param;
- CredentialManagerMsg_SendCredential::Read(message, &send_param);
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY,
- std::get<1>(send_param).type);
+ EXPECT_TRUE(called);
+ EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithZeroClickOnlyFullPasswordStore) {
store_->AddLogin(form_);
client_->set_first_run_seen(true);
@@ -628,12 +647,12 @@ TEST_F(CredentialManagerDispatcherTest,
std::vector<GURL> federations;
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0);
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
- ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD);
+ ExpectZeroClickSignInSuccess(true, true, federations,
+ mojom::CredentialType::PASSWORD);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithoutPasswords) {
store_->AddLogin(form_);
client_->set_first_run_seen(true);
@@ -641,12 +660,11 @@ TEST_F(CredentialManagerDispatcherTest,
std::vector<GURL> federations;
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0);
- dispatcher()->OnRequestCredential(kRequestId, true, false, federations);
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, false, federations);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialFederatedMatch) {
form_.federation_origin = url::Origin(GURL("https://example.com/"));
store_->AddLogin(form_);
@@ -656,12 +674,12 @@ TEST_F(CredentialManagerDispatcherTest,
federations.push_back(GURL("https://example.com/"));
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0);
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
- ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_FEDERATED);
+ ExpectZeroClickSignInSuccess(true, true, federations,
+ mojom::CredentialType::FEDERATED);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialFederatedNoMatch) {
form_.federation_origin = url::Origin(GURL("https://example.com/"));
store_->AddLogin(form_);
@@ -671,12 +689,11 @@ TEST_F(CredentialManagerDispatcherTest,
federations.push_back(GURL("https://not-example.com/"));
EXPECT_CALL(*client_, NotifyUserCouldBeAutoSignedInPtr(_)).Times(0);
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, true, federations);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialAffiliatedPasswordMatch) {
store_->AddLogin(affiliated_form1_);
client_->set_first_run_seen(true);
@@ -688,16 +705,15 @@ TEST_F(CredentialManagerDispatcherTest,
affiliated_realms.push_back(kTestAndroidRealm1);
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
// We pass in 'true' for the 'include_passwords' argument to ensure that
// password-type credentials are included as potential matches.
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
-
- ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD);
+ ExpectZeroClickSignInSuccess(true, true, federations,
+ mojom::CredentialType::PASSWORD);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialAffiliatedPasswordNoMatch) {
store_->AddLogin(affiliated_form1_);
client_->set_first_run_seen(true);
@@ -709,16 +725,14 @@ TEST_F(CredentialManagerDispatcherTest,
affiliated_realms.push_back(kTestAndroidRealm1);
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
// We pass in 'false' for the 'include_passwords' argument to ensure that
// password-type credentials are excluded as potential matches.
- dispatcher()->OnRequestCredential(kRequestId, true, false, federations);
-
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, false, federations);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialAffiliatedFederatedMatch) {
affiliated_form1_.federation_origin =
url::Origin(GURL("https://example.com/"));
@@ -734,14 +748,13 @@ TEST_F(CredentialManagerDispatcherTest,
affiliated_realms.push_back(kTestAndroidRealm1);
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
-
- ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_FEDERATED);
+ ExpectZeroClickSignInSuccess(true, true, federations,
+ mojom::CredentialType::FEDERATED);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialAffiliatedFederatedNoMatch) {
affiliated_form1_.federation_origin =
url::Origin(GURL("https://example.com/"));
@@ -757,14 +770,12 @@ TEST_F(CredentialManagerDispatcherTest,
affiliated_realms.push_back(kTestAndroidRealm1);
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
-
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, true, federations);
}
-TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithoutFirstRun) {
+TEST_F(CredentialManagerImplTest, RequestCredentialWithoutFirstRun) {
client_->set_first_run_seen(false);
store_->AddLogin(form_);
@@ -773,12 +784,11 @@ TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithoutFirstRun) {
EXPECT_CALL(*client_,
NotifyUserCouldBeAutoSignedInPtr(testing::Pointee(form_)))
.Times(1);
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, true, federations);
}
-TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithFirstRunAndSkip) {
+TEST_F(CredentialManagerImplTest, RequestCredentialWithFirstRunAndSkip) {
client_->set_first_run_seen(true);
form_.skip_zero_click = true;
@@ -788,12 +798,11 @@ TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithFirstRunAndSkip) {
EXPECT_CALL(*client_,
NotifyUserCouldBeAutoSignedInPtr(testing::Pointee(form_)))
.Times(1);
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, true, federations);
}
-TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithTLSErrors) {
+TEST_F(CredentialManagerImplTest, RequestCredentialWithTLSErrors) {
// If we encounter TLS errors, we won't return credentials.
EXPECT_CALL(*client_, DidLastPageLoadEncounterSSLErrors())
.WillRepeatedly(testing::Return(true));
@@ -801,12 +810,11 @@ TEST_F(CredentialManagerDispatcherTest, RequestCredentialWithTLSErrors) {
store_->AddLogin(form_);
std::vector<GURL> federations;
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, true, federations);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWithZeroClickOnlyTwoPasswordStore) {
store_->AddLogin(form_);
store_->AddLogin(origin_path_form_);
@@ -816,23 +824,11 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
-
- RunAllPendingTasks();
-
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param send_param;
- CredentialManagerMsg_SendCredential::Read(message, &send_param);
-
// With two items in the password store, we shouldn't get credentials back.
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY,
- std::get<1>(send_param).type);
+ ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
OnRequestCredentialWithZeroClickOnlyAndSkipZeroClickPasswordStore) {
form_.skip_zero_click = true;
store_->AddLogin(form_);
@@ -843,24 +839,12 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
-
- RunAllPendingTasks();
-
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param send_param;
- CredentialManagerMsg_SendCredential::Read(message, &send_param);
-
// With two items in the password store, we shouldn't get credentials back,
// even though only one item has |skip_zero_click| set |false|.
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY,
- std::get<1>(send_param).type);
+ ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
OnRequestCredentialWithZeroClickOnlyCrossOriginPasswordStore) {
store_->AddLogin(cross_origin_form_);
@@ -872,24 +856,12 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
-
- RunAllPendingTasks();
-
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param send_param;
- CredentialManagerMsg_SendCredential::Read(message, &send_param);
-
// We only have cross-origin zero-click credentials; they should not be
// returned.
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY,
- std::get<1>(send_param).type);
+ ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
CredentialManagerOnRequestCredentialWhileRequestPending) {
client_->set_zero_click_enabled(false);
store_->AddLogin(form_);
@@ -899,40 +871,40 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, false, true, federations);
- dispatcher()->OnRequestCredential(kRequestId + 1, false, true, federations);
+ // 1st request.
+ bool called_1 = false;
+ mojom::CredentialManagerError error_1;
+ mojom::CredentialInfoPtr credential_1;
+ CallGet(
+ false, true, federations,
+ base::Bind(&GetCredentialCallback, &called_1, &error_1, &credential_1));
+ // 2nd request.
+ bool called_2 = false;
+ mojom::CredentialManagerError error_2;
+ mojom::CredentialInfoPtr credential_2;
+ CallGet(
+ false, true, federations,
+ base::Bind(&GetCredentialCallback, &called_2, &error_2, &credential_2));
- // Check that the second request triggered a rejection.
- uint32_t kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
-
- CredentialManagerMsg_RejectCredentialRequest::Param reject_param;
- CredentialManagerMsg_RejectCredentialRequest::Read(message, &reject_param);
- EXPECT_EQ(blink::WebCredentialManagerPendingRequestError,
- std::get<1>(reject_param));
EXPECT_CALL(*client_, PromptUserToChooseCredentialsPtr(_, _, _, _))
.Times(testing::Exactly(1));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- process()->sink().ClearMessages();
-
// Execute the PasswordStore asynchronousness.
RunAllPendingTasks();
+ // Check that the second request triggered a rejection.
+ EXPECT_TRUE(called_2);
+ EXPECT_EQ(mojom::CredentialManagerError::PENDINGREQUEST, error_2);
+ EXPECT_TRUE(credential_2.is_null());
+
// Check that the first request resolves.
- kMsgID = CredentialManagerMsg_SendCredential::ID;
- message = process()->sink().GetFirstMessageMatching(kMsgID);
- EXPECT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param send_param;
- CredentialManagerMsg_SendCredential::Read(message, &send_param);
- EXPECT_NE(CredentialType::CREDENTIAL_TYPE_EMPTY,
- std::get<1>(send_param).type);
- process()->sink().ClearMessages();
+ EXPECT_TRUE(called_1);
+ EXPECT_EQ(mojom::CredentialManagerError::SUCCESS, error_1);
+ EXPECT_NE(mojom::CredentialType::EMPTY, credential_1->type);
}
-TEST_F(CredentialManagerDispatcherTest, ResetSkipZeroClickAfterPrompt) {
+TEST_F(CredentialManagerImplTest, ResetSkipZeroClickAfterPrompt) {
// Turn on the global zero-click flag, and add two credentials in separate
// origins, both set to skip zero-click.
client_->set_zero_click_enabled(true);
@@ -965,7 +937,12 @@ TEST_F(CredentialManagerDispatcherTest, ResetSkipZeroClickAfterPrompt) {
.Times(testing::Exactly(1));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, false, true, federations);
+ bool called = false;
+ mojom::CredentialManagerError error;
+ mojom::CredentialInfoPtr credential;
+ CallGet(false, true, federations,
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
+
RunAllPendingTasks();
passwords = store_->stored_passwords();
@@ -976,8 +953,7 @@ TEST_F(CredentialManagerDispatcherTest, ResetSkipZeroClickAfterPrompt) {
EXPECT_TRUE(passwords[cross_origin_form_.signon_realm][0].skip_zero_click);
}
-TEST_F(CredentialManagerDispatcherTest,
- NoResetSkipZeroClickAfterPromptInIncognito) {
+TEST_F(CredentialManagerImplTest, NoResetSkipZeroClickAfterPromptInIncognito) {
EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true));
// Turn on the global zero-click flag which should be overriden by Incognito.
client_->set_zero_click_enabled(true);
@@ -997,8 +973,12 @@ TEST_F(CredentialManagerDispatcherTest,
.Times(testing::Exactly(1));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, false, true,
- std::vector<GURL>());
+ bool called = false;
+ mojom::CredentialManagerError error;
+ mojom::CredentialInfoPtr credential;
+ CallGet(false, true, std::vector<GURL>(),
+ base::Bind(&GetCredentialCallback, &called, &error, &credential));
+
RunAllPendingTasks();
// The form shouldn't become a zero-click one.
@@ -1008,7 +988,7 @@ TEST_F(CredentialManagerDispatcherTest,
EXPECT_TRUE(passwords[form_.signon_realm][0].skip_zero_click);
}
-TEST_F(CredentialManagerDispatcherTest, IncognitoZeroClickRequestCredential) {
+TEST_F(CredentialManagerImplTest, IncognitoZeroClickRequestCredential) {
EXPECT_CALL(*client_, IsOffTheRecord()).WillRepeatedly(testing::Return(true));
store_->AddLogin(form_);
@@ -1017,21 +997,10 @@ TEST_F(CredentialManagerDispatcherTest, IncognitoZeroClickRequestCredential) {
.Times(testing::Exactly(0));
EXPECT_CALL(*client_, NotifyUserAutoSigninPtr(_)).Times(testing::Exactly(0));
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
-
- RunAllPendingTasks();
-
- const uint32_t kMsgID = CredentialManagerMsg_SendCredential::ID;
- const IPC::Message* message =
- process()->sink().GetFirstMessageMatching(kMsgID);
- ASSERT_TRUE(message);
- CredentialManagerMsg_SendCredential::Param param;
- CredentialManagerMsg_SendCredential::Read(message, &param);
- EXPECT_EQ(CredentialType::CREDENTIAL_TYPE_EMPTY, std::get<1>(param).type);
+ ExpectCredentialType(true, true, federations, mojom::CredentialType::EMPTY);
}
-TEST_F(CredentialManagerDispatcherTest,
- ZeroClickWithAffiliatedFormInPasswordStore) {
+TEST_F(CredentialManagerImplTest, ZeroClickWithAffiliatedFormInPasswordStore) {
// Insert the affiliated form into the store, and mock out the association
// with the current origin. As it's the only form matching the origin, it
// ought to be returned automagically.
@@ -1045,14 +1014,13 @@ TEST_F(CredentialManagerDispatcherTest,
affiliated_realms.push_back(kTestAndroidRealm1);
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
-
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
- ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD);
+ ExpectZeroClickSignInSuccess(true, true, federations,
+ mojom::CredentialType::PASSWORD);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
ZeroClickWithTwoAffiliatedFormsInPasswordStore) {
// Insert two affiliated forms into the store, and mock out the association
// with the current origin. Multiple forms === no zero-click sign in.
@@ -1068,14 +1036,12 @@ TEST_F(CredentialManagerDispatcherTest,
affiliated_realms.push_back(kTestAndroidRealm2);
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
-
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, true, federations);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
ZeroClickWithUnaffiliatedFormsInPasswordStore) {
// Insert the affiliated form into the store, but don't mock out the
// association with the current origin. No association === no zero-click sign
@@ -1089,14 +1055,12 @@ TEST_F(CredentialManagerDispatcherTest,
std::vector<std::string> affiliated_realms;
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
-
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
- ExpectZeroClickSignInFailure();
+ ExpectZeroClickSignInFailure(true, true, federations);
}
-TEST_F(CredentialManagerDispatcherTest,
+TEST_F(CredentialManagerImplTest,
ZeroClickWithFormAndUnaffiliatedFormsInPasswordStore) {
// Insert the affiliated form into the store, along with a real form for the
// origin, and don't mock out the association with the current origin. No
@@ -1111,16 +1075,15 @@ TEST_F(CredentialManagerDispatcherTest,
std::vector<std::string> affiliated_realms;
static_cast<MockAffiliatedMatchHelper*>(store_->affiliated_match_helper())
->ExpectCallToGetAffiliatedAndroidRealms(
- dispatcher_->GetSynthesizedFormForOrigin(), affiliated_realms);
-
- dispatcher()->OnRequestCredential(kRequestId, true, true, federations);
+ cm_service_impl_->GetSynthesizedFormForOrigin(), affiliated_realms);
- ExpectZeroClickSignInSuccess(CredentialType::CREDENTIAL_TYPE_PASSWORD);
+ ExpectZeroClickSignInSuccess(true, true, federations,
+ mojom::CredentialType::PASSWORD);
}
-TEST_F(CredentialManagerDispatcherTest, GetSynthesizedFormForOrigin) {
+TEST_F(CredentialManagerImplTest, GetSynthesizedFormForOrigin) {
autofill::PasswordForm synthesized =
- dispatcher_->GetSynthesizedFormForOrigin();
+ cm_service_impl_->GetSynthesizedFormForOrigin();
EXPECT_EQ(kTestWebOrigin, synthesized.origin.spec());
EXPECT_EQ(kTestWebOrigin, synthesized.signon_realm);
EXPECT_EQ(autofill::PasswordForm::SCHEME_HTML, synthesized.scheme);

Powered by Google App Engine
This is Rietveld 408576698