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

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

Issue 484893004: Mojo: Make Core own a PlatformSupport, and plumb it through to Channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « mojo/system/channel.cc ('k') | mojo/system/core.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 "mojo/system/channel.h" 5 #include "mojo/system/channel.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/embedder/platform_channel_pair.h" 10 #include "mojo/embedder/platform_channel_pair.h"
11 #include "mojo/embedder/simple_platform_support.h"
11 #include "mojo/system/local_message_pipe_endpoint.h" 12 #include "mojo/system/local_message_pipe_endpoint.h"
12 #include "mojo/system/message_in_transit.h" 13 #include "mojo/system/message_in_transit.h"
13 #include "mojo/system/message_pipe.h" 14 #include "mojo/system/message_pipe.h"
14 #include "mojo/system/proxy_message_pipe_endpoint.h" 15 #include "mojo/system/proxy_message_pipe_endpoint.h"
15 #include "mojo/system/raw_channel.h" 16 #include "mojo/system/raw_channel.h"
16 #include "mojo/system/test_utils.h" 17 #include "mojo/system/test_utils.h"
17 #include "mojo/system/waiter.h" 18 #include "mojo/system/waiter.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace mojo { 21 namespace mojo {
(...skipping 14 matching lines...) Expand all
35 virtual ~ChannelTest() {} 36 virtual ~ChannelTest() {}
36 37
37 virtual void SetUp() OVERRIDE { 38 virtual void SetUp() OVERRIDE {
38 io_thread_.PostTaskAndWait( 39 io_thread_.PostTaskAndWait(
39 FROM_HERE, 40 FROM_HERE,
40 base::Bind(&ChannelTest::SetUpOnIOThread, base::Unretained(this))); 41 base::Bind(&ChannelTest::SetUpOnIOThread, base::Unretained(this)));
41 } 42 }
42 43
43 void CreateChannelOnIOThread() { 44 void CreateChannelOnIOThread() {
44 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); 45 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop());
45 channel_ = new Channel(); 46 channel_ = new Channel(&platform_support_);
46 } 47 }
47 48
48 void InitChannelOnIOThread() { 49 void InitChannelOnIOThread() {
49 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); 50 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop());
50 51
51 CHECK(raw_channel_); 52 CHECK(raw_channel_);
52 CHECK(channel_); 53 CHECK(channel_);
53 CHECK_EQ(init_result_, TRISTATE_UNKNOWN); 54 CHECK_EQ(init_result_, TRISTATE_UNKNOWN);
54 55
55 init_result_ = BoolToTristate(channel_->Init(raw_channel_.Pass())); 56 init_result_ = BoolToTristate(channel_->Init(raw_channel_.Pass()));
(...skipping 15 matching lines...) Expand all
71 72
72 private: 73 private:
73 void SetUpOnIOThread() { 74 void SetUpOnIOThread() {
74 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop()); 75 CHECK_EQ(base::MessageLoop::current(), io_thread()->message_loop());
75 76
76 embedder::PlatformChannelPair channel_pair; 77 embedder::PlatformChannelPair channel_pair;
77 raw_channel_ = RawChannel::Create(channel_pair.PassServerHandle()).Pass(); 78 raw_channel_ = RawChannel::Create(channel_pair.PassServerHandle()).Pass();
78 other_platform_handle_ = channel_pair.PassClientHandle(); 79 other_platform_handle_ = channel_pair.PassClientHandle();
79 } 80 }
80 81
82 embedder::SimplePlatformSupport platform_support_;
81 test::TestIOThread io_thread_; 83 test::TestIOThread io_thread_;
82 scoped_ptr<RawChannel> raw_channel_; 84 scoped_ptr<RawChannel> raw_channel_;
83 embedder::ScopedPlatformHandle other_platform_handle_; 85 embedder::ScopedPlatformHandle other_platform_handle_;
84 scoped_refptr<Channel> channel_; 86 scoped_refptr<Channel> channel_;
85 87
86 Tristate init_result_; 88 Tristate init_result_;
87 89
88 DISALLOW_COPY_AND_ASSIGN(ChannelTest); 90 DISALLOW_COPY_AND_ASSIGN(ChannelTest);
89 }; 91 };
90 92
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 mp->Close(0); 313 mp->Close(0);
312 314
313 EXPECT_TRUE(channel()->HasOneRef()); 315 EXPECT_TRUE(channel()->HasOneRef());
314 } 316 }
315 317
316 // TODO(vtl): More. ------------------------------------------------------------ 318 // TODO(vtl): More. ------------------------------------------------------------
317 319
318 } // namespace 320 } // namespace
319 } // namespace system 321 } // namespace system
320 } // namespace mojo 322 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/system/channel.cc ('k') | mojo/system/core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698