| 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/public/cpp/bindings/allocation_scope.h" | 5 #include "mojo/public/cpp/bindings/allocation_scope.h" |
| 6 #include "mojo/public/cpp/bindings/array.h" | 6 #include "mojo/public/cpp/bindings/array.h" |
| 7 #include "mojo/public/cpp/bindings/interface.h" | |
| 8 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" | 7 #include "mojo/public/cpp/bindings/lib/fixed_buffer.h" |
| 9 #include "mojo/public/cpp/bindings/lib/scratch_buffer.h" | 8 #include "mojo/public/cpp/bindings/lib/scratch_buffer.h" |
| 10 #include "mojo/public/cpp/environment/environment.h" | 9 #include "mojo/public/cpp/environment/environment.h" |
| 11 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" | 10 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 12 |
| 14 namespace mojo { | 13 namespace mojo { |
| 15 namespace test { | 14 namespace test { |
| 16 namespace { | 15 namespace { |
| 17 | 16 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 133 |
| 135 MOJO_ALLOW_UNUSED Array<MessagePipeHandle> handles = | 134 MOJO_ALLOW_UNUSED Array<MessagePipeHandle> handles = |
| 136 handles_builder.Finish(); | 135 handles_builder.Finish(); |
| 137 } | 136 } |
| 138 | 137 |
| 139 // We expect the pipes to have been closed. | 138 // We expect the pipes to have been closed. |
| 140 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(pipe0_value)); | 139 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(pipe0_value)); |
| 141 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(pipe1_value)); | 140 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(pipe1_value)); |
| 142 } | 141 } |
| 143 | 142 |
| 144 // Tests that Array<InterfaceHandle<S>> supports closing handles. | |
| 145 TEST(ArrayTest, InterfaceHandlesAreClosed) { | |
| 146 Environment env; | |
| 147 | |
| 148 InterfacePipe<sample::Port, sample::Port> pipe; | |
| 149 | |
| 150 MojoHandle pipe0_value = pipe.handle_to_self.get().value(); | |
| 151 MojoHandle pipe1_value = pipe.handle_to_peer.get().value(); | |
| 152 | |
| 153 { | |
| 154 AllocationScope scope; | |
| 155 | |
| 156 Array<sample::PortHandle>::Builder handles_builder(2); | |
| 157 handles_builder[0] = pipe.handle_to_self.Pass(); | |
| 158 handles_builder[1].reset(pipe.handle_to_peer.release()); | |
| 159 | |
| 160 MOJO_ALLOW_UNUSED Array<sample::PortHandle> handles = | |
| 161 handles_builder.Finish(); | |
| 162 } | |
| 163 | |
| 164 // We expect the pipes to have been closed. | |
| 165 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(pipe0_value)); | |
| 166 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(pipe1_value)); | |
| 167 } | |
| 168 | |
| 169 } // namespace | 143 } // namespace |
| 170 } // namespace test | 144 } // namespace test |
| 171 } // namespace mojo | 145 } // namespace mojo |
| OLD | NEW |