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 "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 mojo::test::PlatformHandleFromFILE(fp.Pass()))); | 77 mojo::test::PlatformHandleFromFILE(fp.Pass()))); |
78 | 78 |
79 DispatcherTransport transport( | 79 DispatcherTransport transport( |
80 test::DispatcherTryStartTransport(dispatcher.get())); | 80 test::DispatcherTryStartTransport(dispatcher.get())); |
81 EXPECT_TRUE(transport.is_valid()); | 81 EXPECT_TRUE(transport.is_valid()); |
82 EXPECT_EQ(Dispatcher::kTypePlatformHandle, transport.GetType()); | 82 EXPECT_EQ(Dispatcher::kTypePlatformHandle, transport.GetType()); |
83 EXPECT_FALSE(transport.IsBusy()); | 83 EXPECT_FALSE(transport.IsBusy()); |
84 | 84 |
85 scoped_refptr<Dispatcher> generic_dispatcher = | 85 scoped_refptr<Dispatcher> generic_dispatcher = |
86 transport.CreateEquivalentDispatcherAndClose(); | 86 transport.CreateEquivalentDispatcherAndClose(); |
87 ASSERT_TRUE(generic_dispatcher.get()); | 87 ASSERT_TRUE(generic_dispatcher); |
88 | 88 |
89 transport.End(); | 89 transport.End(); |
90 EXPECT_TRUE(dispatcher->HasOneRef()); | 90 EXPECT_TRUE(dispatcher->HasOneRef()); |
91 dispatcher = nullptr; | 91 dispatcher = nullptr; |
92 | 92 |
93 ASSERT_EQ(Dispatcher::kTypePlatformHandle, generic_dispatcher->GetType()); | 93 ASSERT_EQ(Dispatcher::kTypePlatformHandle, generic_dispatcher->GetType()); |
94 dispatcher = static_cast<PlatformHandleDispatcher*>(generic_dispatcher.get()); | 94 dispatcher = static_cast<PlatformHandleDispatcher*>(generic_dispatcher.get()); |
95 | 95 |
96 fp = mojo::test::FILEFromPlatformHandle(dispatcher->PassPlatformHandle(), | 96 fp = mojo::test::FILEFromPlatformHandle(dispatcher->PassPlatformHandle(), |
97 "rb").Pass(); | 97 "rb").Pass(); |
98 EXPECT_TRUE(fp); | 98 EXPECT_TRUE(fp); |
99 | 99 |
100 rewind(fp.get()); | 100 rewind(fp.get()); |
101 char read_buffer[1000] = {}; | 101 char read_buffer[1000] = {}; |
102 EXPECT_EQ(sizeof(kFooBar), | 102 EXPECT_EQ(sizeof(kFooBar), |
103 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); | 103 fread(read_buffer, 1, sizeof(read_buffer), fp.get())); |
104 EXPECT_STREQ(kFooBar, read_buffer); | 104 EXPECT_STREQ(kFooBar, read_buffer); |
105 | 105 |
106 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 106 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
107 } | 107 } |
108 | 108 |
109 } // namespace | 109 } // namespace |
110 } // namespace system | 110 } // namespace system |
111 } // namespace mojo | 111 } // namespace mojo |
OLD | NEW |