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

Side by Side Diff: mojo/public/tests/bindings_connector_unittest.cc

Issue 70273009: Mojo: Add a MOJO_ARRAYSIZE, corresponding to Chromium's arraysize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/public/system/macros.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 8 #include "mojo/public/bindings/lib/bindings_support.h"
9 #include "mojo/public/bindings/lib/connector.h" 9 #include "mojo/public/bindings/lib/connector.h"
10 #include "mojo/public/bindings/lib/message_queue.h" 10 #include "mojo/public/bindings/lib/message_queue.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 std::string( 125 std::string(
126 reinterpret_cast<char*>(message_received.data->payload))); 126 reinterpret_cast<char*>(message_received.data->payload)));
127 } 127 }
128 128
129 TEST_F(BindingsConnectorTest, Basic_TwoMessages) { 129 TEST_F(BindingsConnectorTest, Basic_TwoMessages) {
130 Connector connector0(handle0_); 130 Connector connector0(handle0_);
131 Connector connector1(handle1_); 131 Connector connector1(handle1_);
132 132
133 const char* kText[] = { "hello", "world" }; 133 const char* kText[] = { "hello", "world" };
134 134
135 for (size_t i = 0; i < sizeof(kText) / sizeof(kText[0]); ++i) { 135 for (size_t i = 0; i < MOJO_ARRAYSIZE(kText); ++i) {
136 Message message; 136 Message message;
137 AllocMessage(kText[i], &message); 137 AllocMessage(kText[i], &message);
138 138
139 connector0.Accept(&message); 139 connector0.Accept(&message);
140 } 140 }
141 141
142 MessageAccumulator accumulator; 142 MessageAccumulator accumulator;
143 connector1.SetIncomingReceiver(&accumulator); 143 connector1.SetIncomingReceiver(&accumulator);
144 144
145 PumpMessages(); 145 PumpMessages();
146 146
147 for (size_t i = 0; i < sizeof(kText) / sizeof(kText[0]); ++i) { 147 for (size_t i = 0; i < MOJO_ARRAYSIZE(kText); ++i) {
148 ASSERT_FALSE(accumulator.IsEmpty()); 148 ASSERT_FALSE(accumulator.IsEmpty());
149 149
150 Message message_received; 150 Message message_received;
151 accumulator.Pop(&message_received); 151 accumulator.Pop(&message_received);
152 152
153 EXPECT_EQ(std::string(kText[i]), 153 EXPECT_EQ(std::string(kText[i]),
154 std::string( 154 std::string(
155 reinterpret_cast<char*>(message_received.data->payload))); 155 reinterpret_cast<char*>(message_received.data->payload)));
156 } 156 }
157 } 157 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 std::string( 208 std::string(
209 reinterpret_cast<char*>(message_received.data->payload))); 209 reinterpret_cast<char*>(message_received.data->payload)));
210 ASSERT_EQ(2U, message_received.handles.size()); 210 ASSERT_EQ(2U, message_received.handles.size());
211 EXPECT_EQ(handles[0].value, message_received.handles[0].value); 211 EXPECT_EQ(handles[0].value, message_received.handles[0].value);
212 EXPECT_EQ(handles[1].value, message_received.handles[1].value); 212 EXPECT_EQ(handles[1].value, message_received.handles[1].value);
213 } 213 }
214 #endif 214 #endif
215 215
216 } // namespace test 216 } // namespace test
217 } // namespace mojo 217 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/system/macros.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698