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

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

Issue 799113004: Update mojo sdk to rev 59145288bae55b0fce4276b017df6a1117bcf00f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add mojo's ply to checklicenses whitelist Created 6 years 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/awakable_list.cc ('k') | mojo/edk/system/channel.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 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a 5 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a
6 // heavily-loaded system). Sorry. |test::EpsilonTimeout()| may be increased to 6 // heavily-loaded system). Sorry. |test::EpsilonTimeout()| may be increased to
7 // increase tolerance and reduce observed flakiness (though doing so reduces the 7 // increase tolerance and reduce observed flakiness (though doing so reduces the
8 // meaningfulness of the test). 8 // meaningfulness of the test).
9 9
10 #include "mojo/edk/system/awakable_list.h" 10 #include "mojo/edk/system/awakable_list.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 EXPECT_EQ(MOJO_RESULT_OK, result1); 277 EXPECT_EQ(MOJO_RESULT_OK, result1);
278 EXPECT_EQ(7u, context1); 278 EXPECT_EQ(7u, context1);
279 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result2); 279 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result2);
280 EXPECT_EQ(8u, context2); 280 EXPECT_EQ(8u, context2);
281 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result3); 281 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result3);
282 EXPECT_EQ(9u, context3); 282 EXPECT_EQ(9u, context3);
283 EXPECT_EQ(MOJO_RESULT_CANCELLED, result4); 283 EXPECT_EQ(MOJO_RESULT_CANCELLED, result4);
284 EXPECT_EQ(10u, context4); 284 EXPECT_EQ(10u, context4);
285 } 285 }
286 286
287 class KeepAwakable : public Awakable {
288 public:
289 KeepAwakable() : awake_count(0) {}
290
291 bool Awake(MojoResult result, uintptr_t context) override {
292 awake_count++;
293 return true;
294 }
295
296 int awake_count;
297
298 DISALLOW_COPY_AND_ASSIGN(KeepAwakable);
299 };
300
301 class RemoveAwakable : public Awakable {
302 public:
303 RemoveAwakable() : awake_count(0) {}
304
305 bool Awake(MojoResult result, uintptr_t context) override {
306 awake_count++;
307 return false;
308 }
309
310 int awake_count;
311
312 DISALLOW_COPY_AND_ASSIGN(RemoveAwakable);
313 };
314
315 TEST(AwakableListTest, KeepAwakablesReturningTrue) {
316 KeepAwakable keep0;
317 KeepAwakable keep1;
318 RemoveAwakable remove0;
319 RemoveAwakable remove1;
320 RemoveAwakable remove2;
321
322 HandleSignalsState hss(MOJO_HANDLE_SIGNAL_WRITABLE,
323 MOJO_HANDLE_SIGNAL_WRITABLE);
324
325 AwakableList remove_all;
326 remove_all.Add(&remove0, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
327 remove_all.Add(&remove1, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
328
329 remove_all.AwakeForStateChange(hss);
330 EXPECT_EQ(remove0.awake_count, 1);
331 EXPECT_EQ(remove1.awake_count, 1);
332
333 remove_all.AwakeForStateChange(hss);
334 EXPECT_EQ(remove0.awake_count, 1);
335 EXPECT_EQ(remove1.awake_count, 1);
336
337 AwakableList remove_first;
338 remove_first.Add(&remove2, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
339 remove_first.Add(&keep0, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
340 remove_first.Add(&keep1, MOJO_HANDLE_SIGNAL_WRITABLE, 0);
341
342 remove_first.AwakeForStateChange(hss);
343 EXPECT_EQ(keep0.awake_count, 1);
344 EXPECT_EQ(keep1.awake_count, 1);
345 EXPECT_EQ(remove2.awake_count, 1);
346
347 remove_first.AwakeForStateChange(hss);
348 EXPECT_EQ(keep0.awake_count, 2);
349 EXPECT_EQ(keep1.awake_count, 2);
350 EXPECT_EQ(remove2.awake_count, 1);
351
352 remove_first.Remove(&keep0);
353 remove_first.Remove(&keep1);
354 }
355
287 } // namespace 356 } // namespace
288 } // namespace system 357 } // namespace system
289 } // namespace mojo 358 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/awakable_list.cc ('k') | mojo/edk/system/channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698