Index: third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraitsTest.cpp |
diff --git a/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraitsTest.cpp b/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraitsTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4e74c151ef5a03676734ccfc6bf389c9810c0e77 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/mojo/CommonCustomTypesStructTraitsTest.cpp |
@@ -0,0 +1,69 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/macros.h" |
+#include "base/message_loop/message_loop.h" |
+#include "mojo/common/test_common_custom_types.mojom-blink.h" |
+#include "mojo/public/cpp/bindings/binding_set.h" |
+#include "public/platform/WebString.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace blink { |
+ |
+namespace { |
+ |
+class TestString16Impl : public mojo::common::test::blink::TestString16 { |
+ public: |
+ explicit TestString16Impl( |
+ mojo::common::test::blink::TestString16Request request) |
+ : m_binding(this, std::move(request)) {} |
+ |
+ // TestString16 implementation: |
+ void BounceString16(const WebString& in, |
+ const BounceString16Callback& callback) override { |
+ callback.Run(in); |
+ } |
+ |
+ private: |
+ mojo::Binding<mojo::common::test::blink::TestString16> m_binding; |
+}; |
+ |
+class CommonCustomTypesStructTraitsTest : public testing::Test { |
+ protected: |
+ CommonCustomTypesStructTraitsTest() {} |
+ ~CommonCustomTypesStructTraitsTest() override {} |
+ |
+ private: |
+ base::MessageLoop m_messageLoop; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CommonCustomTypesStructTraitsTest); |
+}; |
+ |
+} // namespace |
+ |
+TEST_F(CommonCustomTypesStructTraitsTest, String16) { |
+ mojo::common::test::blink::TestString16Ptr ptr; |
+ TestString16Impl impl(GetProxy(&ptr)); |
+ |
+ WebString str = WebString::fromUTF8("hello world"); |
+ WebString output; |
+ |
+ ptr->BounceString16(str, &output); |
+ |
+ ASSERT_EQ(str, output); |
+} |
+ |
+TEST_F(CommonCustomTypesStructTraitsTest, EmptyString16) { |
+ mojo::common::test::blink::TestString16Ptr ptr; |
+ TestString16Impl impl(GetProxy(&ptr)); |
+ |
+ WebString str = WebString::fromUTF8(""); |
+ WebString output; |
+ |
+ ptr->BounceString16(str, &output); |
+ |
+ ASSERT_EQ(str, output); |
+} |
+ |
+} // namespace blink |