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

Side by Side Diff: mojo/edk/system/dispatcher_unittest.cc

Issue 728043002: Revert of Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/dispatcher.cc ('k') | mojo/edk/system/entrypoints.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/dispatcher.h" 5 #include "mojo/edk/system/dispatcher.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 26 matching lines...) Expand all
37 37
38 DISALLOW_COPY_AND_ASSIGN(TrivialDispatcher); 38 DISALLOW_COPY_AND_ASSIGN(TrivialDispatcher);
39 }; 39 };
40 40
41 TEST(DispatcherTest, Basic) { 41 TEST(DispatcherTest, Basic) {
42 scoped_refptr<Dispatcher> d(new TrivialDispatcher()); 42 scoped_refptr<Dispatcher> d(new TrivialDispatcher());
43 43
44 EXPECT_EQ(Dispatcher::kTypeUnknown, d->GetType()); 44 EXPECT_EQ(Dispatcher::kTypeUnknown, d->GetType());
45 45
46 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 46 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
47 d->WriteMessage(NullUserPointer(), 0, nullptr, 47 d->WriteMessage(
48 MOJO_WRITE_MESSAGE_FLAG_NONE)); 48 NullUserPointer(), 0, nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
49 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 49 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
50 d->ReadMessage(NullUserPointer(), NullUserPointer(), nullptr, 50 d->ReadMessage(NullUserPointer(),
51 nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE)); 51 NullUserPointer(),
52 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 52 nullptr,
53 d->WriteData(NullUserPointer(), NullUserPointer(), 53 nullptr,
54 MOJO_WRITE_DATA_FLAG_NONE)); 54 MOJO_WRITE_MESSAGE_FLAG_NONE));
55 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 55 EXPECT_EQ(
56 d->BeginWriteData(NullUserPointer(), NullUserPointer(), 56 MOJO_RESULT_INVALID_ARGUMENT,
57 MOJO_WRITE_DATA_FLAG_NONE)); 57 d->WriteData(
58 NullUserPointer(), NullUserPointer(), MOJO_WRITE_DATA_FLAG_NONE));
59 EXPECT_EQ(
60 MOJO_RESULT_INVALID_ARGUMENT,
61 d->BeginWriteData(
62 NullUserPointer(), NullUserPointer(), MOJO_WRITE_DATA_FLAG_NONE));
58 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndWriteData(0)); 63 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndWriteData(0));
59 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 64 EXPECT_EQ(
60 d->ReadData(NullUserPointer(), NullUserPointer(), 65 MOJO_RESULT_INVALID_ARGUMENT,
61 MOJO_READ_DATA_FLAG_NONE)); 66 d->ReadData(
62 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 67 NullUserPointer(), NullUserPointer(), MOJO_READ_DATA_FLAG_NONE));
63 d->BeginReadData(NullUserPointer(), NullUserPointer(), 68 EXPECT_EQ(
64 MOJO_READ_DATA_FLAG_NONE)); 69 MOJO_RESULT_INVALID_ARGUMENT,
70 d->BeginReadData(
71 NullUserPointer(), NullUserPointer(), MOJO_READ_DATA_FLAG_NONE));
65 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndReadData(0)); 72 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndReadData(0));
66 Waiter w; 73 Waiter w;
67 w.Init(); 74 w.Init();
68 HandleSignalsState hss; 75 HandleSignalsState hss;
69 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, 76 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
70 d->AddWaiter(&w, ~MOJO_HANDLE_SIGNAL_NONE, 0, &hss)); 77 d->AddWaiter(&w, ~MOJO_HANDLE_SIGNAL_NONE, 0, &hss));
71 EXPECT_EQ(0u, hss.satisfied_signals); 78 EXPECT_EQ(0u, hss.satisfied_signals);
72 EXPECT_EQ(0u, hss.satisfiable_signals); 79 EXPECT_EQ(0u, hss.satisfiable_signals);
73 // Okay to remove even if it wasn't added (or was already removed). 80 // Okay to remove even if it wasn't added (or was already removed).
74 hss = HandleSignalsState(); 81 hss = HandleSignalsState();
75 d->RemoveWaiter(&w, &hss); 82 d->RemoveWaiter(&w, &hss);
76 EXPECT_EQ(0u, hss.satisfied_signals); 83 EXPECT_EQ(0u, hss.satisfied_signals);
77 EXPECT_EQ(0u, hss.satisfiable_signals); 84 EXPECT_EQ(0u, hss.satisfiable_signals);
78 hss = HandleSignalsState(); 85 hss = HandleSignalsState();
79 d->RemoveWaiter(&w, &hss); 86 d->RemoveWaiter(&w, &hss);
80 EXPECT_EQ(0u, hss.satisfied_signals); 87 EXPECT_EQ(0u, hss.satisfied_signals);
81 EXPECT_EQ(0u, hss.satisfiable_signals); 88 EXPECT_EQ(0u, hss.satisfiable_signals);
82 89
83 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); 90 EXPECT_EQ(MOJO_RESULT_OK, d->Close());
84 91
85 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 92 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
86 d->WriteMessage(NullUserPointer(), 0, nullptr, 93 d->WriteMessage(
87 MOJO_WRITE_MESSAGE_FLAG_NONE)); 94 NullUserPointer(), 0, nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
88 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 95 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
89 d->ReadMessage(NullUserPointer(), NullUserPointer(), nullptr, 96 d->ReadMessage(NullUserPointer(),
90 nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE)); 97 NullUserPointer(),
91 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 98 nullptr,
92 d->WriteData(NullUserPointer(), NullUserPointer(), 99 nullptr,
93 MOJO_WRITE_DATA_FLAG_NONE)); 100 MOJO_WRITE_MESSAGE_FLAG_NONE));
94 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 101 EXPECT_EQ(
95 d->BeginWriteData(NullUserPointer(), NullUserPointer(), 102 MOJO_RESULT_INVALID_ARGUMENT,
96 MOJO_WRITE_DATA_FLAG_NONE)); 103 d->WriteData(
104 NullUserPointer(), NullUserPointer(), MOJO_WRITE_DATA_FLAG_NONE));
105 EXPECT_EQ(
106 MOJO_RESULT_INVALID_ARGUMENT,
107 d->BeginWriteData(
108 NullUserPointer(), NullUserPointer(), MOJO_WRITE_DATA_FLAG_NONE));
97 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndWriteData(0)); 109 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndWriteData(0));
98 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 110 EXPECT_EQ(
99 d->ReadData(NullUserPointer(), NullUserPointer(), 111 MOJO_RESULT_INVALID_ARGUMENT,
100 MOJO_READ_DATA_FLAG_NONE)); 112 d->ReadData(
101 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 113 NullUserPointer(), NullUserPointer(), MOJO_READ_DATA_FLAG_NONE));
102 d->BeginReadData(NullUserPointer(), NullUserPointer(), 114 EXPECT_EQ(
103 MOJO_READ_DATA_FLAG_NONE)); 115 MOJO_RESULT_INVALID_ARGUMENT,
116 d->BeginReadData(
117 NullUserPointer(), NullUserPointer(), MOJO_READ_DATA_FLAG_NONE));
104 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndReadData(0)); 118 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, d->EndReadData(0));
105 hss = HandleSignalsState(); 119 hss = HandleSignalsState();
106 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 120 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
107 d->AddWaiter(&w, ~MOJO_HANDLE_SIGNAL_NONE, 0, &hss)); 121 d->AddWaiter(&w, ~MOJO_HANDLE_SIGNAL_NONE, 0, &hss));
108 EXPECT_EQ(0u, hss.satisfied_signals); 122 EXPECT_EQ(0u, hss.satisfied_signals);
109 EXPECT_EQ(0u, hss.satisfiable_signals); 123 EXPECT_EQ(0u, hss.satisfiable_signals);
110 hss = HandleSignalsState(); 124 hss = HandleSignalsState();
111 d->RemoveWaiter(&w, &hss); 125 d->RemoveWaiter(&w, &hss);
112 EXPECT_EQ(0u, hss.satisfied_signals); 126 EXPECT_EQ(0u, hss.satisfied_signals);
113 EXPECT_EQ(0u, hss.satisfiable_signals); 127 EXPECT_EQ(0u, hss.satisfiable_signals);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 165
152 waiter_.Init(); 166 waiter_.Init();
153 switch (op_) { 167 switch (op_) {
154 case CLOSE: { 168 case CLOSE: {
155 MojoResult r = dispatcher_->Close(); 169 MojoResult r = dispatcher_->Close();
156 EXPECT_TRUE(r == MOJO_RESULT_OK || r == MOJO_RESULT_INVALID_ARGUMENT) 170 EXPECT_TRUE(r == MOJO_RESULT_OK || r == MOJO_RESULT_INVALID_ARGUMENT)
157 << "Result: " << r; 171 << "Result: " << r;
158 break; 172 break;
159 } 173 }
160 case WRITE_MESSAGE: 174 case WRITE_MESSAGE:
161 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 175 EXPECT_EQ(
162 dispatcher_->WriteMessage(NullUserPointer(), 0, nullptr, 176 MOJO_RESULT_INVALID_ARGUMENT,
163 MOJO_WRITE_MESSAGE_FLAG_NONE)); 177 dispatcher_->WriteMessage(
178 NullUserPointer(), 0, nullptr, MOJO_WRITE_MESSAGE_FLAG_NONE));
164 break; 179 break;
165 case READ_MESSAGE: 180 case READ_MESSAGE:
166 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 181 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
167 dispatcher_->ReadMessage(NullUserPointer(), NullUserPointer(), 182 dispatcher_->ReadMessage(NullUserPointer(),
168 nullptr, nullptr, 183 NullUserPointer(),
184 nullptr,
185 nullptr,
169 MOJO_WRITE_MESSAGE_FLAG_NONE)); 186 MOJO_WRITE_MESSAGE_FLAG_NONE));
170 break; 187 break;
171 case WRITE_DATA: 188 case WRITE_DATA:
172 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 189 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
173 dispatcher_->WriteData(NullUserPointer(), NullUserPointer(), 190 dispatcher_->WriteData(NullUserPointer(),
191 NullUserPointer(),
174 MOJO_WRITE_DATA_FLAG_NONE)); 192 MOJO_WRITE_DATA_FLAG_NONE));
175 break; 193 break;
176 case BEGIN_WRITE_DATA: 194 case BEGIN_WRITE_DATA:
177 EXPECT_EQ( 195 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
178 MOJO_RESULT_INVALID_ARGUMENT, 196 dispatcher_->BeginWriteData(NullUserPointer(),
179 dispatcher_->BeginWriteData(NullUserPointer(), NullUserPointer(), 197 NullUserPointer(),
180 MOJO_WRITE_DATA_FLAG_NONE)); 198 MOJO_WRITE_DATA_FLAG_NONE));
181 break; 199 break;
182 case END_WRITE_DATA: 200 case END_WRITE_DATA:
183 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, dispatcher_->EndWriteData(0)); 201 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, dispatcher_->EndWriteData(0));
184 break; 202 break;
185 case READ_DATA: 203 case READ_DATA:
186 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 204 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
187 dispatcher_->ReadData(NullUserPointer(), NullUserPointer(), 205 dispatcher_->ReadData(NullUserPointer(),
206 NullUserPointer(),
188 MOJO_READ_DATA_FLAG_NONE)); 207 MOJO_READ_DATA_FLAG_NONE));
189 break; 208 break;
190 case BEGIN_READ_DATA: 209 case BEGIN_READ_DATA:
191 EXPECT_EQ( 210 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
192 MOJO_RESULT_INVALID_ARGUMENT, 211 dispatcher_->BeginReadData(NullUserPointer(),
193 dispatcher_->BeginReadData(NullUserPointer(), NullUserPointer(), 212 NullUserPointer(),
194 MOJO_READ_DATA_FLAG_NONE)); 213 MOJO_READ_DATA_FLAG_NONE));
195 break; 214 break;
196 case END_READ_DATA: 215 case END_READ_DATA:
197 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, dispatcher_->EndReadData(0)); 216 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, dispatcher_->EndReadData(0));
198 break; 217 break;
199 case DUPLICATE_BUFFER_HANDLE: { 218 case DUPLICATE_BUFFER_HANDLE: {
200 scoped_refptr<Dispatcher> unused; 219 scoped_refptr<Dispatcher> unused;
201 EXPECT_EQ( 220 EXPECT_EQ(
202 MOJO_RESULT_INVALID_ARGUMENT, 221 MOJO_RESULT_INVALID_ARGUMENT,
203 dispatcher_->DuplicateBufferHandle(NullUserPointer(), &unused)); 222 dispatcher_->DuplicateBufferHandle(NullUserPointer(), &unused));
204 break; 223 break;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 event.Signal(); 317 event.Signal();
299 } // Joins all the threads. 318 } // Joins all the threads.
300 319
301 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); 320 EXPECT_EQ(MOJO_RESULT_OK, d->Close());
302 } 321 }
303 } 322 }
304 323
305 } // namespace 324 } // namespace
306 } // namespace system 325 } // namespace system
307 } // namespace mojo 326 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/dispatcher.cc ('k') | mojo/edk/system/entrypoints.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698