| 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/platform_handle_dispatcher.h" | 5 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ASSERT_TRUE(fp); | 67 ASSERT_TRUE(fp); |
| 68 | 68 |
| 69 ScopedPlatformHandle h(PlatformHandleFromFILE(std::move(fp))); | 69 ScopedPlatformHandle h(PlatformHandleFromFILE(std::move(fp))); |
| 70 EXPECT_FALSE(fp); | 70 EXPECT_FALSE(fp); |
| 71 ASSERT_TRUE(h.is_valid()); | 71 ASSERT_TRUE(h.is_valid()); |
| 72 | 72 |
| 73 auto d = PlatformHandleDispatcher::Create(h.Pass()); | 73 auto d = PlatformHandleDispatcher::Create(h.Pass()); |
| 74 ASSERT_TRUE(d); | 74 ASSERT_TRUE(d); |
| 75 EXPECT_FALSE(h.is_valid()); | 75 EXPECT_FALSE(h.is_valid()); |
| 76 | 76 |
| 77 EXPECT_FALSE( | 77 EXPECT_FALSE(d->SupportsEntrypointClass(EntrypointClass::MESSAGE_PIPE)); |
| 78 d->SupportsEntrypointClass(Dispatcher::EntrypointClass::MESSAGE_PIPE)); | 78 EXPECT_FALSE(d->SupportsEntrypointClass(EntrypointClass::DATA_PIPE_PRODUCER)); |
| 79 EXPECT_FALSE(d->SupportsEntrypointClass( | 79 EXPECT_FALSE(d->SupportsEntrypointClass(EntrypointClass::DATA_PIPE_CONSUMER)); |
| 80 Dispatcher::EntrypointClass::DATA_PIPE_PRODUCER)); | 80 EXPECT_FALSE(d->SupportsEntrypointClass(EntrypointClass::BUFFER)); |
| 81 EXPECT_FALSE(d->SupportsEntrypointClass( | |
| 82 Dispatcher::EntrypointClass::DATA_PIPE_CONSUMER)); | |
| 83 EXPECT_FALSE(d->SupportsEntrypointClass(Dispatcher::EntrypointClass::BUFFER)); | |
| 84 | 81 |
| 85 // TODO(vtl): Check that it actually returns |MOJO_RESULT_INVALID_ARGUMENT| | 82 // TODO(vtl): Check that it actually returns |MOJO_RESULT_INVALID_ARGUMENT| |
| 86 // for methods in unsupported entrypoint classes. | 83 // for methods in unsupported entrypoint classes. |
| 87 | 84 |
| 88 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); | 85 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); |
| 89 } | 86 } |
| 90 | 87 |
| 91 TEST(PlatformHandleDispatcherTest, CreateEquivalentDispatcherAndClose) { | 88 TEST(PlatformHandleDispatcherTest, CreateEquivalentDispatcherAndClose) { |
| 92 test::ScopedTestDir test_dir; | 89 test::ScopedTestDir test_dir; |
| 93 | 90 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 124 EXPECT_EQ(sizeof(kFooBar), | 121 EXPECT_EQ(sizeof(kFooBar), |
| 125 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); | 122 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); |
| 126 EXPECT_STREQ(kFooBar, read_buffer); | 123 EXPECT_STREQ(kFooBar, read_buffer); |
| 127 | 124 |
| 128 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 125 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 129 } | 126 } |
| 130 | 127 |
| 131 } // namespace | 128 } // namespace |
| 132 } // namespace system | 129 } // namespace system |
| 133 } // namespace mojo | 130 } // namespace mojo |
| OLD | NEW |