| 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 | 95 |
| 96 auto dispatcher = | 96 auto dispatcher = |
| 97 PlatformHandleDispatcher::Create(PlatformHandleFromFILE(std::move(fp))); | 97 PlatformHandleDispatcher::Create(PlatformHandleFromFILE(std::move(fp))); |
| 98 | 98 |
| 99 DispatcherTransport transport( | 99 DispatcherTransport transport( |
| 100 test::DispatcherTryStartTransport(dispatcher.get())); | 100 test::DispatcherTryStartTransport(dispatcher.get())); |
| 101 EXPECT_TRUE(transport.is_valid()); | 101 EXPECT_TRUE(transport.is_valid()); |
| 102 EXPECT_EQ(Dispatcher::Type::PLATFORM_HANDLE, transport.GetType()); | 102 EXPECT_EQ(Dispatcher::Type::PLATFORM_HANDLE, transport.GetType()); |
| 103 EXPECT_FALSE(transport.IsBusy()); | 103 EXPECT_FALSE(transport.IsBusy()); |
| 104 | 104 |
| 105 auto generic_dispatcher = transport.CreateEquivalentDispatcherAndClose(); | 105 auto generic_dispatcher = |
| 106 transport.CreateEquivalentDispatcherAndClose(nullptr, 0u); |
| 106 ASSERT_TRUE(generic_dispatcher); | 107 ASSERT_TRUE(generic_dispatcher); |
| 107 | 108 |
| 108 transport.End(); | 109 transport.End(); |
| 109 EXPECT_TRUE(dispatcher->HasOneRef()); | 110 EXPECT_TRUE(dispatcher->HasOneRef()); |
| 110 dispatcher = nullptr; | 111 dispatcher = nullptr; |
| 111 | 112 |
| 112 ASSERT_EQ(Dispatcher::Type::PLATFORM_HANDLE, generic_dispatcher->GetType()); | 113 ASSERT_EQ(Dispatcher::Type::PLATFORM_HANDLE, generic_dispatcher->GetType()); |
| 113 dispatcher = RefPtr<PlatformHandleDispatcher>( | 114 dispatcher = RefPtr<PlatformHandleDispatcher>( |
| 114 static_cast<PlatformHandleDispatcher*>(generic_dispatcher.get())); | 115 static_cast<PlatformHandleDispatcher*>(generic_dispatcher.get())); |
| 115 | 116 |
| 116 fp = FILEFromPlatformHandle(dispatcher->PassPlatformHandle(), "rb"); | 117 fp = FILEFromPlatformHandle(dispatcher->PassPlatformHandle(), "rb"); |
| 117 EXPECT_TRUE(fp); | 118 EXPECT_TRUE(fp); |
| 118 | 119 |
| 119 rewind(fp.get()); | 120 rewind(fp.get()); |
| 120 char read_buffer[1000] = {}; | 121 char read_buffer[1000] = {}; |
| 121 EXPECT_EQ(sizeof(kFooBar), | 122 EXPECT_EQ(sizeof(kFooBar), |
| 122 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); | 123 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); |
| 123 EXPECT_STREQ(kFooBar, read_buffer); | 124 EXPECT_STREQ(kFooBar, read_buffer); |
| 124 | 125 |
| 125 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 126 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 126 } | 127 } |
| 127 | 128 |
| 128 } // namespace | 129 } // namespace |
| 129 } // namespace system | 130 } // namespace system |
| 130 } // namespace mojo | 131 } // namespace mojo |
| OLD | NEW |