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/message_loop/message_loop.h" |
| 6 #include "mojo/common/traits_test_service.mojom.h" |
| 7 #include "mojo/public/cpp/bindings/binding_set.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace mojo { |
| 11 namespace common { |
| 12 namespace { |
| 13 |
| 14 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
| 15 public: |
| 16 StructTraitsTest() {} |
| 17 |
| 18 protected: |
| 19 mojom::TraitsTestServicePtr GetTraitsTestProxy() { |
| 20 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
| 21 } |
| 22 |
| 23 private: |
| 24 // TraitsTestService: |
| 25 void EchoVersion(const base::Version& m, |
| 26 const EchoVersionCallback& callback) override { |
| 27 callback.Run(m); |
| 28 } |
| 29 |
| 30 base::MessageLoop loop_; |
| 31 mojo::BindingSet<TraitsTestService> traits_test_bindings_; |
| 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(StructTraitsTest); |
| 34 }; |
| 35 |
| 36 TEST_F(StructTraitsTest, Version) { |
| 37 const std::string& version_str = "1.2.3.4"; |
| 38 base::Version input(version_str); |
| 39 mojom::TraitsTestServicePtr proxy = GetTraitsTestProxy(); |
| 40 base::Version output; |
| 41 proxy->EchoVersion(input, &output); |
| 42 base::Version test_version(version_str); |
| 43 |
| 44 EXPECT_EQ(version_str, output.GetString()); |
| 45 } |
| 46 |
| 47 } // namespace |
| 48 } // namespace common |
| 49 } // namespace mojo |
OLD | NEW |