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

Unified Diff: components/autofill/core/browser/autofill_assistant_unittest.cc

Issue 2253343003: Only show the credit card assist feature in secure contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove redudant comments Created 4 years, 4 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/autofill/core/browser/autofill_assistant.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_assistant_unittest.cc
diff --git a/components/autofill/core/browser/autofill_assistant_unittest.cc b/components/autofill/core/browser/autofill_assistant_unittest.cc
index 4f93f192dfbf5bf3ceb3e2df02bc18b3c30f9a80..7191e68cdf5b1e9e69b6d39d087cae600d7ece37 100644
--- a/components/autofill/core/browser/autofill_assistant_unittest.cc
+++ b/components/autofill/core/browser/autofill_assistant_unittest.cc
@@ -60,6 +60,7 @@ class AutofillAssistantTest : public testing::Test {
void EnableAutofillCreditCardAssist() {
scoped_feature_list_.InitAndEnableFeature(kAutofillCreditCardAssist);
+ autofill_client_.set_is_context_secure(true);
}
// Returns an initialized FormStructure with credit card form data. To be
@@ -132,6 +133,24 @@ TEST_F(AutofillAssistantTest, CanShowCreditCardAssist_FeatureOn) {
EXPECT_TRUE(autofill_assistant_.CanShowCreditCardAssist(form_structures));
}
+// Tests that with the feature enabled and proper input,
+// CanShowCreditCardAssist() behaves as expected for secure vs insecure
+// contexts.
+TEST_F(AutofillAssistantTest, CanShowCreditCardAssist_FeatureOn_NotSecure) {
+ EnableAutofillCreditCardAssist();
+ std::unique_ptr<FormStructure> form_structure = CreateValidCreditCardForm();
+ std::vector<FormStructure*> form_structures;
+ form_structures.push_back(form_structure.get());
+
+ // Cannot be shown if the context is not secure.
+ autofill_client_.set_is_context_secure(false);
+ EXPECT_FALSE(autofill_assistant_.CanShowCreditCardAssist(form_structures));
+
+ // Can be shown if the context is secure.
+ autofill_client_.set_is_context_secure(true);
+ EXPECT_TRUE(autofill_assistant_.CanShowCreditCardAssist(form_structures));
+}
+
TEST_F(AutofillAssistantTest, ShowAssistForCreditCard_ValidCard) {
EnableAutofillCreditCardAssist();
std::unique_ptr<FormStructure> form_structure = CreateValidCreditCardForm();
« no previous file with comments | « components/autofill/core/browser/autofill_assistant.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698