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

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

Issue 1483823004: EDK: Move {platform_handle,scoped_platform_handle}.* to //mojo/edk/platform. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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/connection_manager.h ('k') | mojo/edk/system/data_pipe.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This is really a unit test for |MasterConnectionManager| and 5 // This is really a unit test for |MasterConnectionManager| and
6 // |SlaveConnectionManager| (since they need to be tested together). 6 // |SlaveConnectionManager| (since they need to be tested together).
7 7
8 #include "mojo/edk/system/connection_manager.h" 8 #include "mojo/edk/system/connection_manager.h"
9 9
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 14
15 #include "mojo/edk/base_edk/platform_task_runner_impl.h" 15 #include "mojo/edk/base_edk/platform_task_runner_impl.h"
16 #include "mojo/edk/embedder/master_process_delegate.h" 16 #include "mojo/edk/embedder/master_process_delegate.h"
17 #include "mojo/edk/embedder/platform_channel_pair.h" 17 #include "mojo/edk/embedder/platform_channel_pair.h"
18 #include "mojo/edk/embedder/simple_platform_support.h" 18 #include "mojo/edk/embedder/simple_platform_support.h"
19 #include "mojo/edk/embedder/slave_process_delegate.h" 19 #include "mojo/edk/embedder/slave_process_delegate.h"
20 #include "mojo/edk/platform/message_loop.h" 20 #include "mojo/edk/platform/message_loop.h"
21 #include "mojo/edk/platform/platform_handle.h"
21 #include "mojo/edk/platform/test_message_loops.h" 22 #include "mojo/edk/platform/test_message_loops.h"
22 #include "mojo/edk/system/master_connection_manager.h" 23 #include "mojo/edk/system/master_connection_manager.h"
23 #include "mojo/edk/system/slave_connection_manager.h" 24 #include "mojo/edk/system/slave_connection_manager.h"
24 #include "mojo/edk/test/test_utils.h" 25 #include "mojo/edk/test/test_utils.h"
25 #include "mojo/edk/util/ref_ptr.h" 26 #include "mojo/edk/util/ref_ptr.h"
26 #include "mojo/edk/util/thread_checker.h" 27 #include "mojo/edk/util/thread_checker.h"
27 #include "mojo/public/cpp/system/macros.h" 28 #include "mojo/public/cpp/system/macros.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 30
30 using mojo::embedder::ScopedPlatformHandle;
31 using mojo::platform::MessageLoop; 31 using mojo::platform::MessageLoop;
32 using mojo::platform::PlatformHandle;
33 using mojo::platform::ScopedPlatformHandle;
32 using mojo::platform::TaskRunner; 34 using mojo::platform::TaskRunner;
33 using mojo::platform::test::CreateTestMessageLoop; 35 using mojo::platform::test::CreateTestMessageLoop;
34 using mojo::util::MakeRefCounted; 36 using mojo::util::MakeRefCounted;
35 using mojo::util::RefPtr; 37 using mojo::util::RefPtr;
36 using mojo::util::ThreadChecker; 38 using mojo::util::ThreadChecker;
37 39
38 namespace mojo { 40 namespace mojo {
39 namespace system { 41 namespace system {
40 namespace { 42 namespace {
41 43
42 bool ArePlatformHandlesConnected(const embedder::PlatformHandle& h1, 44 bool ArePlatformHandlesConnected(const PlatformHandle& h1,
43 const embedder::PlatformHandle& h2) { 45 const PlatformHandle& h2) {
44 const uint32_t w1 = 0xdeadbeef; 46 const uint32_t w1 = 0xdeadbeef;
45 size_t num_bytes = 0; 47 size_t num_bytes = 0;
46 if (!mojo::test::BlockingWrite(h1, &w1, sizeof(w1), &num_bytes) || 48 if (!mojo::test::BlockingWrite(h1, &w1, sizeof(w1), &num_bytes) ||
47 num_bytes != sizeof(w1)) 49 num_bytes != sizeof(w1))
48 return false; 50 return false;
49 uint32_t r = 0; 51 uint32_t r = 0;
50 num_bytes = 0; 52 num_bytes = 0;
51 if (!mojo::test::BlockingRead(h2, &r, sizeof(r), &num_bytes) || 53 if (!mojo::test::BlockingRead(h2, &r, sizeof(r), &num_bytes) ||
52 num_bytes != sizeof(r)) 54 num_bytes != sizeof(r))
53 return false; 55 return false;
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 695
694 slave.Shutdown(); 696 slave.Shutdown();
695 master.Shutdown(); 697 master.Shutdown();
696 } 698 }
697 699
698 // TODO(vtl): More shutdown cases for |AddSlaveAndBootstrap()|? 700 // TODO(vtl): More shutdown cases for |AddSlaveAndBootstrap()|?
699 701
700 } // namespace 702 } // namespace
701 } // namespace system 703 } // namespace system
702 } // namespace mojo 704 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/connection_manager.h ('k') | mojo/edk/system/data_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698