1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_PAYMENTS_PAYMENT_TEST_HELPER_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_PAYMENTS_PAYMENT_TEST_HELPER_H_
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/mojom/payments/payment_request.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_payment_details_init.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_payment_details_update.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_payment_item.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_payment_shipping_option.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_secure_payment_confirmation_request.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
class PaymentMethodData;
class V8TestingScope;
enum PaymentTestDetailToChange {
kPaymentTestDetailNone,
kPaymentTestDetailTotal,
kPaymentTestDetailItem,
kPaymentTestDetailShippingOption,
kPaymentTestDetailModifierTotal,
kPaymentTestDetailModifierItem,
kPaymentTestDetailError
};
enum PaymentTestDataToChange {
kPaymentTestDataNone,
kPaymentTestDataId,
kPaymentTestDataLabel,
kPaymentTestDataAmount,
kPaymentTestDataCurrencyCode,
kPaymentTestDataValue,
};
enum PaymentTestModificationType {
kPaymentTestOverwriteValue,
kPaymentTestRemoveKey
};
PaymentItem* BuildPaymentItemForTest(
PaymentTestDataToChange = kPaymentTestDataNone,
PaymentTestModificationType = kPaymentTestOverwriteValue,
const String& value_to_use = String());
PaymentShippingOption* BuildShippingOptionForTest(
PaymentTestDataToChange = kPaymentTestDataNone,
PaymentTestModificationType = kPaymentTestOverwriteValue,
const String& value_to_use = String());
PaymentDetailsModifier* BuildPaymentDetailsModifierForTest(
PaymentTestDetailToChange = kPaymentTestDetailNone,
PaymentTestDataToChange = kPaymentTestDataNone,
PaymentTestModificationType = kPaymentTestOverwriteValue,
const String& value_to_use = String());
PaymentDetailsInit* BuildPaymentDetailsInitForTest(
PaymentTestDetailToChange = kPaymentTestDetailNone,
PaymentTestDataToChange = kPaymentTestDataNone,
PaymentTestModificationType = kPaymentTestOverwriteValue,
const String& value_to_use = String());
PaymentDetailsUpdate* BuildPaymentDetailsUpdateForTest(
PaymentTestDetailToChange = kPaymentTestDetailNone,
PaymentTestDataToChange = kPaymentTestDataNone,
PaymentTestModificationType = kPaymentTestOverwriteValue,
const String& value_to_use = String());
PaymentDetailsUpdate* BuildPaymentDetailsErrorMsgForTest(
const String& value_to_use = String());
HeapVector<Member<PaymentMethodData>> BuildPaymentMethodDataForTest();
payments::mojom::blink::PaymentResponsePtr BuildPaymentResponseForTest();
payments::mojom::blink::PaymentAddressPtr BuildPaymentAddressForTest();
class PaymentRequestV8TestingScope : public V8TestingScope {
STACK_ALLOCATED();
public:
PaymentRequestV8TestingScope();
};
const uint8_t kSecurePaymentConfirmationCredentialId[] = {
0x63, 0x72, 0x65, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C};
const uint8_t kSecurePaymentConfirmationChallenge[] = {
0x63, 0x68, 0x61, 0x6C, 0x6C, 0x65, 0x6E, 0x67, 0x65};
// Creates and returns a minimal SecurePaymentConfirmationRequest object with
// only required fields filled in to pass parsing.
//
// If include_payee_name is set to false, this function will not include the
// payeeName field which is not required by IDL (and thus not required for
// conversion to ScriptValue), but is required by the parsing code.
SecurePaymentConfirmationRequest* CreateSecurePaymentConfirmationRequest(
const V8TestingScope& scope,
const bool include_payee_name = true);
HeapVector<Member<PaymentMethodData>>
BuildSecurePaymentConfirmationMethodDataForTest(const V8TestingScope& scope);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_PAYMENTS_PAYMENT_TEST_HELPER_H_
|