| 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/PaymentTestHelper.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" | |
| 15 #include <ostream> // NOLINT | 14 #include <ostream> // NOLINT |
| 16 | 15 |
| 17 namespace blink { | 16 namespace blink { |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 class DetailsTestCase { | 19 class DetailsTestCase { |
| 21 public: | 20 public: |
| 22 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) |
| 23 : m_detail(detail) | 22 : m_detail(detail) |
| 24 , m_data(data) | 23 , m_data(data) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 123 |
| 125 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } | 124 ScriptState* getScriptState() { return ScriptState::forMainWorld(m_page->doc
ument().frame()); } |
| 126 ExceptionState& getExceptionState() { return m_exceptionState; } | 125 ExceptionState& getExceptionState() { return m_exceptionState; } |
| 127 | 126 |
| 128 void setSecurityOrigin(const String& securityOrigin) | 127 void setSecurityOrigin(const String& securityOrigin) |
| 129 { | 128 { |
| 130 m_page->document().setSecurityOrigin(SecurityOrigin::create(KURL(KURL(),
securityOrigin))); | 129 m_page->document().setSecurityOrigin(SecurityOrigin::create(KURL(KURL(),
securityOrigin))); |
| 131 } | 130 } |
| 132 | 131 |
| 133 private: | 132 private: |
| 134 OwnPtr<DummyPageHolder> m_page; | 133 std::unique_ptr<DummyPageHolder> m_page; |
| 135 TrackExceptionState m_exceptionState; | 134 TrackExceptionState m_exceptionState; |
| 136 }; | 135 }; |
| 137 | 136 |
| 138 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) | 137 TEST_P(PaymentRequestDetailsTest, ValidatesDetails) |
| 139 { | 138 { |
| 140 PaymentRequest::create(getScriptState(), buildPaymentMethodDataForTest(), Ge
tParam().buildDetails(), getExceptionState()); | 139 PaymentRequest::create(getScriptState(), buildPaymentMethodDataForTest(), Ge
tParam().buildDetails(), getExceptionState()); |
| 141 | 140 |
| 142 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); | 141 EXPECT_EQ(GetParam().expectException(), getExceptionState().hadException()); |
| 143 if (GetParam().expectException()) | 142 if (GetParam().expectException()) |
| 144 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod
e()); | 143 EXPECT_EQ(GetParam().getExpectedExceptionCode(), getExceptionState().cod
e()); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10.", true, V8TypeError), | 275 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10.", true, V8TypeError), |
| 277 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, ".99", true, V8TypeError), | 276 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, ".99", true, V8TypeError), |
| 278 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "-10.", true, V8TypeError), | 277 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "-10.", true, V8TypeError), |
| 279 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10-", true, V8TypeError), | 278 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "10-", true, V8TypeError), |
| 280 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1-0", true, V8TypeError), | 279 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1-0", true, V8TypeError), |
| 281 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1.0.0", true, V8TypeError), | 280 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1.0.0", true, V8TypeError), |
| 282 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1/3", true, V8TypeError))); | 281 DetailsTestCase(PaymentTestDetailShippingOption, PaymentTestDataValue, P
aymentTestOverwriteValue, "1/3", true, V8TypeError))); |
| 283 | 282 |
| 284 } // namespace | 283 } // namespace |
| 285 } // namespace blink | 284 } // namespace blink |
| OLD | NEW |