Chromium Code Reviews| 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/PaymentResponse.h" | 5 #include "modules/payments/PaymentResponse.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 "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 OwnPtr<DummyPageHolder> m_page; | 54 OwnPtr<DummyPageHolder> m_page; |
| 55 NonThrowableExceptionState m_exceptionState; | 55 NonThrowableExceptionState m_exceptionState; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 TEST_F(PaymentResponseTest, DataCopiedOver) | 58 TEST_F(PaymentResponseTest, DataCopiedOver) |
| 59 { | 59 { |
| 60 ScriptState::Scope scope(getScriptState()); | 60 ScriptState::Scope scope(getScriptState()); |
| 61 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New( ); | 61 mojom::blink::PaymentResponsePtr input = mojom::blink::PaymentResponse::New( ); |
| 62 input->method_name = "foo"; | 62 input->method_name = "foo"; |
| 63 input->stringified_details = "{\"transactionId\": 123}"; | 63 input->stringified_details = "{\"transactionId\": 123}"; |
| 64 input->payer_email = "abc@gamil.com"; | |
|
please use gerrit instead
2016/06/07 17:04:24
gmail?
| |
| 65 input->payer_phone = "0123"; | |
| 64 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 66 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; |
| 65 | 67 |
| 66 PaymentResponse output(std::move(input), completeCallback); | 68 PaymentResponse output(std::move(input), completeCallback); |
| 67 | 69 |
| 68 EXPECT_EQ("foo", output.methodName()); | 70 EXPECT_EQ("foo", output.methodName()); |
| 71 EXPECT_EQ("abc@gamil.com", output.payerEmail()); | |
|
please use gerrit instead
2016/06/07 17:04:24
gmail?
| |
| 72 EXPECT_EQ("0123", output.payerPhone()); | |
| 69 | 73 |
| 70 ScriptValue details = output.details(getScriptState(), getExceptionState()); | 74 ScriptValue details = output.details(getScriptState(), getExceptionState()); |
| 71 | 75 |
| 72 ASSERT_FALSE(getExceptionState().hadException()); | 76 ASSERT_FALSE(getExceptionState().hadException()); |
| 73 ASSERT_TRUE(details.v8Value()->IsObject()); | 77 ASSERT_TRUE(details.v8Value()->IsObject()); |
| 74 | 78 |
| 75 ScriptValue transactionId(getScriptState(), details.v8Value().As<v8::Object> ()->Get(v8String(getScriptState()->isolate(), "transactionId"))); | 79 ScriptValue transactionId(getScriptState(), details.v8Value().As<v8::Object> ()->Get(v8String(getScriptState()->isolate(), "transactionId"))); |
| 76 | 80 |
| 77 ASSERT_TRUE(transactionId.v8Value()->IsNumber()); | 81 ASSERT_TRUE(transactionId.v8Value()->IsNumber()); |
| 78 EXPECT_EQ(123, transactionId.v8Value().As<v8::Number>()->Value()); | 82 EXPECT_EQ(123, transactionId.v8Value().As<v8::Number>()->Value()); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 99 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; | 103 MockPaymentCompleter* completeCallback = new MockPaymentCompleter; |
| 100 PaymentResponse output(std::move(input), completeCallback); | 104 PaymentResponse output(std::move(input), completeCallback); |
| 101 | 105 |
| 102 EXPECT_CALL(*completeCallback, complete(getScriptState(), false)); | 106 EXPECT_CALL(*completeCallback, complete(getScriptState(), false)); |
| 103 | 107 |
| 104 output.complete(getScriptState(), false); | 108 output.complete(getScriptState(), false); |
| 105 } | 109 } |
| 106 | 110 |
| 107 } // namespace | 111 } // namespace |
| 108 } // namespace blink | 112 } // namespace blink |
| OLD | NEW |