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

Unified Diff: chrome/browser/ui/passwords/password_manager_presenter_unittest.cc

Issue 589353003: Revert "Allow editing passwords in settings/passwords" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/passwords/password_manager_presenter_unittest.cc
diff --git a/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc b/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc
index 2001a9c81c422ad79355557f3dcfe35bd7e4b73e..1cee3092e502b9b5c821f1dce7b020c307dee802 100644
--- a/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc
+++ b/chrome/browser/ui/passwords/password_manager_presenter_unittest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/password_manager/mock_password_store_service.h"
#include "chrome/browser/password_manager/password_store_factory.h"
@@ -15,7 +14,6 @@
using base::ASCIIToUTF16;
using testing::Eq;
-using testing::Field;
using testing::Property;
class MockPasswordUIView : public PasswordUIView {
@@ -59,9 +57,6 @@ class PasswordManagerPresenterTest : public testing::Test {
PasswordStoreFactory::GetInstance()->SetTestingFactory(
&profile_, MockPasswordStoreService::Build);
mock_controller_.reset(new MockPasswordUIView(&profile_));
- mock_store_ = static_cast<password_manager::MockPasswordStore*>(
- PasswordStoreFactory::GetForProfile(&profile_,
- Profile::EXPLICIT_ACCESS).get());
}
void AddPasswordEntry(const GURL& origin,
const std::string& user_name,
@@ -69,17 +64,10 @@ class PasswordManagerPresenterTest : public testing::Test {
void AddPasswordException(const GURL& origin);
void UpdateLists();
MockPasswordUIView* GetUIController() { return mock_controller_.get(); }
- PasswordManagerPresenter* GetPasswordManagerPresenter() {
- return mock_controller_->GetPasswordManagerPresenter();
- }
- password_manager::MockPasswordStore* GetPasswordStore() {
- return mock_store_.get();
- }
private:
TestingProfile profile_;
scoped_ptr<MockPasswordUIView> mock_controller_;
- scoped_refptr<password_manager::MockPasswordStore> mock_store_;
DISALLOW_COPY_AND_ASSIGN(PasswordManagerPresenterTest);
};
@@ -90,22 +78,24 @@ void PasswordManagerPresenterTest::AddPasswordEntry(
const std::string& password) {
autofill::PasswordForm* form = new autofill::PasswordForm();
form->origin = origin;
- form->username_element = ASCIIToUTF16("Email");
- form->username_value = ASCIIToUTF16(user_name);
- form->password_element = ASCIIToUTF16("Passwd");
- form->password_value = ASCIIToUTF16(password);
- GetPasswordManagerPresenter()->password_list_.push_back(form);
+ form->username_element = base::ASCIIToUTF16("Email");
+ form->username_value = base::ASCIIToUTF16(user_name);
+ form->password_element = base::ASCIIToUTF16("Passwd");
+ form->password_value = base::ASCIIToUTF16(password);
+ mock_controller_->GetPasswordManagerPresenter()->password_list_
+ .push_back(form);
}
void PasswordManagerPresenterTest::AddPasswordException(const GURL& origin) {
autofill::PasswordForm* form = new autofill::PasswordForm();
form->origin = origin;
- GetPasswordManagerPresenter()->password_exception_list_.push_back(form);
+ mock_controller_->GetPasswordManagerPresenter()->password_exception_list_
+ .push_back(form);
}
void PasswordManagerPresenterTest::UpdateLists() {
- GetPasswordManagerPresenter()->SetPasswordList();
- GetPasswordManagerPresenter()->SetPasswordExceptionList();
+ mock_controller_->GetPasswordManagerPresenter()->SetPasswordList();
+ mock_controller_->GetPasswordManagerPresenter()->SetPasswordExceptionList();
}
namespace {
@@ -155,106 +145,4 @@ TEST_F(PasswordManagerPresenterTest, UIControllerIsCalled) {
UpdateLists();
}
-// AddPassword and UpdatePassword are never called on Android.
-#if !defined(OS_ANDROID)
-TEST_F(PasswordManagerPresenterTest, CallAddPassword) {
- GURL basic_origin("http://host.com");
- base::string16 username = ASCIIToUTF16("username");
- base::string16 password = ASCIIToUTF16("password");
- EXPECT_CALL(
- *GetPasswordStore(),
- AddLogin(testing::AllOf(
- Field(&autofill::PasswordForm::signon_realm, Eq(basic_origin.spec())),
- Field(&autofill::PasswordForm::origin, Eq(basic_origin)),
- Field(&autofill::PasswordForm::username_value, Eq(username)),
- Field(&autofill::PasswordForm::password_value, Eq(password)),
- Field(&autofill::PasswordForm::ssl_valid, Eq(false)))));
- GetPasswordManagerPresenter()->AddPassword(basic_origin, username, password);
-
- GURL complex_origin("https://foo:bar@host.com:1234/path?query=v#ref");
- EXPECT_CALL(
- *GetPasswordStore(),
- AddLogin(testing::AllOf(
- Field(&autofill::PasswordForm::signon_realm,
- Eq("https://host.com:1234/")),
- Field(&autofill::PasswordForm::origin,
- Eq(GURL("https://host.com:1234/path"))),
- Field(&autofill::PasswordForm::username_value, Eq(username)),
- Field(&autofill::PasswordForm::password_value, Eq(password)),
- Field(&autofill::PasswordForm::ssl_valid, Eq(true)))));
- GetPasswordManagerPresenter()->AddPassword(complex_origin,
- username,
- password);
-}
-
-TEST_F(PasswordManagerPresenterTest, CallUpdatePassword) {
- GURL origin1("http://host.com");
- static const char kUsername1[] = "username";
- AddPasswordEntry(origin1, kUsername1, "password");
- GURL origin2("https://example.com");
- static const char kUsername2[] = "testname";
- AddPasswordEntry(origin2, kUsername2, "abcd");
-
- base::string16 new_password = ASCIIToUTF16("testpassword");
- EXPECT_CALL(
- *GetPasswordStore(),
- UpdateLogin(testing::AllOf(
- Field(&autofill::PasswordForm::origin, Eq(origin1)),
- Field(&autofill::PasswordForm::username_value,
- Eq(ASCIIToUTF16(kUsername1))),
- Field(&autofill::PasswordForm::password_value,
- Eq(new_password)))));
- GetPasswordManagerPresenter()->UpdatePassword(0, new_password);
-
- base::string16 new_password_again = ASCIIToUTF16("testpassword_again");
- EXPECT_CALL(
- *GetPasswordStore(),
- UpdateLogin(testing::AllOf(
- Field(&autofill::PasswordForm::origin, Eq(origin1)),
- Field(&autofill::PasswordForm::username_value,
- Eq(ASCIIToUTF16(kUsername1))),
- Field(&autofill::PasswordForm::password_value,
- Eq(new_password_again)))));
- GetPasswordManagerPresenter()->UpdatePassword(0, new_password_again);
-
- base::string16 another_password = ASCIIToUTF16("mypassword");
- EXPECT_CALL(
- *GetPasswordStore(),
- UpdateLogin(testing::AllOf(
- Field(&autofill::PasswordForm::origin, Eq(origin2)),
- Field(&autofill::PasswordForm::username_value,
- Eq(ASCIIToUTF16(kUsername2))),
- Field(&autofill::PasswordForm::password_value,
- Eq(another_password)))));
- GetPasswordManagerPresenter()->UpdatePassword(1, another_password);
-}
-#endif // !defined(OS_ANDROID)
-
-TEST(PasswordManagerPresenterTestSimple, CallCheckOriginValidityForAdding) {
- static const char* const kValidOrigins[] = {
- "http://host.com",
- "http://host.com/path",
- "https://host.com",
- "https://foo:bar@host.com/path?query=v#ref",
- "https://foo:bar@host.com:1234/path?query=v#ref"
- };
- for (size_t i = 0; i < arraysize(kValidOrigins); ++i) {
- SCOPED_TRACE(kValidOrigins[i]);
- EXPECT_TRUE(PasswordManagerPresenter::CheckOriginValidityForAdding(
- GURL(kValidOrigins[i])));
- }
-
- static const char* const kInvalidOrigins[] = {
- "noscheme",
- "invalidscheme:host.com",
- "ftp://ftp.host.com",
- "about:test"
- };
- for (size_t i = 0; i < arraysize(kInvalidOrigins); ++i) {
- SCOPED_TRACE(kInvalidOrigins[i]);
- EXPECT_FALSE(PasswordManagerPresenter::CheckOriginValidityForAdding(
- GURL(kInvalidOrigins[i])));
- }
-}
-
} // namespace
« no previous file with comments | « chrome/browser/ui/passwords/password_manager_presenter.cc ('k') | chrome/browser/ui/webui/options/password_manager_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698