Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: mojo/edk/test/mojo_test_base.h

Issue 1748503002: [mojo-edk] Add MojoWatch and MojoCancelWatch APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: revert RequestContext usage, nits Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/watcher_set.cc ('k') | mojo/edk/test/mojo_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef MOJO_EDK_TEST_MOJO_TEST_BASE_H_ 5 #ifndef MOJO_EDK_TEST_MOJO_TEST_BASE_H_
6 #define MOJO_EDK_TEST_MOJO_TEST_BASE_H_ 6 #define MOJO_EDK_TEST_MOJO_TEST_BASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h"
18 #include "base/run_loop.h"
19 #include "base/task_runner.h"
20 #include "base/thread_task_runner_handle.h"
21 #include "mojo/edk/embedder/embedder.h" 17 #include "mojo/edk/embedder/embedder.h"
22 #include "mojo/edk/test/multiprocess_test_helper.h" 18 #include "mojo/edk/test/multiprocess_test_helper.h"
23 #include "mojo/public/c/system/types.h" 19 #include "mojo/public/c/system/types.h"
24 #include "mojo/public/cpp/system/message_pipe.h" 20 #include "mojo/public/cpp/system/message_pipe.h"
25 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
26 22
27 namespace mojo { 23 namespace mojo {
28 namespace edk { 24 namespace edk {
29 namespace test { 25 namespace test {
30 26
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Maps a buffer, writes some data into it, and unmaps it. 120 // Maps a buffer, writes some data into it, and unmaps it.
125 static void WriteToBuffer(MojoHandle h, 121 static void WriteToBuffer(MojoHandle h,
126 size_t offset, 122 size_t offset,
127 const base::StringPiece& s); 123 const base::StringPiece& s);
128 124
129 // Maps a buffer, tests the value of some of its contents, and unmaps it. 125 // Maps a buffer, tests the value of some of its contents, and unmaps it.
130 static void ExpectBufferContents(MojoHandle h, 126 static void ExpectBufferContents(MojoHandle h,
131 size_t offset, 127 size_t offset,
132 const base::StringPiece& s); 128 const base::StringPiece& s);
133 129
130 //////// Data pipe test utilities /////////
131
132 // Creates a new data pipe.
133 static void CreateDataPipe(MojoHandle* producer,
134 MojoHandle* consumer,
135 size_t capacity);
136
137 // Writes data to a data pipe.
138 static void WriteData(MojoHandle producer, const std::string& data);
139
140 // Reads data from a data pipe.
141 static std::string ReadData(MojoHandle consumer, size_t size);
142
134 private: 143 private:
135 friend class ClientController; 144 friend class ClientController;
136 145
137 base::MessageLoop message_loop_;
138 std::vector<scoped_ptr<ClientController>> clients_; 146 std::vector<scoped_ptr<ClientController>> clients_;
139 147
140 DISALLOW_COPY_AND_ASSIGN(MojoTestBase); 148 DISALLOW_COPY_AND_ASSIGN(MojoTestBase);
141 }; 149 };
142 150
143 // Launches a new child process running the test client |client_name| connected 151 // Launches a new child process running the test client |client_name| connected
144 // to a new message pipe bound to |pipe_name|. |pipe_name| is automatically 152 // to a new message pipe bound to |pipe_name|. |pipe_name| is automatically
145 // closed on test teardown. 153 // closed on test teardown.
146 #define RUN_CHILD_ON_PIPE(client_name, pipe_name) \ 154 #define RUN_CHILD_ON_PIPE(client_name, pipe_name) \
147 StartClientWithHandler( \ 155 StartClientWithHandler( \
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 #else // !defined(OS_IOS) 217 #else // !defined(OS_IOS)
210 #define DEFINE_TEST_CLIENT_WITH_PIPE(client_name, test_base, pipe_name) 218 #define DEFINE_TEST_CLIENT_WITH_PIPE(client_name, test_base, pipe_name)
211 #define DEFINE_TEST_CLIENT_TEST_WITH_PIPE(client_name, test_base, pipe_name) 219 #define DEFINE_TEST_CLIENT_TEST_WITH_PIPE(client_name, test_base, pipe_name)
212 #endif // !defined(OS_IOS) 220 #endif // !defined(OS_IOS)
213 221
214 } // namespace test 222 } // namespace test
215 } // namespace edk 223 } // namespace edk
216 } // namespace mojo 224 } // namespace mojo
217 225
218 #endif // MOJO_EDK_TEST_MOJO_TEST_BASE_H_ 226 #endif // MOJO_EDK_TEST_MOJO_TEST_BASE_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/watcher_set.cc ('k') | mojo/edk/test/mojo_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698