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

Side by Side Diff: mojo/public/tests/bindings/handle_passing_unittest.cc

Issue 134253004: Mojo: AsyncWaiter and mojo/public/environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing files Created 6 years, 11 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
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 #include "mojo/public/bindings/lib/remote_ptr.h" 5 #include "mojo/public/bindings/lib/remote_ptr.h"
6 #include "mojo/public/tests/bindings/simple_bindings_support.h" 6 #include "mojo/public/environment/environment.h"
7 #include "mojo/public/tests/test_support.h" 7 #include "mojo/public/tests/test_support.h"
8 #include "mojo/public/utility/run_loop.h"
8 #include "mojom/sample_factory.h" 9 #include "mojom/sample_factory.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 namespace test { 13 namespace test {
13 namespace { 14 namespace {
14 15
15 const char kText1[] = "hello"; 16 const char kText1[] = "hello";
16 const char kText2[] = "world"; 17 const char kText2[] = "world";
17 18
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 private: 119 private:
119 RemotePtr<sample::Factory> factory_; 120 RemotePtr<sample::Factory> factory_;
120 ScopedMessagePipeHandle pipe1_; 121 ScopedMessagePipeHandle pipe1_;
121 ScopedMessagePipeHandle pipe3_; 122 ScopedMessagePipeHandle pipe3_;
122 std::string expected_text_reply_; 123 std::string expected_text_reply_;
123 bool got_response_; 124 bool got_response_;
124 }; 125 };
125 126
126 } // namespace 127 } // namespace
127 128
128 class BindingsHandlePassingTest : public testing::Test { 129 class HandlePassingTest : public testing::Test {
129 public: 130 public:
130 void PumpMessages() { 131 void PumpMessages() {
131 bindings_support_.Process(); 132 loop_.RunUntilIdle();
132 } 133 }
133 134
134 private: 135 private:
135 SimpleBindingsSupport bindings_support_; 136 Environment env_;
137 RunLoop loop_;
136 }; 138 };
137 139
138 TEST_F(BindingsHandlePassingTest, Basic) { 140 TEST_F(HandlePassingTest, Basic) {
139 ScopedMessagePipeHandle pipe0; 141 ScopedMessagePipeHandle pipe0;
140 ScopedMessagePipeHandle pipe1; 142 ScopedMessagePipeHandle pipe1;
141 CreateMessagePipe(&pipe0, &pipe1); 143 CreateMessagePipe(&pipe0, &pipe1);
142 144
143 SampleFactoryImpl factory(pipe0.Pass()); 145 SampleFactoryImpl factory(pipe0.Pass());
144 SampleFactoryClientImpl factory_client(pipe1.Pass()); 146 SampleFactoryClientImpl factory_client(pipe1.Pass());
145 147
146 factory_client.Start(); 148 factory_client.Start();
147 149
148 EXPECT_FALSE(factory_client.got_response()); 150 EXPECT_FALSE(factory_client.got_response());
149 151
150 PumpMessages(); 152 PumpMessages();
151 153
152 EXPECT_TRUE(factory_client.got_response()); 154 EXPECT_TRUE(factory_client.got_response());
153 } 155 }
154 156
155 TEST_F(BindingsHandlePassingTest, PassInvalid) { 157 TEST_F(HandlePassingTest, PassInvalid) {
156 ScopedMessagePipeHandle pipe0; 158 ScopedMessagePipeHandle pipe0;
157 ScopedMessagePipeHandle pipe1; 159 ScopedMessagePipeHandle pipe1;
158 CreateMessagePipe(&pipe0, &pipe1); 160 CreateMessagePipe(&pipe0, &pipe1);
159 161
160 SampleFactoryImpl factory(pipe0.Pass()); 162 SampleFactoryImpl factory(pipe0.Pass());
161 SampleFactoryClientImpl factory_client(pipe1.Pass()); 163 SampleFactoryClientImpl factory_client(pipe1.Pass());
162 164
163 factory_client.StartNoPipes(); 165 factory_client.StartNoPipes();
164 166
165 EXPECT_FALSE(factory_client.got_response()); 167 EXPECT_FALSE(factory_client.got_response());
166 168
167 PumpMessages(); 169 PumpMessages();
168 170
169 EXPECT_TRUE(factory_client.got_response()); 171 EXPECT_TRUE(factory_client.got_response());
170 } 172 }
171 173
172 } // namespace test 174 } // namespace test
173 } // namespace mojo 175 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698