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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 void setSecurityOrigin(const String& securityOrigin) | 70 void setSecurityOrigin(const String& securityOrigin) |
71 { | 71 { |
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 HeapVector<PaymentMethodData> buildPaymentMethodDataForTest() | |
please use gerrit instead
2016/05/29 19:57:12
Rename PaymentDetailsTestHelper into PaymentTestHe
zino
2016/06/01 17:43:46
Done.
| |
81 { | |
82 HeapVector<PaymentMethodData> methodData(1, PaymentMethodData()); | |
83 methodData[0].setSupportedMethods(Vector<String>(1, "food")); | |
please use gerrit instead
2016/05/29 19:57:12
"foo" ?
zino
2016/06/01 17:43:46
Done.
| |
84 return methodData; | |
85 } | |
86 | |
80 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) | 87 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) |
81 { | 88 { |
82 PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), GetParam( ).buildDetails(), getExceptionState()); | 89 PaymentRequest::create(getScriptState(), buildPaymentMethodDataForTest(), Ge tParam().buildDetails(), getExceptionState()); |
83 | 90 |
84 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); | 91 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); |
85 if (GetParam().expectException()) | 92 if (GetParam().expectException()) |
86 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod e()); | 93 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod e()); |
87 } | 94 } |
88 | 95 |
89 INSTANTIATE_TEST_CASE_P(MissingData, | 96 INSTANTIATE_TEST_CASE_P(MissingData, |
90 PaymentRequestDetailsTest, | 97 PaymentRequestDetailsTest, |
91 testing::Values( | 98 testing::Values( |
92 DetailsTestCase(PaymentTestDetailItem, PaymentTestDataAmount, PaymentTes tRemoveKey, "", true, V8TypeError), | 99 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), | 188 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "10.", true, V8TypeError), |
182 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, ".99", true, V8TypeError), | 189 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, ".99", true, V8TypeError), |
183 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "-10.", true, V8TypeError), | 190 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "-10.", true, V8TypeError), |
184 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "10-", true, V8TypeError), | 191 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "10-", true, V8TypeError), |
185 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "1-0", true, V8TypeError), | 192 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "1-0", true, V8TypeError), |
186 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "1.0.0", true, V8TypeError), | 193 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "1.0.0", true, V8TypeError), |
187 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "1/3", true, V8TypeError))); | 194 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P aymentTestOverwriteValue, "1/3", true, V8TypeError))); |
188 | 195 |
189 } // namespace | 196 } // namespace |
190 } // namespace blink | 197 } // namespace blink |
OLD | NEW |