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

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

Issue 891463002: Fill empty fields from keyring result with default values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix. Created 5 years, 10 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
« no previous file with comments | « chrome/browser/password_manager/native_backend_libsecret.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 <stdarg.h> 5 #include <stdarg.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 30 matching lines...) Expand all
41 struct MockSecretItem { 41 struct MockSecretItem {
42 MockSecretValue* value; 42 MockSecretValue* value;
43 GHashTable* attributes; 43 GHashTable* attributes;
44 44
45 MockSecretItem(MockSecretValue* value, GHashTable* attributes) 45 MockSecretItem(MockSecretValue* value, GHashTable* attributes)
46 : value(value), attributes(attributes) {} 46 : value(value), attributes(attributes) {}
47 ~MockSecretItem() { 47 ~MockSecretItem() {
48 delete value; 48 delete value;
49 g_hash_table_destroy(attributes); 49 g_hash_table_destroy(attributes);
50 } 50 }
51
52 void RemoveAttribute(const char* keyname) {
53 g_hash_table_remove(attributes, keyname);
54 }
51 }; 55 };
52 56
53 bool Matches(MockSecretItem* item, GHashTable* query) { 57 bool Matches(MockSecretItem* item, GHashTable* query) {
54 GHashTable* attributes = item->attributes; 58 GHashTable* attributes = item->attributes;
55 GHashTableIter iter; 59 GHashTableIter iter;
56 gchar* name; 60 gchar* name;
57 gchar* query_value; 61 gchar* query_value;
58 g_hash_table_iter_init(&iter, query); 62 g_hash_table_iter_init(&iter, query);
59 63
60 while (g_hash_table_iter_next(&iter, reinterpret_cast<gpointer*>(&name), 64 while (g_hash_table_iter_next(&iter, reinterpret_cast<gpointer*>(&name),
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 815 }
812 816
813 TEST_F(NativeBackendLibsecretTest, RemoveLoginsCreatedBetween) { 817 TEST_F(NativeBackendLibsecretTest, RemoveLoginsCreatedBetween) {
814 CheckRemoveLoginsBetween(CREATED); 818 CheckRemoveLoginsBetween(CREATED);
815 } 819 }
816 820
817 TEST_F(NativeBackendLibsecretTest, RemoveLoginsSyncedBetween) { 821 TEST_F(NativeBackendLibsecretTest, RemoveLoginsSyncedBetween) {
818 CheckRemoveLoginsBetween(SYNCED); 822 CheckRemoveLoginsBetween(SYNCED);
819 } 823 }
820 824
825 TEST_F(NativeBackendLibsecretTest, SomeKeyringAttributesAreMissing) {
826 // Absent attributes should be filled with default values.
827 NativeBackendLibsecret backend(42);
828
829 backend.AddLogin(form_google_);
830
831 EXPECT_EQ(1u, global_mock_libsecret_items.size());
832 // Remove a string attribute.
833 global_mock_libsecret_items[0]->RemoveAttribute("avatar_url");
834 // Remove an integer attribute.
835 global_mock_libsecret_items[0]->RemoveAttribute("ssl_valid");
836
837 ScopedVector<autofill::PasswordForm> form_list;
838 backend.GetAutofillableLogins(&form_list);
839
840 EXPECT_EQ(1u, form_list.size());
841 EXPECT_EQ(GURL(""), form_list[0]->avatar_url);
842 EXPECT_FALSE(form_list[0]->ssl_valid);
843 }
844
821 // TODO(mdm): add more basic tests here at some point. 845 // TODO(mdm): add more basic tests here at some point.
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/native_backend_libsecret.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698