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

Side by Side Diff: mojo/system/remote_message_pipe_unittest.cc

Issue 488003003: Add ChannelProxy benchmark to ipc_perftests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing. Created 6 years, 3 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/system/raw_channel_unittest.cc ('k') | mojo/system/test_utils.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/scoped_file.h" 14 #include "base/files/scoped_file.h"
15 #include "base/files/scoped_temp_dir.h" 15 #include "base/files/scoped_temp_dir.h"
16 #include "base/location.h" 16 #include "base/location.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/test/test_io_thread.h"
20 #include "base/threading/platform_thread.h" // For |Sleep()|. 21 #include "base/threading/platform_thread.h" // For |Sleep()|.
21 #include "build/build_config.h" // TODO(vtl): Remove this. 22 #include "build/build_config.h" // TODO(vtl): Remove this.
22 #include "mojo/common/test/test_utils.h" 23 #include "mojo/common/test/test_utils.h"
23 #include "mojo/embedder/platform_channel_pair.h" 24 #include "mojo/embedder/platform_channel_pair.h"
24 #include "mojo/embedder/platform_shared_buffer.h" 25 #include "mojo/embedder/platform_shared_buffer.h"
25 #include "mojo/embedder/scoped_platform_handle.h" 26 #include "mojo/embedder/scoped_platform_handle.h"
26 #include "mojo/embedder/simple_platform_support.h" 27 #include "mojo/embedder/simple_platform_support.h"
27 #include "mojo/system/channel.h" 28 #include "mojo/system/channel.h"
28 #include "mojo/system/message_pipe.h" 29 #include "mojo/system/message_pipe.h"
29 #include "mojo/system/message_pipe_dispatcher.h" 30 #include "mojo/system/message_pipe_dispatcher.h"
30 #include "mojo/system/platform_handle_dispatcher.h" 31 #include "mojo/system/platform_handle_dispatcher.h"
31 #include "mojo/system/raw_channel.h" 32 #include "mojo/system/raw_channel.h"
32 #include "mojo/system/shared_buffer_dispatcher.h" 33 #include "mojo/system/shared_buffer_dispatcher.h"
33 #include "mojo/system/test_utils.h" 34 #include "mojo/system/test_utils.h"
34 #include "mojo/system/waiter.h" 35 #include "mojo/system/waiter.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 37
37 namespace mojo { 38 namespace mojo {
38 namespace system { 39 namespace system {
39 namespace { 40 namespace {
40 41
41 class RemoteMessagePipeTest : public testing::Test { 42 class RemoteMessagePipeTest : public testing::Test {
42 public: 43 public:
43 RemoteMessagePipeTest() : io_thread_(test::TestIOThread::kAutoStart) {} 44 RemoteMessagePipeTest() : io_thread_(base::TestIOThread::kAutoStart) {}
44 virtual ~RemoteMessagePipeTest() {} 45 virtual ~RemoteMessagePipeTest() {}
45 46
46 virtual void SetUp() OVERRIDE { 47 virtual void SetUp() OVERRIDE {
47 io_thread_.PostTaskAndWait( 48 io_thread_.PostTaskAndWait(
48 FROM_HERE, 49 FROM_HERE,
49 base::Bind(&RemoteMessagePipeTest::SetUpOnIOThread, 50 base::Bind(&RemoteMessagePipeTest::SetUpOnIOThread,
50 base::Unretained(this))); 51 base::Unretained(this)));
51 } 52 }
52 53
53 virtual void TearDown() OVERRIDE { 54 virtual void TearDown() OVERRIDE {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 87 }
87 88
88 void RestoreInitialState() { 89 void RestoreInitialState() {
89 io_thread_.PostTaskAndWait( 90 io_thread_.PostTaskAndWait(
90 FROM_HERE, 91 FROM_HERE,
91 base::Bind(&RemoteMessagePipeTest::RestoreInitialStateOnIOThread, 92 base::Bind(&RemoteMessagePipeTest::RestoreInitialStateOnIOThread,
92 base::Unretained(this))); 93 base::Unretained(this)));
93 } 94 }
94 95
95 embedder::PlatformSupport* platform_support() { return &platform_support_; } 96 embedder::PlatformSupport* platform_support() { return &platform_support_; }
96 test::TestIOThread* io_thread() { return &io_thread_; } 97 base::TestIOThread* io_thread() { return &io_thread_; }
97 98
98 private: 99 private:
99 void SetUpOnIOThread() { 100 void SetUpOnIOThread() {
100 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); 101 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop());
101 102
102 embedder::PlatformChannelPair channel_pair; 103 embedder::PlatformChannelPair channel_pair;
103 platform_handles_[0] = channel_pair.PassServerHandle(); 104 platform_handles_[0] = channel_pair.PassServerHandle();
104 platform_handles_[1] = channel_pair.PassClientHandle(); 105 platform_handles_[1] = channel_pair.PassClientHandle();
105 } 106 }
106 107
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 165 }
165 166
166 void RestoreInitialStateOnIOThread() { 167 void RestoreInitialStateOnIOThread() {
167 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); 168 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop());
168 169
169 TearDownOnIOThread(); 170 TearDownOnIOThread();
170 SetUpOnIOThread(); 171 SetUpOnIOThread();
171 } 172 }
172 173
173 embedder::SimplePlatformSupport platform_support_; 174 embedder::SimplePlatformSupport platform_support_;
174 test::TestIOThread io_thread_; 175 base::TestIOThread io_thread_;
175 embedder::ScopedPlatformHandle platform_handles_[2]; 176 embedder::ScopedPlatformHandle platform_handles_[2];
176 scoped_refptr<Channel> channels_[2]; 177 scoped_refptr<Channel> channels_[2];
177 178
178 DISALLOW_COPY_AND_ASSIGN(RemoteMessagePipeTest); 179 DISALLOW_COPY_AND_ASSIGN(RemoteMessagePipeTest);
179 }; 180 };
180 181
181 TEST_F(RemoteMessagePipeTest, Basic) { 182 TEST_F(RemoteMessagePipeTest, Basic) {
182 static const char kHello[] = "hello"; 183 static const char kHello[] = "hello";
183 static const char kWorld[] = "world!!!1!!!1!"; 184 static const char kWorld[] = "world!!!1!!!1!";
184 char buffer[100] = {0}; 185 char buffer[100] = {0};
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 935
935 mp1->Close(1); 936 mp1->Close(1);
936 937
937 RestoreInitialState(); 938 RestoreInitialState();
938 } 939 }
939 } 940 }
940 941
941 } // namespace 942 } // namespace
942 } // namespace system 943 } // namespace system
943 } // namespace mojo 944 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/raw_channel_unittest.cc ('k') | mojo/system/test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698