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

Side by Side Diff: mojo/public/tests/bindings/connector_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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "mojo/public/bindings/lib/bindings_support.h"
9 #include "mojo/public/bindings/lib/connector.h" 8 #include "mojo/public/bindings/lib/connector.h"
10 #include "mojo/public/bindings/lib/message_queue.h" 9 #include "mojo/public/bindings/lib/message_queue.h"
10 #include "mojo/public/environment/environment.h"
11 #include "mojo/public/system/macros.h" 11 #include "mojo/public/system/macros.h"
12 #include "mojo/public/tests/bindings/simple_bindings_support.h" 12 #include "mojo/public/utility/run_loop.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 namespace test { 16 namespace test {
17 17
18 class MessageAccumulator : public MessageReceiver { 18 class MessageAccumulator : public MessageReceiver {
19 public: 19 public:
20 MessageAccumulator() { 20 MessageAccumulator() {
21 } 21 }
22 22
(...skipping 29 matching lines...) Expand all
52 void AllocMessage(const char* text, Message* message) { 52 void AllocMessage(const char* text, Message* message) {
53 size_t payload_size = strlen(text) + 1; // Plus null terminator. 53 size_t payload_size = strlen(text) + 1; // Plus null terminator.
54 size_t num_bytes = sizeof(MessageHeader) + payload_size; 54 size_t num_bytes = sizeof(MessageHeader) + payload_size;
55 message->data = static_cast<MessageData*>(malloc(num_bytes)); 55 message->data = static_cast<MessageData*>(malloc(num_bytes));
56 message->data->header.num_bytes = static_cast<uint32_t>(num_bytes); 56 message->data->header.num_bytes = static_cast<uint32_t>(num_bytes);
57 message->data->header.name = 1; 57 message->data->header.name = 1;
58 memcpy(message->data->payload, text, payload_size); 58 memcpy(message->data->payload, text, payload_size);
59 } 59 }
60 60
61 void PumpMessages() { 61 void PumpMessages() {
62 bindings_support_.Process(); 62 loop_.RunUntilIdle();
63 } 63 }
64 64
65 protected: 65 protected:
66 ScopedMessagePipeHandle handle0_; 66 ScopedMessagePipeHandle handle0_;
67 ScopedMessagePipeHandle handle1_; 67 ScopedMessagePipeHandle handle1_;
68 68
69 private: 69 private:
70 SimpleBindingsSupport bindings_support_; 70 Environment env_;
71 RunLoop loop_;
71 }; 72 };
72 73
73 TEST_F(ConnectorTest, Basic) { 74 TEST_F(ConnectorTest, Basic) {
74 internal::Connector connector0(handle0_.Pass()); 75 internal::Connector connector0(handle0_.Pass());
75 internal::Connector connector1(handle1_.Pass()); 76 internal::Connector connector1(handle1_.Pass());
76 77
77 const char kText[] = "hello world"; 78 const char kText[] = "hello world";
78 79
79 Message message; 80 Message message;
80 AllocMessage(kText, &message); 81 AllocMessage(kText, &message);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 226
226 accumulator.Pop(&message_received); 227 accumulator.Pop(&message_received);
227 228
228 EXPECT_EQ(std::string(kText), 229 EXPECT_EQ(std::string(kText),
229 std::string( 230 std::string(
230 reinterpret_cast<char*>(message_received.data->payload))); 231 reinterpret_cast<char*>(message_received.data->payload)));
231 } 232 }
232 233
233 } // namespace test 234 } // namespace test
234 } // namespace mojo 235 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698