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

Unified Diff: components/password_manager/core/browser/affiliation_utils_unittest.cc

Issue 1130213004: [Smart Lock] Make android URL prettifying util available on ios. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on top of master Created 5 years, 7 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 | « components/password_manager/core/browser/affiliation_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/affiliation_utils_unittest.cc
diff --git a/components/password_manager/core/browser/affiliation_utils_unittest.cc b/components/password_manager/core/browser/affiliation_utils_unittest.cc
index 73240bc3560c67c78f19fdfe419e9610cd1e3a1a..774a3b88f17456bf99671ec9098a604349c77653 100644
--- a/components/password_manager/core/browser/affiliation_utils_unittest.cc
+++ b/components/password_manager/core/browser/affiliation_utils_unittest.cc
@@ -6,6 +6,8 @@
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
+#include "base/strings/utf_string_conversions.h"
+#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/common/password_manager_switches.h"
#include "components/variations/variations_associated_data.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,6 +17,7 @@ namespace password_manager {
namespace {
const char kFieldTrialName[] = "AffiliationBasedMatching";
+const std::string kSchemeHostExample = "http://example.com";
const char kTestFacetURI1[] = "https://alpha.example.com/";
const char kTestFacetURI2[] = "https://beta.example.com/";
const char kTestFacetURI3[] = "https://gamma.example.com/";
@@ -323,4 +326,50 @@ TEST(AffiliationUtilsTest, IsAffiliationRequestsForDummyFacetsEnabled) {
}
}
+class GetHumanReadableOriginTest : public testing::Test {
+ public:
+ GetHumanReadableOriginTest() {
+ form_template_.origin = GURL(kSchemeHostExample);
+ form_template_.action = GURL(kSchemeHostExample);
+ form_template_.username_element = base::ASCIIToUTF16("Email");
+ form_template_.password_element = base::ASCIIToUTF16("Password");
+ form_template_.submit_element = base::ASCIIToUTF16("signIn");
+ form_template_.signon_realm = kSchemeHostExample;
+ }
+ const autofill::PasswordForm& form_remplate() { return form_template_; }
+
+ private:
+ autofill::PasswordForm form_template_;
+};
+
+TEST_F(GetHumanReadableOriginTest, OriginFromHtmlForm) {
+ autofill::PasswordForm html_form(form_remplate());
+ html_form.origin = GURL(kSchemeHostExample + "/LoginAuth");
+ html_form.action = GURL(kSchemeHostExample + "/Login");
+ html_form.scheme = autofill::PasswordForm::SCHEME_HTML;
+ EXPECT_EQ(GetHumanReadableOrigin(html_form, ""), "example.com/LoginAuth");
+}
+
+TEST_F(GetHumanReadableOriginTest, OriginFromDigestForm) {
+ autofill::PasswordForm non_html_form(form_remplate());
+ non_html_form.scheme = autofill::PasswordForm::SCHEME_DIGEST;
+ non_html_form.action = GURL();
+ non_html_form.signon_realm = kSchemeHostExample + "42";
+ EXPECT_EQ(GetHumanReadableOrigin(non_html_form, ""), "example.com");
+}
+
+TEST_F(GetHumanReadableOriginTest, OriginFromAndroidForm) {
+ autofill::PasswordForm android_form(form_remplate());
+ android_form.action = GURL();
+ android_form.origin = GURL();
+ android_form.scheme = autofill::PasswordForm::SCHEME_OTHER;
+ android_form.signon_realm =
+ "android://"
+ "m3HSJL1i83hdltRq0-o9czGb-8KJDKra4t_"
+ "3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G9zvN7AQw=="
+ "@com.example.android";
+ EXPECT_EQ(GetHumanReadableOrigin(android_form, ""),
+ "android://com.example.android");
+}
+
} // namespace password_manager
« no previous file with comments | « components/password_manager/core/browser/affiliation_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698