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

Side by Side Diff: chrome/browser/password_manager/password_store_mac_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/password_manager/password_store_mac.h" 5 #include "chrome/browser/password_manager/password_store_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/scoped_observer.h" 15 #include "base/scoped_observer.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/synchronization/waitable_event.h" 19 #include "base/synchronization/waitable_event.h"
20 #include "base/test/histogram_tester.h" 20 #include "base/test/histogram_tester.h"
21 #include "base/threading/thread_task_runner_handle.h" 21 #include "base/threading/thread_task_runner_handle.h"
22 #include "chrome/browser/password_manager/password_store_mac_internal.h" 22 #include "chrome/browser/password_manager/password_store_mac_internal.h"
23 #include "chrome/common/chrome_paths.h" 23 #include "chrome/common/chrome_paths.h"
24 #include "components/os_crypt/os_crypt_mocker.h" 24 #include "components/os_crypt/os_crypt_mocker.h"
25 #include "components/password_manager/core/browser/login_database.h" 25 #include "components/password_manager/core/browser/login_database.h"
26 #include "components/password_manager/core/browser/password_manager_test_utils.h " 26 #include "components/password_manager/core/browser/password_manager_test_utils.h "
27 #include "components/password_manager/core/browser/password_manager_util.h" 27 #include "components/password_manager/core/browser/password_manager_util.h"
28 #include "components/password_manager/core/browser/password_store_consumer.h" 28 #include "components/password_manager/core/browser/password_store_consumer.h"
29 #include "components/password_manager/core/browser/password_store_origin_unittes t.h" 29 #include "components/password_manager/core/browser/password_store_origin_unittes t.h"
30 #include "content/public/test/test_browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
31 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "content/public/test/test_utils.h" 32 #include "content/public/test/test_utils.h"
32 #include "crypto/mock_apple_keychain.h" 33 #include "crypto/mock_apple_keychain.h"
33 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
34 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
35 #include "url/origin.h" 36 #include "url/origin.h"
36 37
37 using autofill::PasswordForm; 38 using autofill::PasswordForm;
38 using base::ASCIIToUTF16; 39 using base::ASCIIToUTF16;
39 using base::WideToUTF16; 40 using base::WideToUTF16;
40 using content::BrowserThread; 41 using content::BrowserThread;
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1245
1245 std::vector<std::unique_ptr<PasswordForm>> owned_passwords = 1246 std::vector<std::unique_ptr<PasswordForm>> owned_passwords =
1246 owned_keychain_adapter.GetAllPasswordFormPasswords(); 1247 owned_keychain_adapter.GetAllPasswordFormPasswords();
1247 EXPECT_EQ(arraysize(owned_password_data), owned_passwords.size()); 1248 EXPECT_EQ(arraysize(owned_password_data), owned_passwords.size());
1248 } 1249 }
1249 1250
1250 #pragma mark - 1251 #pragma mark -
1251 1252
1252 class PasswordStoreMacTest : public testing::Test { 1253 class PasswordStoreMacTest : public testing::Test {
1253 public: 1254 public:
1254 PasswordStoreMacTest() : ui_thread_(BrowserThread::UI, &message_loop_) {} 1255 PasswordStoreMacTest() = default;
1255 1256
1256 void SetUp() override { 1257 void SetUp() override {
1257 ASSERT_TRUE(db_dir_.CreateUniqueTempDir()); 1258 ASSERT_TRUE(db_dir_.CreateUniqueTempDir());
1258 histogram_tester_.reset(new base::HistogramTester); 1259 histogram_tester_.reset(new base::HistogramTester);
1259 1260
1260 // Ensure that LoginDatabase will use the mock keychain if it needs to 1261 // Ensure that LoginDatabase will use the mock keychain if it needs to
1261 // encrypt/decrypt a password. 1262 // encrypt/decrypt a password.
1262 OSCryptMocker::SetUpWithSingleton(); 1263 OSCryptMocker::SetUpWithSingleton();
1263 login_db_.reset( 1264 login_db_.reset(
1264 new password_manager::LoginDatabase(test_login_db_file_path())); 1265 new password_manager::LoginDatabase(test_login_db_file_path()));
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 scoped_refptr<content::MessageLoopRunner> runner = 1376 scoped_refptr<content::MessageLoopRunner> runner =
1376 new content::MessageLoopRunner; 1377 new content::MessageLoopRunner;
1377 ASSERT_TRUE(thread_->task_runner()->PostTaskAndReply( 1378 ASSERT_TRUE(thread_->task_runner()->PostTaskAndReply(
1378 FROM_HERE, base::Bind(&Noop), runner->QuitClosure())); 1379 FROM_HERE, base::Bind(&Noop), runner->QuitClosure()));
1379 runner->Run(); 1380 runner->Run();
1380 } 1381 }
1381 1382
1382 PasswordStoreMac* store() { return store_.get(); } 1383 PasswordStoreMac* store() { return store_.get(); }
1383 1384
1384 protected: 1385 protected:
1385 base::MessageLoopForUI message_loop_; 1386 content::TestBrowserThreadBundle test_browser_thread_bundle_;
1386 content::TestBrowserThread ui_thread_;
1387 // Thread that the synchronous methods are run on. 1387 // Thread that the synchronous methods are run on.
1388 std::unique_ptr<base::Thread> thread_; 1388 std::unique_ptr<base::Thread> thread_;
1389 1389
1390 base::ScopedTempDir db_dir_; 1390 base::ScopedTempDir db_dir_;
1391 std::unique_ptr<password_manager::LoginDatabase> login_db_; 1391 std::unique_ptr<password_manager::LoginDatabase> login_db_;
1392 scoped_refptr<PasswordStoreMac> store_; 1392 scoped_refptr<PasswordStoreMac> store_;
1393 std::unique_ptr<base::HistogramTester> histogram_tester_; 1393 std::unique_ptr<base::HistogramTester> histogram_tester_;
1394 }; 1394 };
1395 1395
1396 TEST_F(PasswordStoreMacTest, TestStoreUpdate) { 1396 TEST_F(PasswordStoreMacTest, TestStoreUpdate) {
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 keychain_adapter.GetAllPasswordFormPasswords(); 2103 keychain_adapter.GetAllPasswordFormPasswords();
2104 EXPECT_EQ(2u, passwords.size()); 2104 EXPECT_EQ(2u, passwords.size());
2105 2105
2106 // Delete everyhting but only the Chrome-owned item should be affected. 2106 // Delete everyhting but only the Chrome-owned item should be affected.
2107 PasswordStoreMac::CleanUpKeychain(keychain(), passwords); 2107 PasswordStoreMac::CleanUpKeychain(keychain(), passwords);
2108 passwords = keychain_adapter.GetAllPasswordFormPasswords(); 2108 passwords = keychain_adapter.GetAllPasswordFormPasswords();
2109 ASSERT_EQ(1u, passwords.size()); 2109 ASSERT_EQ(1u, passwords.size());
2110 EXPECT_EQ("http://some.domain.com/", passwords[0]->signon_realm); 2110 EXPECT_EQ("http://some.domain.com/", passwords[0]->signon_realm);
2111 EXPECT_EQ(ASCIIToUTF16("sekrit"), passwords[0]->password_value); 2111 EXPECT_EQ(ASCIIToUTF16("sekrit"), passwords[0]->password_value);
2112 } 2112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698