| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/public/cpp/environment/environment.h" | 5 #include "mojo/public/cpp/environment/environment.h" |
| 6 #include "mojo/public/cpp/test_support/test_utils.h" | 6 #include "mojo/public/cpp/test_support/test_utils.h" |
| 7 #include "mojo/public/cpp/utility/run_loop.h" | 7 #include "mojo/public/cpp/utility/run_loop.h" |
| 8 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 } | 21 } |
| 22 void Run(const String& a) const { | 22 void Run(const String& a) const { |
| 23 *buf_ = a.To<std::string>(); | 23 *buf_ = a.To<std::string>(); |
| 24 } | 24 } |
| 25 private: | 25 private: |
| 26 std::string* buf_; | 26 std::string* buf_; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 class SampleNamedObjectImpl : public InterfaceImpl<sample::NamedObject> { | 29 class SampleNamedObjectImpl : public InterfaceImpl<sample::NamedObject> { |
| 30 public: | 30 public: |
| 31 virtual void OnConnectionError() MOJO_OVERRIDE { | |
| 32 delete this; | |
| 33 } | |
| 34 | |
| 35 virtual void SetName(const mojo::String& name) MOJO_OVERRIDE { | 31 virtual void SetName(const mojo::String& name) MOJO_OVERRIDE { |
| 36 name_ = name; | 32 name_ = name; |
| 37 } | 33 } |
| 38 | 34 |
| 39 virtual void GetName(const mojo::Callback<void(mojo::String)>& callback) | 35 virtual void GetName(const mojo::Callback<void(mojo::String)>& callback) |
| 40 MOJO_OVERRIDE { | 36 MOJO_OVERRIDE { |
| 41 callback.Run(name_); | 37 callback.Run(name_); |
| 42 } | 38 } |
| 43 | 39 |
| 44 private: | 40 private: |
| 45 std::string name_; | 41 std::string name_; |
| 46 }; | 42 }; |
| 47 | 43 |
| 48 class SampleFactoryImpl : public InterfaceImpl<sample::Factory> { | 44 class SampleFactoryImpl : public InterfaceImpl<sample::Factory> { |
| 49 public: | 45 public: |
| 50 virtual void OnConnectionError() MOJO_OVERRIDE { | |
| 51 delete this; | |
| 52 } | |
| 53 | |
| 54 virtual void DoStuff(sample::RequestPtr request, | 46 virtual void DoStuff(sample::RequestPtr request, |
| 55 ScopedMessagePipeHandle pipe) MOJO_OVERRIDE { | 47 ScopedMessagePipeHandle pipe) MOJO_OVERRIDE { |
| 56 std::string text1; | 48 std::string text1; |
| 57 if (pipe.is_valid()) | 49 if (pipe.is_valid()) |
| 58 EXPECT_TRUE(ReadTextMessage(pipe.get(), &text1)); | 50 EXPECT_TRUE(ReadTextMessage(pipe.get(), &text1)); |
| 59 | 51 |
| 60 std::string text2; | 52 std::string text2; |
| 61 if (request->pipe.is_valid()) { | 53 if (request->pipe.is_valid()) { |
| 62 EXPECT_TRUE(ReadTextMessage(request->pipe.get(), &text2)); | 54 EXPECT_TRUE(ReadTextMessage(request->pipe.get(), &text2)); |
| 63 | 55 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 322 |
| 331 PumpMessages(); // Yield for results. | 323 PumpMessages(); // Yield for results. |
| 332 | 324 |
| 333 EXPECT_EQ(std::string("object1"), name1); | 325 EXPECT_EQ(std::string("object1"), name1); |
| 334 EXPECT_EQ(std::string("object2"), name2); | 326 EXPECT_EQ(std::string("object2"), name2); |
| 335 } | 327 } |
| 336 | 328 |
| 337 } // namespace | 329 } // namespace |
| 338 } // namespace test | 330 } // namespace test |
| 339 } // namespace mojo | 331 } // namespace mojo |
| OLD | NEW |