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

Side by Side Diff: mojo/edk/system/ports/ports_unittest.cc

Issue 2799043002: Use ScopedTaskEnvironment instead of MessageLoop in mojo unit tests. (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | no next file » | 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 #include <inttypes.h> 5 #include <inttypes.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <map> 10 #include <map>
11 #include <queue> 11 #include <queue>
12 #include <sstream> 12 #include <sstream>
13 #include <utility> 13 #include <utility>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/rand_util.h" 19 #include "base/rand_util.h"
20 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
21 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
22 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
23 #include "base/synchronization/waitable_event.h" 23 #include "base/synchronization/waitable_event.h"
24 #include "base/test/scoped_task_environment.h"
24 #include "base/threading/thread.h" 25 #include "base/threading/thread.h"
25 #include "mojo/edk/system/ports/event.h" 26 #include "mojo/edk/system/ports/event.h"
26 #include "mojo/edk/system/ports/node.h" 27 #include "mojo/edk/system/ports/node.h"
27 #include "mojo/edk/system/ports/node_delegate.h" 28 #include "mojo/edk/system/ports/node_delegate.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 30
30 namespace mojo { 31 namespace mojo {
31 namespace edk { 32 namespace edk {
32 namespace ports { 33 namespace ports {
33 namespace test { 34 namespace test {
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // NOTE: We only need to support broadcast of events. Events have no 421 // NOTE: We only need to support broadcast of events. Events have no
421 // payload or ports bytes. 422 // payload or ports bytes.
422 ScopedMessage new_message( 423 ScopedMessage new_message(
423 new TestMessage(message->num_header_bytes(), 0, 0)); 424 new TestMessage(message->num_header_bytes(), 0, 0));
424 memcpy(new_message->mutable_header_bytes(), message->header_bytes(), 425 memcpy(new_message->mutable_header_bytes(), message->header_bytes(),
425 message->num_header_bytes()); 426 message->num_header_bytes());
426 node->EnqueueMessage(std::move(new_message)); 427 node->EnqueueMessage(std::move(new_message));
427 } 428 }
428 } 429 }
429 430
430 base::MessageLoop message_loop_; 431 base::test::ScopedTaskEnvironment scoped_task_environment_;
431 432
432 // Acquired before any operation which makes a Node busy, and before testing 433 // Acquired before any operation which makes a Node busy, and before testing
433 // if all nodes are idle. 434 // if all nodes are idle.
434 base::Lock global_lock_; 435 base::Lock global_lock_;
435 436
436 base::Lock lock_; 437 base::Lock lock_;
437 uint64_t next_port_id_ = 1; 438 uint64_t next_port_id_ = 1;
438 std::map<NodeName, TestNode*> nodes_; 439 std::map<NodeName, TestNode*> nodes_;
439 }; 440 };
440 441
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 1470
1470 // Expect everything to have gone away. 1471 // Expect everything to have gone away.
1471 EXPECT_TRUE(node0.node().CanShutdownCleanly()); 1472 EXPECT_TRUE(node0.node().CanShutdownCleanly());
1472 EXPECT_TRUE(node1.node().CanShutdownCleanly()); 1473 EXPECT_TRUE(node1.node().CanShutdownCleanly());
1473 } 1474 }
1474 1475
1475 } // namespace test 1476 } // namespace test
1476 } // namespace ports 1477 } // namespace ports
1477 } // namespace edk 1478 } // namespace edk
1478 } // namespace mojo 1479 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698