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

Side by Side Diff: mojo/runner/shell_test_base_unittest.cc

Issue 1543603002: Switch to standard integer types in mojo/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years 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/runner/shell_apptest.cc ('k') | mojo/runner/task_runners.cc » ('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/runner/shell_test_base.h" 5 #include "mojo/runner/shell_test_base.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
9 #include "base/macros.h" 12 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
11 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
12 #include "mojo/public/cpp/bindings/interface_ptr.h" 15 #include "mojo/public/cpp/bindings/interface_ptr.h"
13 #include "mojo/public/cpp/system/core.h" 16 #include "mojo/public/cpp/system/core.h"
14 #include "mojo/services/test_service/test_request_tracker.mojom.h" 17 #include "mojo/services/test_service/test_request_tracker.mojom.h"
15 #include "mojo/services/test_service/test_service.mojom.h" 18 #include "mojo/services/test_service/test_service.mojom.h"
16 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 EXPECT_FALSE(service1.encountered_error()); 183 EXPECT_FALSE(service1.encountered_error());
181 EXPECT_FALSE(service2.encountered_error()); 184 EXPECT_FALSE(service2.encountered_error());
182 } 185 }
183 message_loop()->Run(); 186 message_loop()->Run();
184 } 187 }
185 188
186 // Tests that service A and service B, both in App 1, can talk to each other 189 // Tests that service A and service B, both in App 1, can talk to each other
187 // and parameters are passed around properly. 190 // and parameters are passed around properly.
188 TEST_F(ShellTestBaseTest, ConnectDifferentServicesInSingleApp) { 191 TEST_F(ShellTestBaseTest, ConnectDifferentServicesInSingleApp) {
189 // Have a TestService GetPartyTime on a TestTimeService in the same app. 192 // Have a TestService GetPartyTime on a TestTimeService in the same app.
190 int64 time_message; 193 int64_t time_message;
191 TestServicePtr service; 194 TestServicePtr service;
192 ConnectToService(test_app_url(), &service); 195 ConnectToService(test_app_url(), &service);
193 service->ConnectToAppAndGetTime(test_app_url().spec(), 196 service->ConnectToAppAndGetTime(test_app_url().spec(),
194 SetAndQuit<int64>(&time_message)); 197 SetAndQuit<int64_t>(&time_message));
195 message_loop()->Run(); 198 message_loop()->Run();
196 199
197 // Verify by hitting the TimeService directly. 200 // Verify by hitting the TimeService directly.
198 TestTimeServicePtr time_service; 201 TestTimeServicePtr time_service;
199 ConnectToService(test_app_url(), &time_service); 202 ConnectToService(test_app_url(), &time_service);
200 int64 party_time; 203 int64_t party_time;
201 time_service->GetPartyTime(SetAndQuit<int64>(&party_time)); 204 time_service->GetPartyTime(SetAndQuit<int64_t>(&party_time));
202 message_loop()->Run(); 205 message_loop()->Run();
203 206
204 EXPECT_EQ(time_message, party_time); 207 EXPECT_EQ(time_message, party_time);
205 } 208 }
206 209
207 // Tests that a service A in App 1 can talk to service B in App 2 and 210 // Tests that a service A in App 1 can talk to service B in App 2 and
208 // parameters are passed around properly. 211 // parameters are passed around properly.
209 TEST_F(ShellTestBaseTest, ConnectDifferentServicesInDifferentApps) { 212 TEST_F(ShellTestBaseTest, ConnectDifferentServicesInDifferentApps) {
210 int64 time_message; 213 int64_t time_message;
211 TestServicePtr service; 214 TestServicePtr service;
212 ConnectToService(test_app_url(), &service); 215 ConnectToService(test_app_url(), &service);
213 service->ConnectToAppAndGetTime("mojo:test_request_tracker_app", 216 service->ConnectToAppAndGetTime("mojo:test_request_tracker_app",
214 SetAndQuit<int64>(&time_message)); 217 SetAndQuit<int64_t>(&time_message));
215 message_loop()->Run(); 218 message_loop()->Run();
216 219
217 // Verify by hitting the TimeService in the request tracker app directly. 220 // Verify by hitting the TimeService in the request tracker app directly.
218 TestTimeServicePtr time_service; 221 TestTimeServicePtr time_service;
219 ConnectToService(GURL("mojo:test_request_tracker_app"), &time_service); 222 ConnectToService(GURL("mojo:test_request_tracker_app"), &time_service);
220 int64 party_time; 223 int64_t party_time;
221 time_service->GetPartyTime(SetAndQuit<int64>(&party_time)); 224 time_service->GetPartyTime(SetAndQuit<int64_t>(&party_time));
222 message_loop()->Run(); 225 message_loop()->Run();
223 226
224 EXPECT_EQ(time_message, party_time); 227 EXPECT_EQ(time_message, party_time);
225 } 228 }
226 229
227 // Tests that service A in App 1 can be a client of service B in App 2. 230 // Tests that service A in App 1 can be a client of service B in App 2.
228 TEST_F(ShellTestBaseTest, ConnectServiceAsClientOfSeparateApp) { 231 TEST_F(ShellTestBaseTest, ConnectServiceAsClientOfSeparateApp) {
229 TestServicePtr service; 232 TestServicePtr service;
230 ConnectToService(test_app_url(), &service); 233 ConnectToService(test_app_url(), &service);
231 service->StartTrackingRequests(message_loop()->QuitWhenIdleClosure()); 234 service->StartTrackingRequests(message_loop()->QuitWhenIdleClosure());
(...skipping 21 matching lines...) Expand all
253 TestTimeServicePtr time_service; 256 TestTimeServicePtr time_service;
254 257
255 // Make a request to the TestService and have it contact TimeService in the 258 // Make a request to the TestService and have it contact TimeService in the
256 // tracking app. Do all this with tracking enabled, meaning both services 259 // tracking app. Do all this with tracking enabled, meaning both services
257 // are connected as clients of the TrackedRequestService. 260 // are connected as clients of the TrackedRequestService.
258 ConnectToService(test_app_url(), &service); 261 ConnectToService(test_app_url(), &service);
259 service->StartTrackingRequests(message_loop()->QuitWhenIdleClosure()); 262 service->StartTrackingRequests(message_loop()->QuitWhenIdleClosure());
260 message_loop()->Run(); 263 message_loop()->Run();
261 for (int i = 0; i < 5; i++) 264 for (int i = 0; i < 5; i++)
262 service->Ping(Callback<void()>()); 265 service->Ping(Callback<void()>());
263 int64 time_result; 266 int64_t time_result;
264 service->ConnectToAppAndGetTime("mojo:test_request_tracker_app", 267 service->ConnectToAppAndGetTime("mojo:test_request_tracker_app",
265 SetAndQuit<int64>(&time_result)); 268 SetAndQuit<int64_t>(&time_result));
266 message_loop()->Run(); 269 message_loop()->Run();
267 270
268 // Also make a few requests to the TimeService in the test_app. 271 // Also make a few requests to the TimeService in the test_app.
269 ConnectToService(test_app_url(), &time_service); 272 ConnectToService(test_app_url(), &time_service);
270 time_service->StartTrackingRequests(message_loop()->QuitWhenIdleClosure()); 273 time_service->StartTrackingRequests(message_loop()->QuitWhenIdleClosure());
271 time_service->GetPartyTime(Callback<void(uint64_t)>()); 274 time_service->GetPartyTime(Callback<void(uint64_t)>());
272 message_loop()->Run(); 275 message_loop()->Run();
273 for (int i = 0; i < 18; i++) 276 for (int i = 0; i < 18; i++)
274 time_service->GetPartyTime(Callback<void(uint64_t)>()); 277 time_service->GetPartyTime(Callback<void(uint64_t)>());
275 // Flush the tasks with one more to quit. 278 // Flush the tasks with one more to quit.
276 int64 party_time = 0; 279 int64_t party_time = 0;
277 time_service->GetPartyTime(SetAndQuit<int64>(&party_time)); 280 time_service->GetPartyTime(SetAndQuit<int64_t>(&party_time));
278 message_loop()->Run(); 281 message_loop()->Run();
279 282
280 std::vector<ServiceReport> reports; 283 std::vector<ServiceReport> reports;
281 GetReport(&reports); 284 GetReport(&reports);
282 ASSERT_EQ(3U, reports.size()); 285 ASSERT_EQ(3U, reports.size());
283 EXPECT_EQ(TestService::Name_, reports[0].service_name); 286 EXPECT_EQ(TestService::Name_, reports[0].service_name);
284 EXPECT_EQ(6U, reports[0].total_requests); 287 EXPECT_EQ(6U, reports[0].total_requests);
285 EXPECT_EQ(TestTimeService::Name_, reports[1].service_name); 288 EXPECT_EQ(TestTimeService::Name_, reports[1].service_name);
286 EXPECT_EQ(1U, reports[1].total_requests); 289 EXPECT_EQ(1U, reports[1].total_requests);
287 EXPECT_EQ(TestTimeService::Name_, reports[2].service_name); 290 EXPECT_EQ(TestTimeService::Name_, reports[2].service_name);
288 EXPECT_EQ(20U, reports[2].total_requests); 291 EXPECT_EQ(20U, reports[2].total_requests);
289 } 292 }
290 293
291 } // namespace 294 } // namespace
292 } // namespace test 295 } // namespace test
293 } // namespace runner 296 } // namespace runner
294 } // namespace mojo 297 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/runner/shell_apptest.cc ('k') | mojo/runner/task_runners.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698