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 | 15 |
16 namespace blink { | 16 namespace blink { |
17 namespace { | 17 namespace { |
18 | 18 |
19 class DetailsTestCase { | 19 class DetailsTestCase { |
20 public: | 20 public: |
21 DetailsTestCase(PaymentTestDetailToChange detail, PaymentTestDataToChange da
ta, PaymentTestModificationType modType, const char* valueToUse, bool expectExce
ption = false, ExceptionCode expectedExceptionCode = 0) | 21 DetailsTestCase(PaymentTestDetailToChange detail, PaymentTestDataToChange da
ta, PaymentTestModificationType modType, const char* valueToUse, bool expectExce
ption = false, ExceptionCode expectedExceptionCode = 0) |
22 : m_detail(detail) | 22 : m_detail(detail) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 m_page->document().setSecurityOrigin(SecurityOrigin::create(KURL(KURL(),
securityOrigin))); | 72 m_page->document().setSecurityOrigin(SecurityOrigin::create(KURL(KURL(),
securityOrigin))); |
73 } | 73 } |
74 | 74 |
75 private: | 75 private: |
76 OwnPtr<DummyPageHolder> m_page; | 76 OwnPtr<DummyPageHolder> m_page; |
77 TrackExceptionState m_exceptionState; | 77 TrackExceptionState m_exceptionState; |
78 }; | 78 }; |
79 | 79 |
80 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) | 80 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) |
81 { | 81 { |
82 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), GetParam(
).buildDetails(), getExceptionState()); | 82 PaymentRequest::create(getScriptState(), buildPaymentMethodDataForTest(), Ge
tParam().buildDetails(), getExceptionState()); |
83 | 83 |
84 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); | 84 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); |
85 if (GetParam().expectException()) | 85 if (GetParam().expectException()) |
86 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod
e()); | 86 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod
e()); |
87 } | 87 } |
88 | 88 |
89 INSTANTIATE_TEST_CASE_P(MissingData, | 89 INSTANTIATE_TEST_CASE_P(MissingData, |
90 PaymentRequestDetailsTest, | 90 PaymentRequestDetailsTest, |
91 testing::Values( | 91 testing::Values( |
92 DetailsTestCase(PaymentTestDetailItem, PaymentTestDataAmount, PaymentTes
tRemoveKey, "", true, V8TypeError), | 92 DetailsTestCase(PaymentTestDetailItem, PaymentTestDataAmount, PaymentTes
tRemoveKey, "", true, V8TypeError), |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10.", true, V8TypeError), | 181 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10.", true, V8TypeError), |
182 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, ".99", true, V8TypeError), | 182 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, ".99", true, V8TypeError), |
183 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "-10.", true, V8TypeError), | 183 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "-10.", true, V8TypeError), |
184 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10-", true, V8TypeError), | 184 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10-", true, V8TypeError), |
185 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1-0", true, V8TypeError), | 185 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1-0", true, V8TypeError), |
186 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1.0.0", true, V8TypeError), | 186 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1.0.0", true, V8TypeError), |
187 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1/3", true, V8TypeError))); | 187 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1/3", true, V8TypeError))); |
188 | 188 |
189 } // namespace | 189 } // namespace |
190 } // namespace blink | 190 } // namespace blink |
OLD | NEW |