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

Unified Diff: chrome/browser/password_manager/password_store_mac_unittest.cc

Issue 1226303003: Start the migration of passwords from the Keychain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the test Created 5 years, 5 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/password_manager/password_store_mac_unittest.cc
diff --git a/chrome/browser/password_manager/password_store_mac_unittest.cc b/chrome/browser/password_manager/password_store_mac_unittest.cc
index 43456f2e423e8ef2fa290ba24d2ec1351a2f4ec2..42fe4cedcb094509db4347cc8430a431a883de76 100644
--- a/chrome/browser/password_manager/password_store_mac_unittest.cc
+++ b/chrome/browser/password_manager/password_store_mac_unittest.cc
@@ -20,6 +20,7 @@
#include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "content/public/test/test_browser_thread.h"
+#include "content/public/test/test_utils.h"
#include "crypto/mock_apple_keychain.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -59,6 +60,9 @@ ACTION_P(SaveACopyOfFirstForm, target_form_ptr) {
*target_form_ptr = *arg0[0];
}
+void Noop() {
+}
+
class MockPasswordStoreConsumer : public PasswordStoreConsumer {
public:
MOCK_METHOD1(OnGetPasswordStoreResultsConstRef,
@@ -1215,10 +1219,13 @@ class PasswordStoreMacTest : public testing::Test {
store_ = new PasswordStoreMac(
base::ThreadTaskRunnerHandle::Get(), nullptr,
make_scoped_ptr<AppleKeychain>(new MockAppleKeychain));
- store_->InitWithTaskRunner(thread_->task_runner());
- ASSERT_TRUE(store_->ScheduleTask(
- base::Bind(&PasswordStoreMac::set_login_metadata_db, store_,
- base::Unretained(login_db))));
+ ASSERT_TRUE(thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&PasswordStoreMac::InitWithTaskRunner, store_,
+ thread_->task_runner())));
+
+ ASSERT_TRUE(thread_->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&PasswordStoreMac::set_login_metadata_db, store_,
+ base::Unretained(login_db))));
}
void ClosePasswordStore() {
@@ -1292,13 +1299,11 @@ class PasswordStoreMacTest : public testing::Test {
}
void FinishAsyncProcessing() {
- // Do a store-level query to wait for all the previously enqueued operations
- // to finish.
- MockPasswordStoreConsumer consumer;
- store_->GetLogins(PasswordForm(), PasswordStore::ALLOW_PROMPT, &consumer);
- EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(_))
- .WillOnce(QuitUIMessageLoop());
- base::MessageLoop::current()->Run();
+ scoped_refptr<content::MessageLoopRunner> runner =
+ new content::MessageLoopRunner;
+ ASSERT_TRUE(thread_->task_runner()->PostTaskAndReply(
+ FROM_HERE, base::Bind(&Noop), runner->QuitClosure()));
+ runner->Run();
}
PasswordStoreMac* store() { return store_.get(); }
@@ -1668,41 +1673,6 @@ TEST_F(PasswordStoreMacTest, TestRemoveLoginsMultiProfile) {
ASSERT_EQ(1u, matching_items.size());
}
-// Open the store and immediately write to it and try to read it back, without
-// first waiting for the initialization to finish. If tasks are processed in
-// order, read/write operations will correctly be performed only after the
-// initialization has finished.
-TEST_F(PasswordStoreMacTest, StoreIsUsableImmediatelyAfterConstruction) {
- ClosePasswordStore();
-
- base::WaitableEvent event(false, false);
- login_db_.reset(
- new SlowToInitLoginDatabase(test_login_db_file_path(), &event));
- ASSERT_TRUE(thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&PasswordStoreMacTest::InitLoginDatabase,
- base::Unretained(login_db_.get()))));
- CreateAndInitPasswordStore(login_db_.get());
-
- PasswordFormData www_form_data = {
- PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
- "http://www.facebook.com/index.html", "login", L"username", L"password",
- L"submit", L"not_joe_user", L"12345", true, false, 1};
- scoped_ptr<PasswordForm> form =
- CreatePasswordFormFromDataForTesting(www_form_data);
- store()->AddLogin(*form);
-
- MockPasswordStoreConsumer mock_consumer;
- store()->GetLogins(*form, PasswordStore::ALLOW_PROMPT, &mock_consumer);
-
- // Now the read/write tasks are scheduled, let the DB initialization proceed.
- event.Signal();
-
- EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u)))
- .WillOnce(QuitUIMessageLoop());
- base::MessageLoop::current()->Run();
- EXPECT_TRUE(login_db());
-}
-
// Add a facebook form to the store but not to the keychain. The form is to be
// implicitly deleted. However, the observers shouldn't get notified about
// deletion of non-existent forms like m.facebook.com.
« no previous file with comments | « chrome/browser/password_manager/password_store_mac.cc ('k') | chrome/browser/password_manager/password_store_proxy_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698