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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc

Issue 1181623004: [Password Manager] Replace "this site" in save password prompt with password's origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses Vaclav's review comments. Created 5 years, 5 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
(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/string_util.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/range/range.h"
11 #include "url/gurl.h"
12
13 // Test for GetSavePasswordDialogTitleTextAndLinkRange().
14 TEST(ManagePasswordsViewUtilTest, GetSavePasswordDialogTitleTextAndLinkRange) {
15 const struct {
16 const char* const user_visible_url;
17 const char* const form_origin_url;
18 bool is_smartlock_branding_enabled;
19 const char* const expected_title_text_ends_with;
20 size_t expected_link_range_start;
21 size_t expected_link_range_end;
22 } test_cases[] = {// Same domains.
vabr (Chromium) 2015/06/30 10:47:10 nit: Comments need to separated by 2 spaces from t
Pritam Nikam 2015/06/30 15:26:06 This is output for "git cl format" command.
vabr (Chromium) 2015/07/01 08:42:21 This is unfortunate, but looks like a bug in Chrom
vabr (Chromium) 2015/07/01 08:52:37 Bug filed as http://crbug.com/506102.
Pritam Nikam 2015/07/01 10:01:53 Done.
23 {"http://example.com/landing",
24 "http://example.com/login#form?value=3",
25 false,
26 "this site?",
27 0,
28 0},
29 {"http://example.com/landing",
30 "http://example.com/login#form?value=3",
31 true,
32 "this site?",
33 12,
34 29},
35
36 // Different subdomains.
37 {"https://a.example.com/landing",
38 "https://b.example.com/login#form?value=3",
39 false,
40 "this site?",
41 0,
42 0},
43 {"https://a.example.com/landing",
44 "https://b.example.com/login#form?value=3",
45 true,
46 "this site?",
47 12,
48 29},
49
50 // Different domains.
51 {"https://another.org",
52 "https://example.com:/login#form?value=3",
53 false,
54 "https://example.com?",
55 0,
56 0},
57 {"https://another.org",
58 "https://example.com/login#form?value=3",
59 true,
60 "https://example.com?",
61 12,
62 29},
63
64 // Different domains and password form origin url with
65 // default port for the scheme.
66 {"https://another.org",
67 "https://example.com:443/login#form?value=3",
68 false,
69 "https://example.com?",
70 0,
71 0},
72 {"https://another.org",
73 "http://example.com:80/login#form?value=3",
74 true,
75 "http://example.com?",
76 12,
77 29},
78
79 // Different domains and password form origin url with
80 // non-default port for the scheme.
81 {"https://another.org",
82 "https://example.com:8001/login#form?value=3",
83 false,
84 "https://example.com:8001?",
85 0,
86 0},
87 {"https://another.org",
88 "https://example.com:8001/login#form?value=3",
89 true,
90 "https://example.com:8001?",
91 12,
92 29}};
93
94 for (size_t i = 0; i < arraysize(test_cases); ++i) {
95 SCOPED_TRACE(testing::Message()
96 << "user_visible_url = " << test_cases[i].user_visible_url
97 << ", form_origin_url = " << test_cases[i].form_origin_url);
98
99 base::string16 title;
100 gfx::Range title_link_range;
101 GetSavePasswordDialogTitleTextAndLinkRange(
102 GURL(test_cases[i].user_visible_url),
103 GURL(test_cases[i].form_origin_url),
104 test_cases[i].is_smartlock_branding_enabled, &title, &title_link_range);
105
106 // Verify against expectations.
107 EXPECT_TRUE(EndsWith(
108 title, base::ASCIIToUTF16(test_cases[i].expected_title_text_ends_with),
109 false));
110 EXPECT_EQ(test_cases[i].expected_link_range_start,
111 title_link_range.start());
112 EXPECT_EQ(test_cases[i].expected_link_range_end, title_link_range.end());
113 }
114 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_view_utils.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698