| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 util::ScopedFILE fp(test_dir.CreateFile()); | 95 util::ScopedFILE fp(test_dir.CreateFile()); |
| 96 EXPECT_EQ(sizeof(kFooBar), fwrite(kFooBar, 1, sizeof(kFooBar), fp.get())); | 96 EXPECT_EQ(sizeof(kFooBar), fwrite(kFooBar, 1, sizeof(kFooBar), fp.get())); |
| 97 | 97 |
| 98 auto dispatcher = | 98 auto dispatcher = |
| 99 PlatformHandleDispatcher::Create(PlatformHandleFromFILE(std::move(fp))); | 99 PlatformHandleDispatcher::Create(PlatformHandleFromFILE(std::move(fp))); |
| 100 // TODO(vtl): Are these the correct rights for a |PlatformHandleDispatcher|? | 100 // TODO(vtl): Are these the correct rights for a |PlatformHandleDispatcher|? |
| 101 Handle handle(std::move(dispatcher), MOJO_HANDLE_RIGHT_TRANSFER | | 101 Handle handle(std::move(dispatcher), MOJO_HANDLE_RIGHT_TRANSFER | |
| 102 MOJO_HANDLE_RIGHT_READ | | 102 MOJO_HANDLE_RIGHT_READ | |
| 103 MOJO_HANDLE_RIGHT_WRITE); | 103 MOJO_HANDLE_RIGHT_WRITE); |
| 104 | 104 |
| 105 DispatcherTransport transport(test::HandleTryStartTransport(handle)); | 105 HandleTransport transport(test::HandleTryStartTransport(handle)); |
| 106 EXPECT_TRUE(transport.is_valid()); | 106 EXPECT_TRUE(transport.is_valid()); |
| 107 EXPECT_EQ(Dispatcher::Type::PLATFORM_HANDLE, transport.GetType()); | 107 EXPECT_EQ(Dispatcher::Type::PLATFORM_HANDLE, transport.GetType()); |
| 108 EXPECT_FALSE(transport.IsBusy()); | 108 EXPECT_FALSE(transport.IsBusy()); |
| 109 | 109 |
| 110 auto generic_dispatcher = | 110 auto generic_dispatcher = |
| 111 transport.CreateEquivalentDispatcherAndClose(nullptr, 0u); | 111 transport.CreateEquivalentDispatcherAndClose(nullptr, 0u); |
| 112 ASSERT_TRUE(generic_dispatcher); | 112 ASSERT_TRUE(generic_dispatcher); |
| 113 | 113 |
| 114 transport.End(); | 114 transport.End(); |
| 115 EXPECT_TRUE(handle.dispatcher->HasOneRef()); | 115 EXPECT_TRUE(handle.dispatcher->HasOneRef()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 EXPECT_EQ(sizeof(kFooBar), | 127 EXPECT_EQ(sizeof(kFooBar), |
| 128 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); | 128 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); |
| 129 EXPECT_STREQ(kFooBar, read_buffer); | 129 EXPECT_STREQ(kFooBar, read_buffer); |
| 130 | 130 |
| 131 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 131 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace | 134 } // namespace |
| 135 } // namespace system | 135 } // namespace system |
| 136 } // namespace mojo | 136 } // namespace mojo |
| OLD | NEW |