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

Side by Side Diff: components/autofill/browser/password_autofill_manager_unittest.cc

Issue 17392006: In components/autofill, move browser/ to core/browser/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to fix conflicts Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/compiler_specific.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "components/autofill/browser/password_autofill_manager.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace {
11
12 // The name of the username/password element in the form.
13 const char* const kUsernameName = "username";
14 const char* const kInvalidUsername = "no-username";
15 const char* const kPasswordName = "password";
16
17 const char* const kAliceUsername = "alice";
18 const char* const kAlicePassword = "password";
19
20 const char* const kValue = "password";
21
22 } // namespace
23
24 namespace autofill {
25
26 class PasswordAutofillManagerTest : public testing::Test {
27 protected:
28 PasswordAutofillManagerTest() : password_autofill_manager_(NULL) {}
29
30 virtual void SetUp() OVERRIDE {
31 // Add a preferred login and an additional login to the FillData.
32 base::string16 username1 = ASCIIToUTF16(kAliceUsername);
33 base::string16 password1 = ASCIIToUTF16(kAlicePassword);
34
35 username_field_.name = ASCIIToUTF16(kUsernameName);
36 username_field_.value = username1;
37 fill_data_.basic_data.fields.push_back(username_field_);
38
39 FormFieldData password_field;
40 password_field.name = ASCIIToUTF16(kPasswordName);
41 password_field.value = password1;
42 fill_data_.basic_data.fields.push_back(password_field);
43
44 password_autofill_manager_.AddPasswordFormMapping(username_field_,
45 fill_data_);
46 }
47
48 PasswordAutofillManager* password_autofill_manager() {
49 return &password_autofill_manager_;
50 }
51
52 const FormFieldData& username_field() { return username_field_; }
53
54 private:
55 PasswordFormFillData fill_data_;
56 FormFieldData username_field_;
57
58 PasswordAutofillManager password_autofill_manager_;
59 };
60
61 TEST_F(PasswordAutofillManagerTest, DidAcceptAutofillSuggestion) {
62 EXPECT_TRUE(password_autofill_manager()->DidAcceptAutofillSuggestion(
63 username_field(), ASCIIToUTF16(kAliceUsername)));
64 EXPECT_FALSE(password_autofill_manager()->DidAcceptAutofillSuggestion(
65 username_field(), ASCIIToUTF16(kInvalidUsername)));
66
67 FormFieldData invalid_username_field;
68 invalid_username_field.name = ASCIIToUTF16(kInvalidUsername);
69
70 EXPECT_FALSE(password_autofill_manager()->DidAcceptAutofillSuggestion(
71 invalid_username_field, ASCIIToUTF16(kAliceUsername)));
72
73 password_autofill_manager()->Reset();
74 EXPECT_FALSE(password_autofill_manager()->DidAcceptAutofillSuggestion(
75 username_field(), ASCIIToUTF16(kAliceUsername)));
76 }
77
78 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/browser/password_autofill_manager.cc ('k') | components/autofill/browser/password_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698