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

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

Issue 11647041: Revert "Linux: add library loader for GNOME keyring." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « chrome/browser/password_manager/native_backend_gnome_x.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
diff --git a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
index 92e5bc9f4eb9c7003741572c12218fcca7134c93..eb0e44d45e6b043e4a31059697acc347c3979898 100644
--- a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
+++ b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
@@ -257,7 +257,23 @@ const gchar* mock_gnome_keyring_result_to_message(GnomeKeyringResult res) {
return "mock keyring simulating failure";
}
-} // namespace
+// Inherit to get access to protected fields.
+class MockGnomeKeyringLoader : public GnomeKeyringLoader {
+ public:
+ static bool LoadMockGnomeKeyring() {
+#define GNOME_KEYRING_ASSIGN_POINTER(name) \
+ gnome_keyring_##name = &mock_gnome_keyring_##name;
+ GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_ASSIGN_POINTER)
+#undef GNOME_KEYRING_ASSIGN_POINTER
+ keyring_loaded = true;
+ // Reset the state of the mock library.
+ mock_keyring_items.clear();
+ mock_keyring_reject_local_ids = false;
+ return true;
+ }
+};
+
+} // anonymous namespace
class NativeBackendGnomeTest : public testing::Test {
protected:
@@ -269,6 +285,8 @@ class NativeBackendGnomeTest : public testing::Test {
virtual void SetUp() {
ASSERT_TRUE(db_thread_.Start());
+ MockGnomeKeyringLoader::LoadMockGnomeKeyring();
+
form_google_.origin = GURL("http://www.google.com/");
form_google_.action = GURL("http://www.google.com/login");
form_google_.username_element = UTF8ToUTF16("user");
@@ -294,20 +312,6 @@ class NativeBackendGnomeTest : public testing::Test {
db_thread_.Stop();
}
- static void SetUpMockKeyring(NativeBackendGnome* backend) {
- LibGnomeKeyringLoader* loader = backend->libgnome_keyring_loader();
- loader->gnome_keyring_is_available = &mock_gnome_keyring_is_available;
- loader->gnome_keyring_store_password = &mock_gnome_keyring_store_password;
- loader->gnome_keyring_delete_password = &mock_gnome_keyring_delete_password;
- loader->gnome_keyring_find_itemsv = &mock_gnome_keyring_find_itemsv;
- loader->gnome_keyring_result_to_message =
- &mock_gnome_keyring_result_to_message;
-
- // Reset the state of the mock library.
- mock_keyring_items.clear();
- mock_keyring_reject_local_ids = false;
- }
-
void RunBothThreads() {
// First we post a message to the DB thread that will run after all other
// messages that have been posted to the DB thread (we don't expect more
@@ -391,7 +395,6 @@ TEST_F(NativeBackendGnomeTest, BasicAddLogin) {
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -411,7 +414,6 @@ TEST_F(NativeBackendGnomeTest, BasicListLogins) {
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -442,7 +444,6 @@ TEST_F(NativeBackendGnomeTest, BasicRemoveLogin) {
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -471,7 +472,6 @@ TEST_F(NativeBackendGnomeTest, RemoveNonexistentLogin) {
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// First add an unrelated login.
BrowserThread::PostTask(
@@ -516,7 +516,6 @@ TEST_F(NativeBackendGnomeTest, AddDuplicateLogin) {
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -540,7 +539,6 @@ TEST_F(NativeBackendGnomeTest, ListLoginsAppends) {
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -580,7 +578,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_MigrateOneLogin) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
@@ -611,7 +608,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_MigrateOneLogin) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// This should not trigger migration because there will be no results.
std::vector<PasswordForm*> form_list;
@@ -639,7 +635,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_MigrateOneLogin) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// Trigger the migration by looking something up.
std::vector<PasswordForm*> form_list;
@@ -674,7 +669,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_MigrateToMultipleProfiles) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -694,7 +688,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_MigrateToMultipleProfiles) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// Trigger the migration by looking something up.
std::vector<PasswordForm*> form_list;
@@ -728,7 +721,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_MigrateToMultipleProfiles) {
{
NativeBackendGnome backend(24, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// Trigger the migration by looking something up.
std::vector<PasswordForm*> form_list;
@@ -761,7 +753,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_NoMigrationWithPrefSet) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -782,7 +773,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_NoMigrationWithPrefSet) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// Trigger the migration by adding a new login.
BrowserThread::PostTask(
@@ -821,7 +811,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_DeleteMigratedPasswordIsIsolated) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
@@ -841,7 +830,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_DeleteMigratedPasswordIsIsolated) {
{
NativeBackendGnome backend(42, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// Trigger the migration by looking something up.
std::vector<PasswordForm*> form_list;
@@ -875,7 +863,6 @@ TEST_F(NativeBackendGnomeTest, DISABLED_DeleteMigratedPasswordIsIsolated) {
{
NativeBackendGnome backend(24, profile_.GetPrefs());
backend.Init();
- SetUpMockKeyring(&backend);
// Trigger the migration by looking something up.
std::vector<PasswordForm*> form_list;
« no previous file with comments | « chrome/browser/password_manager/native_backend_gnome_x.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698