Index: chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
index 06c93da7cf6115b0023ad9499aa3c67b976e6e02..29dd339e130eaff2f8ad204258919a79b7d7d15f 100644 |
--- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
+++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
@@ -21,6 +21,7 @@ |
#include "components/password_manager/content/common/credential_manager_messages.h" |
#include "components/password_manager/core/browser/log_receiver.h" |
#include "components/password_manager/core/browser/password_manager_internals_service.h" |
+#include "components/password_manager/core/browser/store_result_filter.h" |
#include "components/password_manager/core/common/credential_manager_types.h" |
#include "components/password_manager/core/common/password_manager_pref_names.h" |
#include "components/password_manager/core/common/password_manager_switches.h" |
@@ -48,7 +49,6 @@ class MockLogReceiver : public password_manager::LogReceiver { |
// http://crbug.com/474577. |
class MockChromePasswordManagerClient : public ChromePasswordManagerClient { |
public: |
- MOCK_CONST_METHOD0(IsPasswordManagementEnabledForCurrentPage, bool()); |
engedy
2015/08/04 10:11:29
nit: Why this is going away? Is it just drive-by r
vabr (Chromium)
2015/08/04 12:21:25
Yes. I will mention it in the CL description, this
|
MOCK_CONST_METHOD0(DidLastPageLoadEncounterSSLErrors, bool()); |
MOCK_CONST_METHOD2(IsSyncAccountCredential, |
bool(const std::string& username, |
@@ -58,8 +58,6 @@ class MockChromePasswordManagerClient : public ChromePasswordManagerClient { |
: ChromePasswordManagerClient(web_contents, nullptr) { |
ON_CALL(*this, DidLastPageLoadEncounterSSLErrors()) |
.WillByDefault(testing::Return(false)); |
- ON_CALL(*this, IsPasswordManagementEnabledForCurrentPage()) |
- .WillByDefault(testing::Return(true)); |
} |
~MockChromePasswordManagerClient() override {} |
@@ -237,61 +235,6 @@ TEST_F(ChromePasswordManagerClientTest, LogToAReceiver) { |
EXPECT_FALSE(client->IsLoggingActive()); |
} |
-TEST_F(ChromePasswordManagerClientTest, ShouldFilterAutofillResult_Reauth) { |
- // Make client disallow only reauth requests. |
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
- command_line->AppendSwitch( |
- password_manager::switches::kDisallowAutofillSyncCredentialForReauth); |
- scoped_ptr<MockChromePasswordManagerClient> client( |
- new MockChromePasswordManagerClient(web_contents())); |
- autofill::PasswordForm form; |
- |
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _)) |
- .WillRepeatedly(Return(false)); |
- NavigateAndCommit( |
- GURL("https://accounts.google.com/login?rart=123&continue=blah")); |
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form)); |
- |
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _)) |
- .WillRepeatedly(Return(true)); |
- NavigateAndCommit( |
- GURL("https://accounts.google.com/login?rart=123&continue=blah")); |
- EXPECT_TRUE(client->ShouldFilterAutofillResult(form)); |
- |
- // This counts as a reauth url, though a valid URL should have a value for |
- // "rart" |
- NavigateAndCommit(GURL("https://accounts.google.com/addlogin?rart")); |
- EXPECT_TRUE(client->ShouldFilterAutofillResult(form)); |
- |
- NavigateAndCommit(GURL("https://accounts.google.com/login?param=123")); |
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form)); |
- |
- NavigateAndCommit(GURL("https://site.com/login?rart=678")); |
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form)); |
-} |
- |
-TEST_F(ChromePasswordManagerClientTest, ShouldFilterAutofillResult) { |
- // Normally the client should allow any credentials through, even if they |
- // are the sync credential. |
- scoped_ptr<MockChromePasswordManagerClient> client( |
- new MockChromePasswordManagerClient(web_contents())); |
- autofill::PasswordForm form; |
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _)) |
- .WillRepeatedly(Return(true)); |
- NavigateAndCommit(GURL("https://accounts.google.com/Login")); |
- EXPECT_FALSE(client->ShouldFilterAutofillResult(form)); |
- |
- // Adding disallow switch should cause sync credential to be filtered. |
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
- command_line->AppendSwitch( |
- password_manager::switches::kDisallowAutofillSyncCredential); |
- client.reset(new MockChromePasswordManagerClient(web_contents())); |
- EXPECT_CALL(*client, IsSyncAccountCredential(_, _)) |
- .WillRepeatedly(Return(true)); |
- NavigateAndCommit(GURL("https://accounts.google.com/Login")); |
- EXPECT_TRUE(client->ShouldFilterAutofillResult(form)); |
-} |
- |
TEST_F(ChromePasswordManagerClientTest, |
IsPasswordManagementEnabledForCurrentPage) { |
ChromePasswordManagerClient* client = GetClient(); |
@@ -467,3 +410,25 @@ TEST_F(ChromePasswordManagerClientTest, IsSavingEnabledForCurrentPageTest) { |
EXPECT_FALSE(client->IsSavingEnabledForCurrentPage()); |
profile()->ForceIncognito(false); |
} |
+ |
+TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL_Empty) { |
+ EXPECT_EQ(GURL::EmptyGURL(), GetClient()->GetLastCommittedEntryURL()); |
+} |
+ |
+TEST_F(ChromePasswordManagerClientTest, GetLastCommittedEntryURL) { |
+ GURL kUrl( |
+ "https://accounts.google.com/ServiceLogin?continue=" |
+ "https://passwords.google.com/settings&rart=123"); |
+ NavigateAndCommit(kUrl); |
+ EXPECT_EQ(kUrl, GetClient()->GetLastCommittedEntryURL()); |
+} |
+ |
+TEST_F(ChromePasswordManagerClientTest, CreateStoreResulFilter) { |
+ scoped_ptr<password_manager::StoreResultFilter> filter1 = |
+ GetClient()->CreateStoreResultFilter(); |
+ scoped_ptr<password_manager::StoreResultFilter> filter2 = |
+ GetClient()->CreateStoreResultFilter(); |
+ EXPECT_TRUE(filter1); |
+ EXPECT_TRUE(filter2); |
+ EXPECT_NE(filter1.get(), filter2.get()); |
+} |