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
3 // found in the LICENSE file.
5 #ifndef MOJO_COMMON_TEST_TEST_UTILS_H_
6 #define MOJO_COMMON_TEST_TEST_UTILS_H_
13 #include "base/files/file_path.h"
14 #include "base/files/scoped_file.h"
15 #include "mojo/embedder/platform_handle.h"
16 #include "mojo/embedder/scoped_platform_handle.h"
21 // On success, |bytes_written| is updated to the number of bytes written;
22 // otherwise it is untouched.
23 bool BlockingWrite(const embedder::PlatformHandle
& handle
,
25 size_t bytes_to_write
,
26 size_t* bytes_written
);
28 // On success, |bytes_read| is updated to the number of bytes read; otherwise it
30 bool BlockingRead(const embedder::PlatformHandle
& handle
,
35 // If the read is done successfully or would block, the function returns true
36 // and updates |bytes_read| to the number of bytes read (0 if the read would
37 // block); otherwise it returns false and leaves |bytes_read| untouched.
38 // |handle| must already be in non-blocking mode.
39 bool NonBlockingRead(const embedder::PlatformHandle
& handle
,
44 // Gets a (scoped) |PlatformHandle| from the given (scoped) |FILE|.
45 embedder::ScopedPlatformHandle
PlatformHandleFromFILE(base::ScopedFILE fp
);
47 // Gets a (scoped) |FILE| from a (scoped) |PlatformHandle|.
48 base::ScopedFILE
FILEFromPlatformHandle(embedder::ScopedPlatformHandle h
,
51 // Returns the path to the mojom js bindings file.
52 base::FilePath
GetFilePathForJSResource(const std::string
& path
);
57 #endif // MOJO_COMMON_TEST_TEST_UTILS_H_