| 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/system/channel.h" | 5 #include "mojo/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 17 matching lines...) Expand all Loading... |
| 28 return b ? TRISTATE_TRUE : TRISTATE_FALSE; | 28 return b ? TRISTATE_TRUE : TRISTATE_FALSE; |
| 29 } | 29 } |
| 30 | 30 |
| 31 class ChannelTest : public testing::Test { | 31 class ChannelTest : public testing::Test { |
| 32 public: | 32 public: |
| 33 ChannelTest() | 33 ChannelTest() |
| 34 : io_thread_(base::TestIOThread::kAutoStart), | 34 : io_thread_(base::TestIOThread::kAutoStart), |
| 35 init_result_(TRISTATE_UNKNOWN) {} | 35 init_result_(TRISTATE_UNKNOWN) {} |
| 36 virtual ~ChannelTest() {} | 36 virtual ~ChannelTest() {} |
| 37 | 37 |
| 38 virtual void SetUp() OVERRIDE { | 38 virtual void SetUp() override { |
| 39 io_thread_.PostTaskAndWait( | 39 io_thread_.PostTaskAndWait( |
| 40 FROM_HERE, | 40 FROM_HERE, |
| 41 base::Bind(&ChannelTest::SetUpOnIOThread, base::Unretained(this))); | 41 base::Bind(&ChannelTest::SetUpOnIOThread, base::Unretained(this))); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void CreateChannelOnIOThread() { | 44 void CreateChannelOnIOThread() { |
| 45 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); | 45 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); |
| 46 channel_ = new Channel(&platform_support_); | 46 channel_ = new Channel(&platform_support_); |
| 47 } | 47 } |
| 48 | 48 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 virtual ~MockRawChannelOnInitFails() {} |
| 122 | 122 |
| 123 // |RawChannel| public methods: | 123 // |RawChannel| public methods: |
| 124 virtual size_t GetSerializedPlatformHandleSize() const OVERRIDE { return 0; } | 124 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 mp->Close(0); | 314 mp->Close(0); |
| 315 | 315 |
| 316 EXPECT_TRUE(channel()->HasOneRef()); | 316 EXPECT_TRUE(channel()->HasOneRef()); |
| 317 } | 317 } |
| 318 | 318 |
| 319 // TODO(vtl): More. ------------------------------------------------------------ | 319 // TODO(vtl): More. ------------------------------------------------------------ |
| 320 | 320 |
| 321 } // namespace | 321 } // namespace |
| 322 } // namespace system | 322 } // namespace system |
| 323 } // namespace mojo | 323 } // namespace mojo |
| OLD | NEW |