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

Side by Side Diff: components/password_manager/core/browser/password_ui_utils_unittest.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "components/autofill/core/common/password_form.h" 5 #include "components/autofill/core/common/password_form.h"
6 #include "components/password_manager/core/browser/password_ui_utils.h" 6 #include "components/password_manager/core/browser/password_ui_utils.h"
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace password_manager { 10 namespace password_manager {
(...skipping 14 matching lines...) Expand all
25 {"https://m.de", "m.de"}, 25 {"https://m.de", "m.de"},
26 {"https://www.mobile.de", "mobile.de"}, 26 {"https://www.mobile.de", "mobile.de"},
27 {"https://m.mobile.de", "mobile.de"}, 27 {"https://m.mobile.de", "mobile.de"},
28 {"https://m.www.de", "www.de"}, 28 {"https://m.www.de", "www.de"},
29 {"https://Mobile.example.de", "example.de"}, 29 {"https://Mobile.example.de", "example.de"},
30 {"https://WWW.Example.DE", "example.de"}}; 30 {"https://WWW.Example.DE", "example.de"}};
31 31
32 for (const auto& test_case : kTestCases) { 32 for (const auto& test_case : kTestCases) {
33 autofill::PasswordForm password_form; 33 autofill::PasswordForm password_form;
34 password_form.origin = GURL(test_case.input); 34 password_form.origin = GURL(test_case.input);
35 EXPECT_EQ(test_case.output, 35 EXPECT_EQ(test_case.output, GetShownOrigin(password_form.origin))
36 GetShownOrigin(password_form.origin, std::string()))
37 << "for input " << test_case.input; 36 << "for input " << test_case.input;
38 } 37 }
39 } 38 }
40 39
41 TEST(GetShownOriginAndLinkUrlTest, OriginFromAndroidForm_NoAffiliatedRealm) { 40 TEST(GetShownOriginAndLinkUrlTest, OriginFromAndroidForm_NoAffiliatedRealm) {
42 autofill::PasswordForm android_form; 41 autofill::PasswordForm android_form;
43 android_form.signon_realm = 42 android_form.signon_realm =
44 "android://" 43 "android://"
45 "m3HSJL1i83hdltRq0-o9czGb-8KJDKra4t_" 44 "m3HSJL1i83hdltRq0-o9czGb-8KJDKra4t_"
46 "3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw==" 45 "3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw=="
47 "@com.example.android"; 46 "@com.example.android";
48 android_form.affiliated_web_realm = std::string(); 47 android_form.affiliated_web_realm = std::string();
49 48
50 bool is_android_uri; 49 bool is_android_uri;
51 GURL link_url; 50 GURL link_url;
52 bool origin_is_clickable; 51 bool origin_is_clickable;
53 EXPECT_EQ( 52 EXPECT_EQ("android://com.example.android",
54 "android://com.example.android", 53 GetShownOriginAndLinkUrl(android_form, &is_android_uri, &link_url,
55 GetShownOriginAndLinkUrl(android_form, std::string(), &is_android_uri, 54 &origin_is_clickable));
56 &link_url, &origin_is_clickable));
57 EXPECT_TRUE(is_android_uri); 55 EXPECT_TRUE(is_android_uri);
58 EXPECT_FALSE(origin_is_clickable); 56 EXPECT_FALSE(origin_is_clickable);
59 EXPECT_EQ(GURL(android_form.signon_realm), link_url); 57 EXPECT_EQ(GURL(android_form.signon_realm), link_url);
60 } 58 }
61 59
62 TEST(GetShownOriginAndLinkUrlTest, OriginFromAndroidForm_WithAffiliatedRealm) { 60 TEST(GetShownOriginAndLinkUrlTest, OriginFromAndroidForm_WithAffiliatedRealm) {
63 autofill::PasswordForm android_form; 61 autofill::PasswordForm android_form;
64 android_form.signon_realm = 62 android_form.signon_realm =
65 "android://" 63 "android://"
66 "m3HSJL1i83hdltRq0-o9czGb-8KJDKra4t_" 64 "m3HSJL1i83hdltRq0-o9czGb-8KJDKra4t_"
67 "3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw==" 65 "3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw=="
68 "@com.example.android"; 66 "@com.example.android";
69 android_form.affiliated_web_realm = "https://example.com/"; 67 android_form.affiliated_web_realm = "https://example.com/";
70 68
71 bool is_android_uri; 69 bool is_android_uri;
72 GURL link_url; 70 GURL link_url;
73 bool origin_is_clickable; 71 bool origin_is_clickable;
74 EXPECT_EQ("example.com", GetShownOriginAndLinkUrl(android_form, std::string(), 72 EXPECT_EQ("example.com",
75 &is_android_uri, &link_url, 73 GetShownOriginAndLinkUrl(android_form, &is_android_uri, &link_url,
76 &origin_is_clickable)); 74 &origin_is_clickable));
77 EXPECT_TRUE(is_android_uri); 75 EXPECT_TRUE(is_android_uri);
78 EXPECT_TRUE(origin_is_clickable); 76 EXPECT_TRUE(origin_is_clickable);
79 EXPECT_EQ(GURL(android_form.affiliated_web_realm), link_url); 77 EXPECT_EQ(GURL(android_form.affiliated_web_realm), link_url);
80 } 78 }
81 79
82 TEST(GetShownOriginAndLinkUrlTest, OriginFromNonAndroidForm) { 80 TEST(GetShownOriginAndLinkUrlTest, OriginFromNonAndroidForm) {
83 autofill::PasswordForm form; 81 autofill::PasswordForm form;
84 form.signon_realm = "https://example.com/"; 82 form.signon_realm = "https://example.com/";
85 form.origin = GURL("https://example.com/login?ref=1"); 83 form.origin = GURL("https://example.com/login?ref=1");
86 84
87 bool is_android_uri; 85 bool is_android_uri;
88 GURL link_url; 86 GURL link_url;
89 bool origin_is_clickable; 87 bool origin_is_clickable;
90 EXPECT_EQ("example.com", 88 EXPECT_EQ("example.com",
91 GetShownOriginAndLinkUrl(form, std::string(), &is_android_uri, 89 GetShownOriginAndLinkUrl(form, &is_android_uri, &link_url,
92 &link_url, &origin_is_clickable)); 90 &origin_is_clickable));
93 EXPECT_FALSE(is_android_uri); 91 EXPECT_FALSE(is_android_uri);
94 EXPECT_TRUE(origin_is_clickable); 92 EXPECT_TRUE(origin_is_clickable);
95 EXPECT_EQ(form.origin, link_url); 93 EXPECT_EQ(form.origin, link_url);
96 } 94 }
97 95
98 } // namespace password_manager 96 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/password_ui_utils.cc ('k') | components/search_engines/keyword_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698