OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/macros.h" |
| 6 #include "base/message_loop/message_loop.h" |
| 7 #include "mojo/common/test_common_custom_types.mojom-blink.h" |
| 8 #include "mojo/public/cpp/bindings/binding_set.h" |
| 9 #include "public/platform/WebString.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 namespace { |
| 15 |
| 16 class TestString16Impl : public mojo::common::test::blink::TestString16 { |
| 17 public: |
| 18 explicit TestString16Impl( |
| 19 mojo::common::test::blink::TestString16Request request) |
| 20 : m_binding(this, std::move(request)) {} |
| 21 |
| 22 // TestString16 implementation: |
| 23 void BounceString16(const WebString& in, |
| 24 const BounceString16Callback& callback) override { |
| 25 callback.Run(in); |
| 26 } |
| 27 |
| 28 private: |
| 29 mojo::Binding<mojo::common::test::blink::TestString16> m_binding; |
| 30 }; |
| 31 |
| 32 class CommonCustomTypesStructTraitsTest : public testing::Test { |
| 33 protected: |
| 34 CommonCustomTypesStructTraitsTest() {} |
| 35 ~CommonCustomTypesStructTraitsTest() override {} |
| 36 |
| 37 private: |
| 38 base::MessageLoop m_messageLoop; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(CommonCustomTypesStructTraitsTest); |
| 41 }; |
| 42 |
| 43 } // namespace |
| 44 |
| 45 TEST_F(CommonCustomTypesStructTraitsTest, String16) { |
| 46 mojo::common::test::blink::TestString16Ptr ptr; |
| 47 TestString16Impl impl(GetProxy(&ptr)); |
| 48 |
| 49 WebString str = WebString::fromUTF8("hello world"); |
| 50 WebString output; |
| 51 |
| 52 ptr->BounceString16(str, &output); |
| 53 |
| 54 ASSERT_EQ(str, output); |
| 55 } |
| 56 |
| 57 TEST_F(CommonCustomTypesStructTraitsTest, EmptyString16) { |
| 58 mojo::common::test::blink::TestString16Ptr ptr; |
| 59 TestString16Impl impl(GetProxy(&ptr)); |
| 60 |
| 61 WebString str = WebString::fromUTF8(""); |
| 62 WebString output; |
| 63 |
| 64 ptr->BounceString16(str, &output); |
| 65 |
| 66 ASSERT_EQ(str, output); |
| 67 } |
| 68 |
| 69 } // namespace blink |
OLD | NEW |