OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | |
6 | |
7 #include "base/strings/utf_string_conversions.h" | |
8 #include "components/autofill/core/common/password_form.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 #include "url/url_constants.h" | |
11 | |
12 namespace { | |
13 const std::string kSchemeHostExample = "http://example.com"; | |
14 } // namespace | |
15 | |
16 class GetHumanReadableOriginTest : public testing::Test { | |
17 public: | |
18 GetHumanReadableOriginTest() { | |
19 form_template_.origin = GURL(kSchemeHostExample); | |
20 form_template_.action = GURL(kSchemeHostExample); | |
21 form_template_.username_element = base::ASCIIToUTF16("Email"); | |
22 form_template_.password_element = base::ASCIIToUTF16("Password"); | |
23 form_template_.submit_element = base::ASCIIToUTF16("signIn"); | |
24 form_template_.signon_realm = kSchemeHostExample; | |
25 } | |
26 const autofill::PasswordForm& form_remplate() { return form_template_; } | |
27 | |
28 private: | |
29 autofill::PasswordForm form_template_; | |
30 }; | |
31 | |
32 TEST_F(GetHumanReadableOriginTest, OriginFromHtmlForm) { | |
33 autofill::PasswordForm html_form(form_remplate()); | |
34 html_form.origin = GURL(kSchemeHostExample + "/LoginAuth"); | |
35 html_form.action = GURL(kSchemeHostExample + "/Login"); | |
36 html_form.scheme = autofill::PasswordForm::SCHEME_HTML; | |
37 EXPECT_EQ(GetHumanReadableOrigin(html_form, ""), "example.com/LoginAuth"); | |
38 } | |
39 | |
40 TEST_F(GetHumanReadableOriginTest, OriginFromDigestForm) { | |
41 autofill::PasswordForm non_html_form(form_remplate()); | |
42 non_html_form.scheme = autofill::PasswordForm::SCHEME_DIGEST; | |
43 non_html_form.action = GURL(); | |
44 non_html_form.signon_realm = kSchemeHostExample + "42"; | |
45 EXPECT_EQ(GetHumanReadableOrigin(non_html_form, ""), "example.com"); | |
46 } | |
47 | |
48 TEST_F(GetHumanReadableOriginTest, OriginFromAndroidForm) { | |
49 autofill::PasswordForm android_form(form_remplate()); | |
50 android_form.action = GURL(); | |
51 android_form.origin = GURL(); | |
52 android_form.scheme = autofill::PasswordForm::SCHEME_OTHER; | |
53 android_form.signon_realm = | |
54 "android://" | |
55 "m3HSJL1i83hdltRq0-o9czGb-8KJDKra4t_" | |
56 "3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw==" | |
57 "@com.example.android"; | |
58 EXPECT_EQ(GetHumanReadableOrigin(android_form, ""), | |
59 "android://com.example.android"); | |
60 } | |
OLD | NEW |