| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/edk/system/channel.h" | 5 #include "mojo/edk/system/channel.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/test/test_io_thread.h" | 10 #include "base/test/test_io_thread.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // Okay to destroy |Channel| on not-the-I/O-thread. | 111 // Okay to destroy |Channel| on not-the-I/O-thread. |
| 112 EXPECT_TRUE(channel()->HasOneRef()); | 112 EXPECT_TRUE(channel()->HasOneRef()); |
| 113 *mutable_channel() = nullptr; | 113 *mutable_channel() = nullptr; |
| 114 } | 114 } |
| 115 | 115 |
| 116 // ChannelTest.InitFails ------------------------------------------------------- | 116 // ChannelTest.InitFails ------------------------------------------------------- |
| 117 | 117 |
| 118 class MockRawChannelOnInitFails : public RawChannel { | 118 class MockRawChannelOnInitFails : public RawChannel { |
| 119 public: | 119 public: |
| 120 MockRawChannelOnInitFails() : on_init_called_(false) {} | 120 MockRawChannelOnInitFails() : on_init_called_(false) {} |
| 121 virtual ~MockRawChannelOnInitFails() {} | 121 ~MockRawChannelOnInitFails() override {} |
| 122 | 122 |
| 123 // |RawChannel| public methods: | 123 // |RawChannel| public methods: |
| 124 virtual size_t GetSerializedPlatformHandleSize() const override { return 0; } | 124 size_t GetSerializedPlatformHandleSize() const override { return 0; } |
| 125 | 125 |
| 126 private: | 126 private: |
| 127 // |RawChannel| protected methods: | 127 // |RawChannel| protected methods: |
| 128 virtual IOResult Read(size_t*) override { | 128 IOResult Read(size_t*) override { |
| 129 CHECK(false); | 129 CHECK(false); |
| 130 return IO_FAILED_UNKNOWN; | 130 return IO_FAILED_UNKNOWN; |
| 131 } | 131 } |
| 132 virtual IOResult ScheduleRead() override { | 132 IOResult ScheduleRead() override { |
| 133 CHECK(false); | 133 CHECK(false); |
| 134 return IO_FAILED_UNKNOWN; | 134 return IO_FAILED_UNKNOWN; |
| 135 } | 135 } |
| 136 virtual embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 136 embedder::ScopedPlatformHandleVectorPtr GetReadPlatformHandles( |
| 137 size_t, | 137 size_t, |
| 138 const void*) override { | 138 const void*) override { |
| 139 CHECK(false); | 139 CHECK(false); |
| 140 return embedder::ScopedPlatformHandleVectorPtr(); | 140 return embedder::ScopedPlatformHandleVectorPtr(); |
| 141 } | 141 } |
| 142 virtual IOResult WriteNoLock(size_t*, size_t*) override { | 142 IOResult WriteNoLock(size_t*, size_t*) override { |
| 143 CHECK(false); | 143 CHECK(false); |
| 144 return IO_FAILED_UNKNOWN; | 144 return IO_FAILED_UNKNOWN; |
| 145 } | 145 } |
| 146 virtual IOResult ScheduleWriteNoLock() override { | 146 IOResult ScheduleWriteNoLock() override { |
| 147 CHECK(false); | 147 CHECK(false); |
| 148 return IO_FAILED_UNKNOWN; | 148 return IO_FAILED_UNKNOWN; |
| 149 } | 149 } |
| 150 virtual bool OnInit() override { | 150 bool OnInit() override { |
| 151 EXPECT_FALSE(on_init_called_); | 151 EXPECT_FALSE(on_init_called_); |
| 152 on_init_called_ = true; | 152 on_init_called_ = true; |
| 153 return false; | 153 return false; |
| 154 } | 154 } |
| 155 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer>, | 155 void OnShutdownNoLock(scoped_ptr<ReadBuffer>, |
| 156 scoped_ptr<WriteBuffer>) override { | 156 scoped_ptr<WriteBuffer>) override { |
| 157 CHECK(false); | 157 CHECK(false); |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool on_init_called_; | 160 bool on_init_called_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(MockRawChannelOnInitFails); | 162 DISALLOW_COPY_AND_ASSIGN(MockRawChannelOnInitFails); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 TEST_F(ChannelTest, InitFails) { | 165 TEST_F(ChannelTest, InitFails) { |
| 166 io_thread()->PostTaskAndWait(FROM_HERE, | 166 io_thread()->PostTaskAndWait(FROM_HERE, |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 mp->Close(0); | 297 mp->Close(0); |
| 298 | 298 |
| 299 EXPECT_TRUE(channel()->HasOneRef()); | 299 EXPECT_TRUE(channel()->HasOneRef()); |
| 300 } | 300 } |
| 301 | 301 |
| 302 // TODO(vtl): More. ------------------------------------------------------------ | 302 // TODO(vtl): More. ------------------------------------------------------------ |
| 303 | 303 |
| 304 } // namespace | 304 } // namespace |
| 305 } // namespace system | 305 } // namespace system |
| 306 } // namespace mojo | 306 } // namespace mojo |
| OLD | NEW |