OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 ASSERT_TRUE(db->Init(file_)); | 40 ASSERT_TRUE(db->Init(file_)); |
41 | 41 |
42 std::vector<PasswordForm*> result; | 42 std::vector<PasswordForm*> result; |
43 | 43 |
44 // Verify the database is empty. | 44 // Verify the database is empty. |
45 EXPECT_TRUE(db->GetAutofillableLogins(&result)); | 45 EXPECT_TRUE(db->GetAutofillableLogins(&result)); |
46 EXPECT_EQ(0U, result.size()); | 46 EXPECT_EQ(0U, result.size()); |
47 | 47 |
48 // Example password form. | 48 // Example password form. |
49 PasswordForm form; | 49 PasswordForm form; |
50 form.origin = GURL("http://www.google.com/accounts/LoginAuth"); | 50 form.origin = GURL("http://accounts.google.com/LoginAuth"); |
51 form.action = GURL("http://www.google.com/accounts/Login"); | 51 form.action = GURL("http://accounts.google.com/Login"); |
52 form.username_element = ASCIIToUTF16("Email"); | 52 form.username_element = ASCIIToUTF16("Email"); |
53 form.username_value = ASCIIToUTF16("test@gmail.com"); | 53 form.username_value = ASCIIToUTF16("test@gmail.com"); |
54 form.password_element = ASCIIToUTF16("Passwd"); | 54 form.password_element = ASCIIToUTF16("Passwd"); |
55 form.password_value = ASCIIToUTF16("test"); | 55 form.password_value = ASCIIToUTF16("test"); |
56 form.submit_element = ASCIIToUTF16("signIn"); | 56 form.submit_element = ASCIIToUTF16("signIn"); |
57 form.signon_realm = "http://www.google.com/"; | 57 form.signon_realm = "http://www.google.com/"; |
58 form.ssl_valid = false; | 58 form.ssl_valid = false; |
59 form.preferred = false; | 59 form.preferred = false; |
60 form.scheme = PasswordForm::SCHEME_HTML; | 60 form.scheme = PasswordForm::SCHEME_HTML; |
61 | 61 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 EXPECT_TRUE(db->Init(file_)); | 249 EXPECT_TRUE(db->Init(file_)); |
250 std::vector<PasswordForm*> result; | 250 std::vector<PasswordForm*> result; |
251 | 251 |
252 // Verify the database is empty. | 252 // Verify the database is empty. |
253 EXPECT_TRUE(db->GetBlacklistLogins(&result)); | 253 EXPECT_TRUE(db->GetBlacklistLogins(&result)); |
254 ASSERT_EQ(0U, result.size()); | 254 ASSERT_EQ(0U, result.size()); |
255 | 255 |
256 // Save a form as blacklisted. | 256 // Save a form as blacklisted. |
257 PasswordForm form; | 257 PasswordForm form; |
258 form.origin = GURL("http://www.google.com/accounts/LoginAuth"); | 258 form.origin = GURL("http://accounts.google.com/LoginAuth"); |
259 form.action = GURL("http://www.google.com/accounts/Login"); | 259 form.action = GURL("http://accounts.google.com/Login"); |
260 form.username_element = ASCIIToUTF16("Email"); | 260 form.username_element = ASCIIToUTF16("Email"); |
261 form.password_element = ASCIIToUTF16("Passwd"); | 261 form.password_element = ASCIIToUTF16("Passwd"); |
262 form.submit_element = ASCIIToUTF16("signIn"); | 262 form.submit_element = ASCIIToUTF16("signIn"); |
263 form.signon_realm = "http://www.google.com/"; | 263 form.signon_realm = "http://www.google.com/"; |
264 form.ssl_valid = false; | 264 form.ssl_valid = false; |
265 form.preferred = true; | 265 form.preferred = true; |
266 form.blacklisted_by_user = true; | 266 form.blacklisted_by_user = true; |
267 form.scheme = PasswordForm::SCHEME_HTML; | 267 form.scheme = PasswordForm::SCHEME_HTML; |
268 EXPECT_TRUE(db->AddLogin(form)); | 268 EXPECT_TRUE(db->AddLogin(form)); |
269 | 269 |
270 // Get all non-blacklisted logins (should be none). | 270 // Get all non-blacklisted logins (should be none). |
271 EXPECT_TRUE(db->GetAutofillableLogins(&result)); | 271 EXPECT_TRUE(db->GetAutofillableLogins(&result)); |
272 ASSERT_EQ(0U, result.size()); | 272 ASSERT_EQ(0U, result.size()); |
273 | 273 |
274 // GetLogins should give the blacklisted result. | 274 // GetLogins should give the blacklisted result. |
275 EXPECT_TRUE(db->GetLogins(form, &result)); | 275 EXPECT_TRUE(db->GetLogins(form, &result)); |
276 EXPECT_EQ(1U, result.size()); | 276 EXPECT_EQ(1U, result.size()); |
277 ClearResults(&result); | 277 ClearResults(&result); |
278 | 278 |
279 // So should GetAllBlacklistedLogins. | 279 // So should GetAllBlacklistedLogins. |
280 EXPECT_TRUE(db->GetBlacklistLogins(&result)); | 280 EXPECT_TRUE(db->GetBlacklistLogins(&result)); |
281 EXPECT_EQ(1U, result.size()); | 281 EXPECT_EQ(1U, result.size()); |
282 ClearResults(&result); | 282 ClearResults(&result); |
283 } | 283 } |
OLD | NEW |