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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc b/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e32435c9c14b254aef84c6cf4ad8b7fb40b67038
--- /dev/null
+++ b/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc
@@ -0,0 +1,114 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
+
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/range/range.h"
+#include "url/gurl.h"
+
+// Test for GetSavePasswordDialogTitleTextAndLinkRange().
+TEST(ManagePasswordsViewUtilTest, GetSavePasswordDialogTitleTextAndLinkRange) {
+ const struct {
+ const char* const user_visible_url;
+ const char* const form_origin_url;
+ bool is_smartlock_branding_enabled;
+ const char* const expected_title_text_ends_with;
+ size_t expected_link_range_start;
+ size_t expected_link_range_end;
+ } 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.
+ {"http://example.com/landing",
+ "http://example.com/login#form?value=3",
+ false,
+ "this site?",
+ 0,
+ 0},
+ {"http://example.com/landing",
+ "http://example.com/login#form?value=3",
+ true,
+ "this site?",
+ 12,
+ 29},
+
+ // Different subdomains.
+ {"https://a.example.com/landing",
+ "https://b.example.com/login#form?value=3",
+ false,
+ "this site?",
+ 0,
+ 0},
+ {"https://a.example.com/landing",
+ "https://b.example.com/login#form?value=3",
+ true,
+ "this site?",
+ 12,
+ 29},
+
+ // Different domains.
+ {"https://another.org",
+ "https://example.com:/login#form?value=3",
+ false,
+ "https://example.com?",
+ 0,
+ 0},
+ {"https://another.org",
+ "https://example.com/login#form?value=3",
+ true,
+ "https://example.com?",
+ 12,
+ 29},
+
+ // Different domains and password form origin url with
+ // default port for the scheme.
+ {"https://another.org",
+ "https://example.com:443/login#form?value=3",
+ false,
+ "https://example.com?",
+ 0,
+ 0},
+ {"https://another.org",
+ "http://example.com:80/login#form?value=3",
+ true,
+ "http://example.com?",
+ 12,
+ 29},
+
+ // Different domains and password form origin url with
+ // non-default port for the scheme.
+ {"https://another.org",
+ "https://example.com:8001/login#form?value=3",
+ false,
+ "https://example.com:8001?",
+ 0,
+ 0},
+ {"https://another.org",
+ "https://example.com:8001/login#form?value=3",
+ true,
+ "https://example.com:8001?",
+ 12,
+ 29}};
+
+ for (size_t i = 0; i < arraysize(test_cases); ++i) {
+ SCOPED_TRACE(testing::Message()
+ << "user_visible_url = " << test_cases[i].user_visible_url
+ << ", form_origin_url = " << test_cases[i].form_origin_url);
+
+ base::string16 title;
+ gfx::Range title_link_range;
+ GetSavePasswordDialogTitleTextAndLinkRange(
+ GURL(test_cases[i].user_visible_url),
+ GURL(test_cases[i].form_origin_url),
+ test_cases[i].is_smartlock_branding_enabled, &title, &title_link_range);
+
+ // Verify against expectations.
+ EXPECT_TRUE(EndsWith(
+ title, base::ASCIIToUTF16(test_cases[i].expected_title_text_ends_with),
+ false));
+ EXPECT_EQ(test_cases[i].expected_link_range_start,
+ title_link_range.start());
+ EXPECT_EQ(test_cases[i].expected_link_range_end, title_link_range.end());
+ }
+}
« 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