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

#include "components/autofill/core/browser/payments/android_bnpl_strategy.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace autofill::payments {

class AndroidBnplStrategyTest : public testing::Test {
 public:
  AndroidBnplStrategyTest() = default;
  ~AndroidBnplStrategyTest() override = default;

 protected:
  AndroidBnplStrategy android_bnpl_strategy_;
};

// Verify that GetNextActionOnSuggestionsShown() returns the correct action for
// the Android platform.
TEST_F(AndroidBnplStrategyTest, GetNextActionOnSuggestionsShown) {
  EXPECT_EQ(android_bnpl_strategy_.GetNextActionOnSuggestionsShown(),
            BnplStrategy::SuggestionsShownNextAction::
                kSkipNotifyingUpdateCallbackOfSuggestionsShownResponse);
}

// Verify that GetNextActionOnUserDecisionToUseBnpl() returns the correct
// action for the Android platform.
TEST_F(AndroidBnplStrategyTest, GetNextActionOnUserDecisionToUseBnpl) {
  EXPECT_EQ(android_bnpl_strategy_.GetNextActionOnUserDecisionToUseBnpl(),
            BnplStrategy::UserDecisionToUseBnplNextAction::
                kCheckAmountExtractionBeforeContinuingFlowForAndroid);
}

// Verify that GetNextActionOnAmountExtractionReturned() returns the correct
// action for the Android platform.
TEST_F(AndroidBnplStrategyTest, GetNextActionOnAmountExtractionReturned) {
  EXPECT_EQ(android_bnpl_strategy_.GetNextActionOnAmountExtractionReturned(),
            BnplStrategy::BnplAmountExtractionReturnedNextAction::
                kNotifyUiOfAmountExtractionReturnedResponse);
}

// Verify that GetBeforeViewSwitchAction() returns the correct action for
// the Android platform.
TEST_F(AndroidBnplStrategyTest, GetBeforeViewSwitchAction) {
  EXPECT_EQ(android_bnpl_strategy_.GetBeforeViewSwitchAction(),
            BnplStrategy::BeforeSwitchingViewAction::kDoNothing);
}

// Verify that GetNextActionOnAiBasedAmountExtractionReturned() returns the
// correct action for the Android platform.
TEST_F(AndroidBnplStrategyTest,
       GetNextActionOnAiBasedAmountExtractionReturned) {
  EXPECT_EQ(
      android_bnpl_strategy_.GetNextActionOnAiBasedAmountExtractionReturned(),
      BnplStrategy::BnplAiBasedAmountExtractionReturnedNextAction::
          kSwitchToIssuerSelectionScreenOnAndroid);
}

// Verify that GetNextActionOnUserDecisionToUseSavedCards() returns the correct
// action for the Android platform.
TEST_F(AndroidBnplStrategyTest, GetNextActionOnUserDecisionToUseSavedCards) {
  EXPECT_EQ(android_bnpl_strategy_.GetNextActionOnUserDecisionToUseSavedCards(),
            BnplStrategy::UserDecisionToUseSavedCardsNextAction::
                kResetSelectedIssuerOrFlowStateOnAndroid);
}

// Verify that GetNextActionOnUserDecisionToUseBnplAgain() returns the correct
// action for the Android platform.
TEST_F(AndroidBnplStrategyTest, GetNextActionOnUserDecisionToUseBnplAgain) {
  EXPECT_EQ(android_bnpl_strategy_.GetNextActionOnUserDecisionToUseBnplAgain(),
            BnplStrategy::UserDecisionToUseBnplAgainNextAction::
                kReshowSelectBnplIssuerUiOnAndroid);
}

// Verify that GetUiDismissalAction() returns the correct action for
// the Android platform.
TEST_F(AndroidBnplStrategyTest, GetUiDismissalAction) {
  EXPECT_EQ(android_bnpl_strategy_.GetUiDismissalAction(),
            BnplStrategy::UiDismissalAction::kRemoveBnplUi);
}

// Verify that ShouldRemoveExistingUiOnServerReturn() returns the correct
// value for the Android platform.
TEST_F(AndroidBnplStrategyTest, ShouldRemoveExistingUiOnServerReturn) {
  EXPECT_EQ(android_bnpl_strategy_.ShouldRemoveExistingUiOnServerReturn(
                PaymentsAutofillClient::PaymentsRpcResult::kSuccess),
            true);
  EXPECT_EQ(android_bnpl_strategy_.ShouldRemoveExistingUiOnServerReturn(
                PaymentsAutofillClient::PaymentsRpcResult::kPermanentFailure),
            false);
}

}  // namespace autofill::payments
