Commit b54154ac authored by Sebastien Seguin-Gagnon's avatar Sebastien Seguin-Gagnon Committed by Commit Bot

Revert "Make SaveCardBubble browsertest use the sync state"

This reverts commit 995f8099.

Reason for revert: Breaks browser tests on continues builders (consistent failures) See crbug.com/908787

Original change's description:
> Make SaveCardBubble browsertest use the sync state
> 
> The browsertests used to rely on the save manager being hardcoded to
> upload to Google if the observer_for_testing was set. This makes it
> impossible to test that the logic for showing the upload prompt works
> properly.
> 
> BUG=906630, 859761
> 
> Change-Id: Id7352a869388aac4ff36e1284750e22ac68c91b3
> Reviewed-on: https://chromium-review.googlesource.com/c/1348335
> Commit-Queue: Florian Uunk <feuunk@chromium.org>
> Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
> Reviewed-by: Sebastien Seguin-Gagnon <sebsg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#610866}

TBR=vasilii@chromium.org,sebsg@chromium.org,feuunk@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 906630, 859761
Change-Id: I145d2b56295af6014b6a94c44beb38b1bf6b9e01
Reviewed-on: https://chromium-review.googlesource.com/c/1352680Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611844}
parent 3ee1c1d5
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h" #include "base/test/metrics/user_action_tester.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/ui/autofill/popup_constants.h" #include "chrome/browser/ui/autofill/popup_constants.h"
#include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -40,13 +39,6 @@ ...@@ -40,13 +39,6 @@
using base::Bucket; using base::Bucket;
using testing::ElementsAre; using testing::ElementsAre;
namespace {
const char kCreditCardUploadForm[] =
"/credit_card_upload_form_address_and_cc.html";
const char kCreditCardAndShippingUploadForm[] =
"/credit_card_upload_form_shipping_address.html";
} // namespace
namespace autofill { namespace autofill {
class SaveCardBubbleViewsFullFormBrowserTest class SaveCardBubbleViewsFullFormBrowserTest
...@@ -60,6 +52,38 @@ class SaveCardBubbleViewsFullFormBrowserTest ...@@ -60,6 +52,38 @@ class SaveCardBubbleViewsFullFormBrowserTest
DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleViewsFullFormBrowserTest); DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleViewsFullFormBrowserTest);
}; };
class SaveCardBubbleViewsFullFormWithShippingBrowserTest
: public SaveCardBubbleViewsBrowserTestBase {
protected:
SaveCardBubbleViewsFullFormWithShippingBrowserTest()
: SaveCardBubbleViewsBrowserTestBase(
"/credit_card_upload_form_shipping_address.html") {}
private:
DISALLOW_COPY_AND_ASSIGN(SaveCardBubbleViewsFullFormWithShippingBrowserTest);
};
// Tests the local save bubble. Ensures that local save appears if the RPC to
// Google Payments fails unexpectedly.
IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest,
Local_SubmittingFormShowsBubbleIfGetUploadDetailsRpcFails) {
// Set up the Payments RPC.
SetUploadDetailsRpcServerError();
// Submitting the form and having the call to Payments fail should show the
// local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm();
WaitForObservedEvent();
EXPECT_TRUE(
FindViewInBubbleById(DialogViewId::MAIN_CONTENT_VIEW_LOCAL)->visible());
}
// Tests the local save bubble. Ensures that clicking the [Save] button // Tests the local save bubble. Ensures that clicking the [Save] button
// successfully causes the bubble to go away. // successfully causes the bubble to go away.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
...@@ -68,10 +92,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -68,10 +92,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndDisableFeature( scoped_feature_list_.InitAndDisableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -102,11 +132,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -102,11 +132,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardImprovedUserConsent); features::kAutofillSaveCardImprovedUserConsent);
// Set up the Payments RPC.
SetUploadDetailsRpcPaymentsDeclines();
// Submitting the form and having Payments decline offering to save should // Submitting the form and having Payments decline offering to save should
// show the local save bubble. // show the local save bubble.
// (Must wait for response from Payments before accessing the controller.) // (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE}); ResetEventWaiterForSequence(
NavigateTo(kCreditCardUploadForm); {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -131,10 +166,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -131,10 +166,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -161,20 +202,20 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -161,20 +202,20 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
#endif #endif
// Tests the sign in promo bubble. Ensures that the sign-in promo // Tests the sign in promo bubble. Ensures that the sign-in promo
// is not shown when the user is signed-in and syncing, even if the local save // is not shown when the user is signed-in and syncing, even if
// bubble is shown. // the local save bubble is shown.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Local_NoSigninPromoShowsWhenUserIsSyncing) { Local_NoSigninPromoShowsWhenUserIsSyncing) {
// Enable the sign-in promo. // Enable the sign-in promo.
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsDeclines(); SetUploadDetailsRpcPaymentsDeclines();
// Sign the user in.
SignInWithFullName("John Smith");
// Submitting the form and having Payments decline offering to save should // Submitting the form and having Payments decline offering to save should
// show the local save bubble. // show the local save bubble.
// (Must wait for response from Payments before accessing the controller.) // (Must wait for response from Payments before accessing the controller.)
...@@ -182,7 +223,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -182,7 +223,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE, DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE}); DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -209,10 +249,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -209,10 +249,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -244,10 +290,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -244,10 +290,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -285,10 +337,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -285,10 +337,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -332,10 +390,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -332,10 +390,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -393,10 +457,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -393,10 +457,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -446,10 +516,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -446,10 +516,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -489,10 +565,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -489,10 +565,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardSignInAfterLocalSave); features::kAutofillSaveCardSignInAfterLocalSave);
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -537,10 +619,17 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -537,10 +619,17 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// Disable the updated UI. // Disable the updated UI.
scoped_feature_list_.InitAndDisableFeature( scoped_feature_list_.InitAndDisableFeature(
features::kAutofillSaveCardImprovedUserConsent); features::kAutofillSaveCardImprovedUserConsent);
// Submitting the form without signed in user should show the local save
// bubble. // Set up the Payments RPC.
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE}); SetUploadDetailsRpcPaymentsDeclines();
NavigateTo(kCreditCardUploadForm);
// Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -556,10 +645,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -556,10 +645,16 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// https://crbug.com/842577 . // https://crbug.com/842577 .
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Local_SynchronousCloseAfterAsynchronousClose) { Local_SynchronousCloseAfterAsynchronousClose) {
// Submitting the form without signed in user should show the local save // Set up the Payments RPC.
// bubble. SetUploadDetailsRpcPaymentsDeclines();
ResetEventWaiterForSequence({DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm); // Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
...@@ -588,9 +683,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -588,9 +683,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// to Google Payments. // to Google Payments.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Upload_ClickingSaveClosesBubble) { Upload_ClickingSaveClosesBubble) {
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -599,7 +691,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -599,7 +691,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -625,9 +716,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -625,9 +716,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardImprovedUserConsent); features::kAutofillSaveCardImprovedUserConsent);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -636,7 +724,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -636,7 +724,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -661,9 +748,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -661,9 +748,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndDisableFeature( scoped_feature_list_.InitAndDisableFeature(
features::kAutofillSaveCardImprovedUserConsent); features::kAutofillSaveCardImprovedUserConsent);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -672,7 +756,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -672,7 +756,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -687,9 +770,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -687,9 +770,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// button successfully causes the bubble to go away. // button successfully causes the bubble to go away.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Upload_ClickingCloseClosesBubble) { Upload_ClickingCloseClosesBubble) {
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -698,7 +778,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -698,7 +778,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -713,9 +792,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -713,9 +792,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// cardholder name textfield if it is not needed. // cardholder name textfield if it is not needed.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Upload_ShouldNotRequestCardholderNameInHappyPath) { Upload_ShouldNotRequestCardholderNameInHappyPath) {
// Start sync.
harness_->SetupSync();
// Enable the EditableCardholderName experiment. // Enable the EditableCardholderName experiment.
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
...@@ -728,7 +804,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -728,7 +804,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -748,9 +823,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -748,9 +823,6 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -760,7 +832,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -760,7 +832,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -772,20 +843,16 @@ IN_PROC_BROWSER_TEST_F( ...@@ -772,20 +843,16 @@ IN_PROC_BROWSER_TEST_F(
// Tests the upload save bubble. Ensures that the bubble surfaces a textfield // Tests the upload save bubble. Ensures that the bubble surfaces a textfield
// requesting cardholder name if cardholder name is conflicting. // requesting cardholder name if cardholder name is conflicting.
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest, SaveCardBubbleViewsFullFormWithShippingBrowserTest,
Upload_SubmittingFormWithConflictingNamesRequestsCardholderNameIfExpOn) { Upload_SubmittingFormWithConflictingNamesRequestsCardholderNameIfExpOn) {
// Enable the EditableCardholderName experiment. // Enable the EditableCardholderName experiment.
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
// Submit first shipping address form with a conflicting name. // Submit first shipping address form with a conflicting name.
NavigateTo(kCreditCardAndShippingUploadForm);
FillAndSubmitFormWithConflictingName(); FillAndSubmitFormWithConflictingName();
// Submitting the second form should still show the upload save bubble and // Submitting the second form should still show the upload save bubble and
...@@ -795,7 +862,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -795,7 +862,6 @@ IN_PROC_BROWSER_TEST_F(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
FindViewInBubbleById(DialogViewId::MAIN_CONTENT_VIEW_UPLOAD)->visible()); FindViewInBubbleById(DialogViewId::MAIN_CONTENT_VIEW_UPLOAD)->visible());
...@@ -808,9 +874,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -808,9 +874,6 @@ IN_PROC_BROWSER_TEST_F(
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest, SaveCardBubbleViewsFullFormBrowserTest,
Upload_SaveButtonIsDisabledIfNoCardholderNameAndCardholderNameRequested) { Upload_SaveButtonIsDisabledIfNoCardholderNameAndCardholderNameRequested) {
// Start sync.
harness_->SetupSync();
// Enable the EditableCardholderName experiment. // Enable the EditableCardholderName experiment.
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
...@@ -824,7 +887,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -824,7 +887,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -853,9 +915,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -853,9 +915,6 @@ IN_PROC_BROWSER_TEST_F(
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest, SaveCardBubbleViewsFullFormBrowserTest,
Upload_EnteringCardholderNameAndClickingSaveClosesBubbleIfCardholderNameRequested) { Upload_EnteringCardholderNameAndClickingSaveClosesBubbleIfCardholderNameRequested) {
// Start sync.
harness_->SetupSync();
// Enable the EditableCardholderName experiment. // Enable the EditableCardholderName experiment.
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
...@@ -869,7 +928,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -869,7 +928,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -905,14 +963,12 @@ IN_PROC_BROWSER_TEST_F( ...@@ -905,14 +963,12 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
// Start sync.
harness_->SetupSync();
// Set the user's full name.
SetAccountFullName("John Smith");
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
// Sign the user in.
SignInWithFullName("John Smith");
// Submitting the form should show the upload save bubble, along with a // Submitting the form should show the upload save bubble, along with a
// textfield specifically requesting the cardholder name. // textfield specifically requesting the cardholder name.
// (Must wait for response from Payments before accessing the controller.) // (Must wait for response from Payments before accessing the controller.)
...@@ -920,7 +976,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -920,7 +976,6 @@ IN_PROC_BROWSER_TEST_F(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD)); EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
...@@ -948,9 +1003,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -948,9 +1003,6 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -964,7 +1016,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -964,7 +1016,6 @@ IN_PROC_BROWSER_TEST_F(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD)); EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
...@@ -990,21 +1041,18 @@ IN_PROC_BROWSER_TEST_F( ...@@ -990,21 +1041,18 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
// Start sync.
harness_->SetupSync();
// Set the user's full name.
SetAccountFullName("John Smith");
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
// Sign the user in.
SignInWithFullName("John Smith");
// Submitting the form should show the upload save bubble, along with a // Submitting the form should show the upload save bubble, along with a
// textfield specifically requesting the cardholder name. // textfield specifically requesting the cardholder name.
// (Must wait for response from Payments before accessing the controller.) // (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD)); EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
...@@ -1028,21 +1076,18 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1028,21 +1076,18 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableCardholderName); features::kAutofillUpstreamEditableCardholderName);
// Start sync.
harness_->SetupSync();
// Set the user's full name.
SetAccountFullName("John Smith");
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
// Sign the user in.
SignInWithFullName("John Smith");
// Submitting the form should show the upload save bubble, along with a // Submitting the form should show the upload save bubble, along with a
// textfield specifically requesting the cardholder name. // textfield specifically requesting the cardholder name.
// (Must wait for response from Payments before accessing the controller.) // (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD)); EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
...@@ -1075,14 +1120,12 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1075,14 +1120,12 @@ IN_PROC_BROWSER_TEST_F(
// Disabled // Disabled
{}); {});
// Start sync.
harness_->SetupSync();
// Set the user's full name.
SetAccountFullName("John Smith");
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
// Sign the user in.
SignInWithFullName("John Smith");
// Submitting the form should show the upload save bubble, along with a // Submitting the form should show the upload save bubble, along with a
// textfield specifically requesting the cardholder name. // textfield specifically requesting the cardholder name.
// (Must wait for response from Payments before accessing the controller.) // (Must wait for response from Payments before accessing the controller.)
...@@ -1090,7 +1133,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1090,7 +1133,6 @@ IN_PROC_BROWSER_TEST_F(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
base::HistogramTester histogram_tester; base::HistogramTester histogram_tester;
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD)); EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CARDHOLDER_NAME_TEXTFIELD));
...@@ -1112,62 +1154,11 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1112,62 +1154,11 @@ IN_PROC_BROWSER_TEST_F(
// gfx::Range of the link. When/if that can be worked around, // gfx::Range of the link. When/if that can be worked around,
// create an Upload_ClickingTosLinkClosesBubble test. // create an Upload_ClickingTosLinkClosesBubble test.
// Tests the upload save logic. Ensures that Chrome offers a local save when the
// data is complete, even if Payments rejects the data.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Logic_ShouldOfferLocalSaveIfPaymentsDeclines) {
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC.
SetUploadDetailsRpcPaymentsDeclines();
// Submitting the form and having Payments decline offering to save should
// show the local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm();
WaitForObservedEvent();
EXPECT_TRUE(
FindViewInBubbleById(DialogViewId::MAIN_CONTENT_VIEW_LOCAL)->visible());
}
// Tests the upload save logic. Ensures that Chrome offers a local save when the
// data is complete, even if the Payments upload fails unexpectedly.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Logic_ShouldOfferLocalSaveIfPaymentsFails) {
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC.
SetUploadDetailsRpcServerError();
// Submitting the form and having the call to Payments fail should show the
// local save bubble.
// (Must wait for response from Payments before accessing the controller.)
ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE,
DialogEvent::OFFERED_LOCAL_SAVE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm();
WaitForObservedEvent();
EXPECT_TRUE(
FindViewInBubbleById(DialogViewId::MAIN_CONTENT_VIEW_LOCAL)->visible());
}
// Tests the upload save logic. Ensures that Chrome delegates the offer-to-save // Tests the upload save logic. Ensures that Chrome delegates the offer-to-save
// call to Payments, and offers to upload save the card if Payments allows it. // call to Payments, and offers to upload save the card if Payments allows it.
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest, SaveCardBubbleViewsFullFormBrowserTest,
Logic_CanOfferToSaveEvenIfNothingFoundIfPaymentsAccepts) { Logic_CanOfferToSaveEvenIfNothingFoundIfPaymentsAccepts) {
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -1178,7 +1169,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1178,7 +1169,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithCardDetailsOnly(); FillAndSubmitFormWithCardDetailsOnly();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -1192,9 +1182,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1192,9 +1182,6 @@ IN_PROC_BROWSER_TEST_F(
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest, SaveCardBubbleViewsFullFormBrowserTest,
Logic_ShouldNotOfferToSaveIfNothingFoundAndPaymentsDeclines) { Logic_ShouldNotOfferToSaveIfNothingFoundAndPaymentsDeclines) {
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsDeclines(); SetUploadDetailsRpcPaymentsDeclines();
...@@ -1205,7 +1192,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1205,7 +1192,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithCardDetailsOnly(); FillAndSubmitFormWithCardDetailsOnly();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_FALSE(GetSaveCardBubbleViews()); EXPECT_FALSE(GetSaveCardBubbleViews());
...@@ -1215,13 +1201,9 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1215,13 +1201,9 @@ IN_PROC_BROWSER_TEST_F(
// upload save should be offered, even if CVC is not detected. // upload save should be offered, even if CVC is not detected.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Logic_ShouldAttemptToOfferToSaveIfCvcNotFound) { Logic_ShouldAttemptToOfferToSaveIfCvcNotFound) {
// Start sync.
harness_->SetupSync();
// Submitting the form should still start the flow of asking Payments if // Submitting the form should still start the flow of asking Payments if
// Chrome should offer to save the card to Google, even though CVC is missing. // Chrome should offer to save the card to Google, even though CVC is missing.
ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE}); ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutCvc(); FillAndSubmitFormWithoutCvc();
WaitForObservedEvent(); WaitForObservedEvent();
} }
...@@ -1230,14 +1212,10 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1230,14 +1212,10 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// upload save should be offered, even if the detected CVC is invalid. // upload save should be offered, even if the detected CVC is invalid.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Logic_ShouldAttemptToOfferToSaveIfInvalidCvcFound) { Logic_ShouldAttemptToOfferToSaveIfInvalidCvcFound) {
// Start sync.
harness_->SetupSync();
// Submitting the form should still start the flow of asking Payments if // Submitting the form should still start the flow of asking Payments if
// Chrome should offer to save the card to Google, even though the provided // Chrome should offer to save the card to Google, even though the provided
// CVC is invalid. // CVC is invalid.
ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE}); ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithInvalidCvc(); FillAndSubmitFormWithInvalidCvc();
WaitForObservedEvent(); WaitForObservedEvent();
} }
...@@ -1247,14 +1225,10 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1247,14 +1225,10 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// detected. // detected.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Logic_ShouldAttemptToOfferToSaveIfNameNotFound) { Logic_ShouldAttemptToOfferToSaveIfNameNotFound) {
// Start sync.
harness_->SetupSync();
// Submitting the form should still start the flow of asking Payments if // Submitting the form should still start the flow of asking Payments if
// Chrome should offer to save the card to Google, even though name is // Chrome should offer to save the card to Google, even though name is
// missing. // missing.
ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE}); ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutName(); FillAndSubmitFormWithoutName();
WaitForObservedEvent(); WaitForObservedEvent();
} }
...@@ -1262,13 +1236,9 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1262,13 +1236,9 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// Tests the upload save logic. Ensures that Chrome lets Payments decide whether // Tests the upload save logic. Ensures that Chrome lets Payments decide whether
// upload save should be offered, even if multiple conflicting names are // upload save should be offered, even if multiple conflicting names are
// detected. // detected.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormWithShippingBrowserTest,
Logic_ShouldAttemptToOfferToSaveIfNamesConflict) { Logic_ShouldAttemptToOfferToSaveIfNamesConflict) {
// Start sync.
harness_->SetupSync();
// Submit first shipping address form with a conflicting name. // Submit first shipping address form with a conflicting name.
NavigateTo(kCreditCardAndShippingUploadForm);
FillAndSubmitFormWithConflictingName(); FillAndSubmitFormWithConflictingName();
// Submitting the form should still start the flow of asking Payments if // Submitting the form should still start the flow of asking Payments if
...@@ -1283,14 +1253,10 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1283,14 +1253,10 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// upload save should be offered, even if billing address is not detected. // upload save should be offered, even if billing address is not detected.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Logic_ShouldAttemptToOfferToSaveIfAddressNotFound) { Logic_ShouldAttemptToOfferToSaveIfAddressNotFound) {
// Start sync.
harness_->SetupSync();
// Submitting the form should still start the flow of asking Payments if // Submitting the form should still start the flow of asking Payments if
// Chrome should offer to save the card to Google, even though billing address // Chrome should offer to save the card to Google, even though billing address
// is missing. // is missing.
ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE}); ResetEventWaiterForSequence({DialogEvent::REQUESTED_UPLOAD_SAVE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutAddress(); FillAndSubmitFormWithoutAddress();
WaitForObservedEvent(); WaitForObservedEvent();
} }
...@@ -1298,13 +1264,9 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1298,13 +1264,9 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// Tests the upload save logic. Ensures that Chrome lets Payments decide whether // Tests the upload save logic. Ensures that Chrome lets Payments decide whether
// upload save should be offered, even if multiple conflicting billing address // upload save should be offered, even if multiple conflicting billing address
// postal codes are detected. // postal codes are detected.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormWithShippingBrowserTest,
Logic_ShouldAttemptToOfferToSaveIfPostalCodesConflict) { Logic_ShouldAttemptToOfferToSaveIfPostalCodesConflict) {
// Start sync.
harness_->SetupSync();
// Submit first shipping address form with a conflicting postal code. // Submit first shipping address form with a conflicting postal code.
NavigateTo(kCreditCardAndShippingUploadForm);
FillAndSubmitFormWithConflictingPostalCode(); FillAndSubmitFormWithConflictingPostalCode();
// Submitting the form should still start the flow of asking Payments if // Submitting the form should still start the flow of asking Payments if
...@@ -1320,9 +1282,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1320,9 +1282,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(
SaveCardBubbleViewsFullFormBrowserTest, SaveCardBubbleViewsFullFormBrowserTest,
Upload_DecliningUploadDoesNotLogUserAcceptedCardOriginUMA) { Upload_DecliningUploadDoesNotLogUserAcceptedCardOriginUMA) {
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -1332,7 +1291,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1332,7 +1291,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -1358,9 +1316,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1358,9 +1316,6 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableExpirationDate); features::kAutofillUpstreamEditableExpirationDate);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -1371,7 +1326,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1371,7 +1326,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutExpirationDate(); FillAndSubmitFormWithoutExpirationDate();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -1395,9 +1349,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1395,9 +1349,6 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableExpirationDate); features::kAutofillUpstreamEditableExpirationDate);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -1408,7 +1359,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1408,7 +1359,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithExpiredExpirationDate(); FillAndSubmitFormWithExpiredExpirationDate();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -1434,7 +1384,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1434,7 +1384,6 @@ IN_PROC_BROWSER_TEST_F(
// The credit card will not be imported if the expiration date is expired and // The credit card will not be imported if the expiration date is expired and
// experiment is off. // experiment is off.
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithExpiredExpirationDate(); FillAndSubmitFormWithExpiredExpirationDate();
EXPECT_FALSE(GetSaveCardBubbleViews()); EXPECT_FALSE(GetSaveCardBubbleViews());
} }
...@@ -1450,7 +1399,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1450,7 +1399,6 @@ IN_PROC_BROWSER_TEST_F(
// The credit card will not be imported if there is no expiration date and // The credit card will not be imported if there is no expiration date and
// experiment is off. // experiment is off.
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutExpirationDate(); FillAndSubmitFormWithoutExpirationDate();
EXPECT_FALSE(GetSaveCardBubbleViews()); EXPECT_FALSE(GetSaveCardBubbleViews());
} }
...@@ -1463,9 +1411,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1463,9 +1411,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableExpirationDate); features::kAutofillUpstreamEditableExpirationDate);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -1474,7 +1419,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1474,7 +1419,6 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitForm(); FillAndSubmitForm();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -1500,9 +1444,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1500,9 +1444,6 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableExpirationDate); features::kAutofillUpstreamEditableExpirationDate);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -1513,7 +1454,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1513,7 +1454,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutExpirationDate(); FillAndSubmitFormWithoutExpirationDate();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
...@@ -1563,9 +1503,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1563,9 +1503,6 @@ IN_PROC_BROWSER_TEST_F(
scoped_feature_list_.InitAndEnableFeature( scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableExpirationDate); features::kAutofillUpstreamEditableExpirationDate);
// Start sync.
harness_->SetupSync();
// Set up the Payments RPC. // Set up the Payments RPC.
SetUploadDetailsRpcPaymentsAccepts(); SetUploadDetailsRpcPaymentsAccepts();
...@@ -1576,7 +1513,6 @@ IN_PROC_BROWSER_TEST_F( ...@@ -1576,7 +1513,6 @@ IN_PROC_BROWSER_TEST_F(
ResetEventWaiterForSequence( ResetEventWaiterForSequence(
{DialogEvent::REQUESTED_UPLOAD_SAVE, {DialogEvent::REQUESTED_UPLOAD_SAVE,
DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE}); DialogEvent::RECEIVED_GET_UPLOAD_DETAILS_RESPONSE});
NavigateTo(kCreditCardUploadForm);
FillAndSubmitFormWithoutExpirationDate(); FillAndSubmitFormWithoutExpirationDate();
WaitForObservedEvent(); WaitForObservedEvent();
EXPECT_TRUE( EXPECT_TRUE(
......
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/account_fetcher_service_factory.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_account_fetcher_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/ui/autofill/chrome_autofill_client.h" #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
#include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -29,19 +30,14 @@ ...@@ -29,19 +30,14 @@
#include "components/autofill/core/browser/credit_card_save_manager.h" #include "components/autofill/core/browser/credit_card_save_manager.h"
#include "components/autofill/core/browser/form_data_importer.h" #include "components/autofill/core/browser/form_data_importer.h"
#include "components/autofill/core/browser/payments/payments_client.h" #include "components/autofill/core/browser/payments/payments_client.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/network_session_configurator/common/network_switches.h" #include "components/network_session_configurator/common/network_switches.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_account_fetcher_service.h" #include "components/signin/core/browser/fake_account_fetcher_service.h"
#include "components/sync/test/fake_server/fake_server.h"
#include "components/sync/test/fake_server/fake_server_network_resources.h"
#include "content/public/test/browser_test_utils.h" #include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
#include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/test_url_fetcher_factory.h"
#include "services/device/public/cpp/test/scoped_geolocation_overrider.h" #include "services/device/public/cpp/test/scoped_geolocation_overrider.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "services/identity/public/cpp/identity_test_utils.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
#include "ui/views/bubble/bubble_frame_view.h" #include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
...@@ -75,38 +71,21 @@ const double kFakeGeolocationLongitude = 4.56; ...@@ -75,38 +71,21 @@ const double kFakeGeolocationLongitude = 4.56;
SaveCardBubbleViewsBrowserTestBase::SaveCardBubbleViewsBrowserTestBase( SaveCardBubbleViewsBrowserTestBase::SaveCardBubbleViewsBrowserTestBase(
const std::string& test_file_path) const std::string& test_file_path)
: SyncTest(SINGLE_CLIENT), test_file_path_(test_file_path) {} : test_file_path_(test_file_path) {}
SaveCardBubbleViewsBrowserTestBase::~SaveCardBubbleViewsBrowserTestBase() {} SaveCardBubbleViewsBrowserTestBase::~SaveCardBubbleViewsBrowserTestBase() {}
void SaveCardBubbleViewsBrowserTestBase::SetUpOnMainThread() { void SaveCardBubbleViewsBrowserTestBase::SetUpOnMainThread() {
SyncTest::SetUpOnMainThread();
// Set up the HTTPS server (uses the embedded_test_server). // Set up the HTTPS server (uses the embedded_test_server).
ASSERT_TRUE(embedded_test_server()->InitializeAndListen()); ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
embedded_test_server()->ServeFilesFromSourceDirectory( embedded_test_server()->ServeFilesFromSourceDirectory(
"components/test/data/autofill"); "components/test/data/autofill");
embedded_test_server()->StartAcceptingConnections(); embedded_test_server()->StartAcceptingConnections();
ProfileSyncServiceFactory::GetForProfile(browser()->profile()) // Set up the URL fetcher. By providing an Impl, unexpected calls (sync, etc.)
->OverrideNetworkResourcesForTest( // won't cause the test to crash.
std::make_unique<fake_server::FakeServerNetworkResources>( url_fetcher_factory_ = std::make_unique<net::FakeURLFetcherFactory>(
GetFakeServer()->AsWeakPtr())); new net::URLFetcherImplFactory());
std::string username;
#if defined(OS_CHROMEOS)
// In ChromeOS browser tests, the profile may already by authenticated with
// stub account |user_manager::kStubUserEmail|.
AccountInfo info = IdentityManagerFactory::GetForProfile(browser()->profile())
->GetPrimaryAccountInfo();
username = info.email;
#endif
if (username.empty())
username = "user@gmail.com";
harness_ = ProfileSyncServiceHarness::Create(
browser()->profile(), username, "password",
ProfileSyncServiceHarness::SigninType::FAKE_SIGNIN);
// Set up the URL loader factory for the payments client so we can intercept // Set up the URL loader factory for the payments client so we can intercept
// those network requests too. // those network requests too.
...@@ -133,6 +112,8 @@ void SaveCardBubbleViewsBrowserTestBase::SetUpOnMainThread() { ...@@ -133,6 +112,8 @@ void SaveCardBubbleViewsBrowserTestBase::SetUpOnMainThread() {
// Set up the fake geolocation data. // Set up the fake geolocation data.
geolocation_overrider_ = std::make_unique<device::ScopedGeolocationOverrider>( geolocation_overrider_ = std::make_unique<device::ScopedGeolocationOverrider>(
kFakeGeolocationLatitude, kFakeGeolocationLongitude); kFakeGeolocationLatitude, kFakeGeolocationLongitude);
NavigateTo(test_file_path_);
} }
void SaveCardBubbleViewsBrowserTestBase::NavigateTo( void SaveCardBubbleViewsBrowserTestBase::NavigateTo(
...@@ -190,13 +171,54 @@ void SaveCardBubbleViewsBrowserTestBase::OnSCBCStrikeChangeComplete() { ...@@ -190,13 +171,54 @@ void SaveCardBubbleViewsBrowserTestBase::OnSCBCStrikeChangeComplete() {
event_waiter_->OnEvent(DialogEvent::STRIKE_CHANGE_COMPLETE); event_waiter_->OnEvent(DialogEvent::STRIKE_CHANGE_COMPLETE);
} }
void SaveCardBubbleViewsBrowserTestBase::SetAccountFullName( void SaveCardBubbleViewsBrowserTestBase::SetUpInProcessBrowserTestFixture() {
will_create_browser_context_services_subscription_ =
BrowserContextDependencyManager::GetInstance()
->RegisterWillCreateBrowserContextServicesCallbackForTesting(
base::BindRepeating(&SaveCardBubbleViewsBrowserTestBase::
OnWillCreateBrowserContextServices,
base::Unretained(this)));
}
void SaveCardBubbleViewsBrowserTestBase::OnWillCreateBrowserContextServices(
content::BrowserContext* context) {
// Replace the signin manager and account fetcher service with fakes.
SigninManagerFactory::GetInstance()->SetTestingFactory(
context, base::BindRepeating(&BuildFakeSigninManagerForTesting));
AccountFetcherServiceFactory::GetInstance()->SetTestingFactory(
context,
base::BindRepeating(&FakeAccountFetcherServiceBuilder::BuildForTests));
}
void SaveCardBubbleViewsBrowserTestBase::SignInWithFullName(
const std::string& full_name) { const std::string& full_name) {
identity::IdentityManager* identity_manager = // TODO(crbug.com/859761): Can this function be used to remove the
IdentityManagerFactory::GetForProfile(browser()->profile()); // observer_for_testing_ hack in
AccountInfo info = identity_manager->GetPrimaryAccountInfo(); // CreditCardSaveManager::IsCreditCardUploadEnabled()?
info.full_name = full_name; FakeSigninManagerForTesting* signin_manager =
identity::UpdateAccountInfoForAccount(identity_manager, info); static_cast<FakeSigninManagerForTesting*>(
SigninManagerFactory::GetInstance()->GetForProfile(
browser()->profile()));
// Note: Chrome OS tests seem to rely on these specific login values, so
// changing them is probably not recommended.
constexpr char kTestEmail[] = "stub-user@example.com";
constexpr char kTestGaiaId[] = "stub-user@example.com";
#if !defined(OS_CHROMEOS)
signin_manager->SignIn(kTestGaiaId, kTestEmail, "password");
#else
AccountTrackerService* account_tracker_service =
AccountTrackerServiceFactory::GetForProfile(browser()->profile());
signin_manager->SignIn(account_tracker_service->PickAccountIdForAccount(
kTestGaiaId, kTestEmail));
#endif
FakeAccountFetcherService* account_fetcher_service =
static_cast<FakeAccountFetcherService*>(
AccountFetcherServiceFactory::GetForProfile(browser()->profile()));
account_fetcher_service->FakeUserInfoFetchSuccess(
signin_manager->GetAuthenticatedAccountId(), kTestEmail, kTestGaiaId,
AccountTrackerService::kNoHostedDomainFound, full_name,
/*given_name=*/std::string(), "locale", "avatar.jpg");
} }
void SaveCardBubbleViewsBrowserTestBase::SubmitForm() { void SaveCardBubbleViewsBrowserTestBase::SubmitForm() {
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
#include "chrome/browser/ui/views/autofill/dialog_view_ids.h" #include "chrome/browser/ui/views/autofill/dialog_view_ids.h"
#include "chrome/browser/ui/views/autofill/save_card_bubble_views.h" #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h"
...@@ -38,7 +37,7 @@ namespace autofill { ...@@ -38,7 +37,7 @@ namespace autofill {
// Base class for any interactive SaveCardBubbleViews browser test that will // Base class for any interactive SaveCardBubbleViews browser test that will
// need to show and interact with the offer-to-save bubble. // need to show and interact with the offer-to-save bubble.
class SaveCardBubbleViewsBrowserTestBase class SaveCardBubbleViewsBrowserTestBase
: public SyncTest, : public InProcessBrowserTest,
public CreditCardSaveManager::ObserverForTest, public CreditCardSaveManager::ObserverForTest,
public SaveCardBubbleControllerImpl::ObserverForTest { public SaveCardBubbleControllerImpl::ObserverForTest {
public: public:
...@@ -78,8 +77,14 @@ class SaveCardBubbleViewsBrowserTestBase ...@@ -78,8 +77,14 @@ class SaveCardBubbleViewsBrowserTestBase
void OnBubbleClosed() override; void OnBubbleClosed() override;
void OnSCBCStrikeChangeComplete() override; void OnSCBCStrikeChangeComplete() override;
// Sets the full name of the signed-in account to the provided |full_name|. // BrowserTestBase:
void SetAccountFullName(const std::string& full_name); void SetUpInProcessBrowserTestFixture() override;
// Sets up the ability to sign in the user.
void OnWillCreateBrowserContextServices(content::BrowserContext* context);
// Signs in the user with the provided |full_name|.
void SignInWithFullName(const std::string& full_name);
// Will call JavaScript to fill and submit the form in different ways. // Will call JavaScript to fill and submit the form in different ways.
void SubmitForm(); void SubmitForm();
...@@ -158,8 +163,6 @@ class SaveCardBubbleViewsBrowserTestBase ...@@ -158,8 +163,6 @@ class SaveCardBubbleViewsBrowserTestBase
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
std::unique_ptr<ProfileSyncServiceHarness> harness_;
private: private:
std::unique_ptr<autofill::EventWaiter<DialogEvent>> event_waiter_; std::unique_ptr<autofill::EventWaiter<DialogEvent>> event_waiter_;
std::unique_ptr<net::FakeURLFetcherFactory> url_fetcher_factory_; std::unique_ptr<net::FakeURLFetcherFactory> url_fetcher_factory_;
......
...@@ -100,13 +100,10 @@ bool IsCreditCardUploadEnabled(const PrefService* pref_service, ...@@ -100,13 +100,10 @@ bool IsCreditCardUploadEnabled(const PrefService* pref_service,
// If the "allow all email domains" flag is off, restrict credit card upload // If the "allow all email domains" flag is off, restrict credit card upload
// only to Google Accounts with @googlemail, @gmail, @google, or @chromium // only to Google Accounts with @googlemail, @gmail, @google, or @chromium
// domains. // domains.
// example.com is on the list because ChromeOS tests rely on using this. That
// should be fine, since example.com is an IANA reserved domain.
if (!base::FeatureList::IsEnabled( if (!base::FeatureList::IsEnabled(
features::kAutofillUpstreamAllowAllEmailDomains) && features::kAutofillUpstreamAllowAllEmailDomains) &&
!(domain == "googlemail.com" || domain == "gmail.com" || !(domain == "googlemail.com" || domain == "gmail.com" ||
domain == "google.com" || domain == "chromium.org" || domain == "google.com" || domain == "chromium.org")) {
domain == "example.com")) {
return false; return false;
} }
......
...@@ -251,16 +251,12 @@ void CreditCardSaveManager::AttemptToOfferCardUploadSave( ...@@ -251,16 +251,12 @@ void CreditCardSaveManager::AttemptToOfferCardUploadSave(
} }
bool CreditCardSaveManager::IsCreditCardUploadEnabled() { bool CreditCardSaveManager::IsCreditCardUploadEnabled() {
#if defined(OS_IOS)
// If observer_for_testing_ is set, assume we are in a browsertest and // If observer_for_testing_ is set, assume we are in a browsertest and
// credit card upload should be enabled by default. // credit card upload should be enabled by default.
// TODO(crbug.com/859761): Remove dependency from iOS tests on this behavior. return observer_for_testing_ ||
if (observer_for_testing_) ::autofill::IsCreditCardUploadEnabled(
return true; client_->GetPrefs(), client_->GetSyncService(),
#endif // defined(OS_IOS) personal_data_manager_->GetAccountInfoForPaymentsServer().email);
return ::autofill::IsCreditCardUploadEnabled(
client_->GetPrefs(), client_->GetSyncService(),
personal_data_manager_->GetAccountInfoForPaymentsServer().email);
} }
bool CreditCardSaveManager::IsUploadEnabledForNetwork( bool CreditCardSaveManager::IsUploadEnabledForNetwork(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment