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/edk/system/core.h" | 5 #include "mojo/edk/system/core.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 MOJO_RESULT_FAILED_PRECONDITION, | 151 MOJO_RESULT_FAILED_PRECONDITION, |
152 core()->WaitMany(&h, &handle_signals, 1, MOJO_DEADLINE_INDEFINITE, | 152 core()->WaitMany(&h, &handle_signals, 1, MOJO_DEADLINE_INDEFINITE, |
153 &result_index, &hss)); | 153 &result_index, &hss)); |
154 ASSERT_EQ(9u, info.GetAddAwakableCallCount()); | 154 ASSERT_EQ(9u, info.GetAddAwakableCallCount()); |
155 ASSERT_EQ(0u, result_index); | 155 ASSERT_EQ(0u, result_index); |
156 ASSERT_EQ(0u, hss.satisfied_signals); | 156 ASSERT_EQ(0u, hss.satisfied_signals); |
157 ASSERT_EQ(0u, hss.satisfiable_signals); | 157 ASSERT_EQ(0u, hss.satisfiable_signals); |
158 | 158 |
159 ASSERT_EQ(0u, info.GetDtorCallCount()); | 159 ASSERT_EQ(0u, info.GetDtorCallCount()); |
160 ASSERT_EQ(0u, info.GetCloseCallCount()); | 160 ASSERT_EQ(0u, info.GetCloseCallCount()); |
161 ASSERT_EQ(0u, info.GetCancelAllAwakablesCallCount()); | |
162 ASSERT_EQ(MOJO_RESULT_OK, core()->Close(h)); | 161 ASSERT_EQ(MOJO_RESULT_OK, core()->Close(h)); |
163 ASSERT_EQ(1u, info.GetCancelAllAwakablesCallCount()); | |
164 ASSERT_EQ(1u, info.GetCloseCallCount()); | 162 ASSERT_EQ(1u, info.GetCloseCallCount()); |
165 ASSERT_EQ(1u, info.GetDtorCallCount()); | 163 ASSERT_EQ(1u, info.GetDtorCallCount()); |
166 | 164 |
167 // No awakables should ever have ever been added. | 165 // No awakables should ever have ever been added. |
168 ASSERT_EQ(0u, info.GetRemoveAwakableCallCount()); | 166 ASSERT_EQ(0u, info.GetRemoveAwakableCallCount()); |
169 } | 167 } |
170 | 168 |
171 TEST_F(CoreTest, InvalidArguments) { | 169 TEST_F(CoreTest, InvalidArguments) { |
172 // |Close()|: | 170 // |Close()|: |
173 { | 171 { |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 ASSERT_EQ(kHelloSize, num_bytes); | 709 ASSERT_EQ(kHelloSize, num_bytes); |
712 ASSERT_STREQ(kHello, buffer); | 710 ASSERT_STREQ(kHello, buffer); |
713 ASSERT_EQ(0u, num_handles); | 711 ASSERT_EQ(0u, num_handles); |
714 | 712 |
715 // Make sure that you can't pass either of the message pipe's handles over | 713 // Make sure that you can't pass either of the message pipe's handles over |
716 // itself. | 714 // itself. |
717 ASSERT_EQ(MOJO_RESULT_BUSY, | 715 ASSERT_EQ(MOJO_RESULT_BUSY, |
718 core()->WriteMessage(h_passing[0], kHello, kHelloSize, | 716 core()->WriteMessage(h_passing[0], kHello, kHelloSize, |
719 &h_passing[0], 1, | 717 &h_passing[0], 1, |
720 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 718 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
721 #if defined(OS_WIN) | |
722 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | |
723 #endif | |
724 ASSERT_EQ(MOJO_RESULT_INVALID_ARGUMENT, | 719 ASSERT_EQ(MOJO_RESULT_INVALID_ARGUMENT, |
725 core()->WriteMessage(h_passing[0], kHello, kHelloSize, | 720 core()->WriteMessage(h_passing[0], kHello, kHelloSize, |
726 &h_passing[1], 1, | 721 &h_passing[1], 1, |
727 MOJO_WRITE_MESSAGE_FLAG_NONE)); | 722 MOJO_WRITE_MESSAGE_FLAG_NONE)); |
728 #if defined(OS_WIN) | |
729 } | |
730 #endif | |
731 | 723 |
732 MojoHandle h_passed[2]; | 724 MojoHandle h_passed[2]; |
733 MojoCreateMessagePipeOptions options; | 725 MojoCreateMessagePipeOptions options; |
734 options.struct_size = sizeof(MojoCreateMessagePipeOptions); | 726 options.struct_size = sizeof(MojoCreateMessagePipeOptions); |
735 options.flags = MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE; | 727 options.flags = MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE; |
736 ASSERT_EQ(MOJO_RESULT_OK, | 728 ASSERT_EQ(MOJO_RESULT_OK, |
737 core()->CreateMessagePipe(&options, &h_passed[0], &h_passed[1])); | 729 core()->CreateMessagePipe(&options, &h_passed[0], &h_passed[1])); |
738 | 730 |
739 // Make sure that |h_passed[]| work properly. | 731 // Make sure that |h_passed[]| work properly. |
740 ASSERT_EQ(MOJO_RESULT_OK, | 732 ASSERT_EQ(MOJO_RESULT_OK, |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 ASSERT_EQ(MOJO_RESULT_BUSY, waiter.result); | 1261 ASSERT_EQ(MOJO_RESULT_BUSY, waiter.result); |
1270 | 1262 |
1271 ASSERT_EQ(MOJO_RESULT_OK, core()->Close(h)); | 1263 ASSERT_EQ(MOJO_RESULT_OK, core()->Close(h)); |
1272 } | 1264 } |
1273 | 1265 |
1274 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. | 1266 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. |
1275 | 1267 |
1276 } // namespace | 1268 } // namespace |
1277 } // namespace edk | 1269 } // namespace edk |
1278 } // namespace mojo | 1270 } // namespace mojo |
OLD | NEW |