chromium/chrome/browser/ui/views/payments/shipping_address_editor_view_controller_browsertest.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <algorithm>

#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/ui/views/payments/editor_view_controller.h"
#include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
#include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
#include "chrome/browser/ui/views/payments/validating_textfield.h"
#include "components/autofill/core/browser/address_data_manager.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/country_type.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/geo/autofill_country.h"
#include "components/autofill/core/browser/geo/test_region_data_loader.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/ui/country_combobox_model.h"
#include "components/autofill/core/browser/ui/region_combobox_model.h"
#include "components/payments/content/payment_request_spec.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/null_storage.h"
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/label.h"

namespace payments {

namespace {

const char kLocale[] =;
const char16_t kNameFull[] =;
const char16_t kHomeAddress[] =;
const char16_t kHomeCity[] =;
const char16_t kHomeZip[] =;
const char16_t kHomePhone[] =;  // +1 555-555-5555 is invalid :-(.
const char kAnyState[] =;
const char16_t kAnyState16[] =;
const char kAnyStateCode[] =;
const char16_t kCountryWithoutStates[] =;
const char16_t kCountryWithoutStatesCode[] =;
const char16_t kCountryWithoutStatesPhoneNumber[] =;

const base::Time kJanuary2017 =;

}  // namespace

// This test suite is flaky on desktop platforms (crbug.com/1073972) and tests
// UI that is soon to be deprecated, so it is disabled.
class DISABLED_PaymentRequestShippingAddressEditorTest
    : public PaymentRequestBrowserTestBase {};

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       SyncData) {}

// Disabled for flakiness: crbug.com/799028
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       DISABLED_EnterAcceleratorSyncData) {}

// TODO(crbug.com/40732468): flaky.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       DISABLED_AsyncData) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       SwitchingCountryUpdatesViewAndKeepsValues) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       FailToLoadRegionData) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       TimingOutRegionData) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       SelectingIncompleteAddress) {}

// Flaky on ozone: https://crbug.com/1216184
#if BUILDFLAG(IS_OZONE)
#define MAYBE_FocusFirstField_Name
#else
#define MAYBE_FocusFirstField_Name
#endif
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       MAYBE_FocusFirstField_Name) {}

// Flaky on ozone: https://crbug.com/1216184
#if BUILDFLAG(IS_OZONE)
#define MAYBE_FocusFirstInvalidField_NotName
#else
#define MAYBE_FocusFirstInvalidField_NotName
#endif
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       MAYBE_FocusFirstInvalidField_NotName) {}

// Tests that the editor accepts an international phone from another country.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       AddInternationalPhoneNumberFromOtherCountry) {}

// Tests that the editor accepts a phone number looks like a possible number
// but is actually invalid.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       AddPossiblePhoneNumber) {}

// Tests that the editor does not accept a impossible phone number.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       AddImpossiblePhoneNumber) {}

// Tests that updating the country to one with no states clears the state value.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       UpdateToCountryWithoutState) {}

// Tests that there is no error label for an international phone from another
// country.
IN_PROC_BROWSER_TEST_F(
    DISABLED_PaymentRequestShippingAddressEditorTest,
    NoErrorLabelForInternationalPhoneNumberFromOtherCountry) {}

// Tests that there is no error label for an phone number that can be
// technically parsed as a US number even if it is actually invalid.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       NoErrorLabelForPossibleButInvalidPhoneNumber) {}

// Tests that there is error label for an impossible phone number.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       ErrorLabelForImpossiblePhoneNumber) {}

// Tests that if the a profile has a country and no state, the editor makes the
// user pick a state. This should also disable the "Done" button.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       CountryButNoState) {}

// TODO(crbug.com/40524578): This address should be invalid.
// Tests that if the a profile has a country and an invalid state for the
// country, the address is considered valid.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       CountryAndInvalidState) {}

// Tests that if the a profile has no country and no state, the editor sets the
// country and lets the user pick a state. This should also disable the "Done"
// button.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       NoCountryNoState) {}

// Tests that if the a profile has no country and an invalid state for the
// default country, the editor sets the country and lets the user pick a state.
// This should also disable the "Done" button.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       NoCountryInvalidState) {}

// TODO(crbug.com/40524404): The profile should be considered valid.
// Tests that if the a profile has no country but has a valid state for the
// default country, the editor sets the country and the state for the user.
// This should also enable the "Done" button.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       NoCountryValidState_SyncRegionLoad) {}

// TODO(crbug.com/40524404): The profile should be considered valid.
// Tests that if the a profile has no country but has a valid state for the
// default country, the editor sets the country and the state for the user.
// This should also enable the "Done" button.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       NoCountryValidState_AsyncRegionLoad) {}

// Tests that the state dropdown is set to the right value if the value from the
// profile is a region code.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       DefaultRegion_RegionCode) {}

// Tests that the state dropdown is set to the right value if the value from the
// profile is a region name.
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       DefaultRegion_RegionName) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       NoCountryProfileDoesntSetCountryToLocale) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       SyncDataInIncognito) {}

// Tests that there is error label for an impossible
IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       RetryWithShippingAddressErrors) {}

// Tests that there is error label for an impossible
IN_PROC_BROWSER_TEST_F(
    DISABLED_PaymentRequestShippingAddressEditorTest,
    RetryWithShippingAddressErrors_HasSameValueButDifferentErrorsShown) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       RetryWithShippingAddressErrors_NoRequestShippingOption) {}

IN_PROC_BROWSER_TEST_F(DISABLED_PaymentRequestShippingAddressEditorTest,
                       UpdateWithShippingAddressErrors) {}

}  // namespace payments