| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/payments/PaymentRequest.h" | 5 #include "modules/payments/PaymentRequest.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| 11 #include "modules/payments/PaymentDetails.h" | 11 #include "modules/payments/PaymentDetails.h" |
| 12 #include "modules/payments/PaymentDetailsTestHelper.h" | 12 #include "modules/payments/PaymentTestHelper.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "wtf/OwnPtr.h" | 14 #include "wtf/OwnPtr.h" |
| 15 #include <ostream> // NOLINT | 15 #include <ostream> // NOLINT |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class DetailsTestCase { | 20 class DetailsTestCase { |
| 21 public: | 21 public: |
| 22 DetailsTestCase(PaymentTestDetailToChange detail, PaymentTestDataToChange da
ta, PaymentTestModificationType modType, const char* valueToUse, bool expectExce
ption = false, ExceptionCode expectedExceptionCode = 0) | 22 DetailsTestCase(PaymentTestDetailToChange detail, PaymentTestDataToChange da
ta, PaymentTestModificationType modType, const char* valueToUse, bool expectExce
ption = false, ExceptionCode expectedExceptionCode = 0) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 m_page->document().setSecurityOrigin(SecurityOrigin::create(KURL(KURL(),
securityOrigin))); | 130 m_page->document().setSecurityOrigin(SecurityOrigin::create(KURL(KURL(),
securityOrigin))); |
| 131 } | 131 } |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 OwnPtr<DummyPageHolder> m_page; | 134 OwnPtr<DummyPageHolder> m_page; |
| 135 TrackExceptionState m_exceptionState; | 135 TrackExceptionState m_exceptionState; |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) | 138 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) |
| 139 { | 139 { |
| 140 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), GetParam(
).buildDetails(), getExceptionState()); | 140 PaymentRequest::create(getScriptState(), buildPaymentMethodDataForTest(), Ge
tParam().buildDetails(), getExceptionState()); |
| 141 | 141 |
| 142 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); | 142 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); |
| 143 if (GetParam().expectException()) | 143 if (GetParam().expectException()) |
| 144 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod
e()); | 144 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod
e()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 INSTANTIATE_TEST_CASE_P(MissingData, | 147 INSTANTIATE_TEST_CASE_P(MissingData, |
| 148 PaymentRequestDetailsTest, | 148 PaymentRequestDetailsTest, |
| 149 testing::Values( | 149 testing::Values( |
| 150 DetailsTestCase(PaymentTestDetailTotal, PaymentTestDataAmount, PaymentTe
stRemoveKey, "", true, V8TypeError), | 150 DetailsTestCase(PaymentTestDetailTotal, PaymentTestDataAmount, PaymentTe
stRemoveKey, "", true, V8TypeError), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10.", true, V8TypeError), | 276 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10.", true, V8TypeError), |
| 277 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, ".99", true, V8TypeError), | 277 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, ".99", true, V8TypeError), |
| 278 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "-10.", true, V8TypeError), | 278 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "-10.", true, V8TypeError), |
| 279 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10-", true, V8TypeError), | 279 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10-", true, V8TypeError), |
| 280 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1-0", true, V8TypeError), | 280 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1-0", true, V8TypeError), |
| 281 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1.0.0", true, V8TypeError), | 281 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1.0.0", true, V8TypeError), |
| 282 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1/3", true, V8TypeError))); | 282 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1/3", true, V8TypeError))); |
| 283 | 283 |
| 284 } // namespace | 284 } // namespace |
| 285 } // namespace blink | 285 } // namespace blink |
| OLD | NEW |