OLD | NEW |
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 "content/browser/service_worker/service_worker_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <tuple> |
8 | 9 |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
12 #include "content/browser/service_worker/embedded_worker_registry.h" | 13 #include "content/browser/service_worker/embedded_worker_registry.h" |
13 #include "content/browser/service_worker/embedded_worker_test_helper.h" | 14 #include "content/browser/service_worker/embedded_worker_test_helper.h" |
14 #include "content/browser/service_worker/service_worker_context_core.h" | 15 #include "content/browser/service_worker/service_worker_context_core.h" |
15 #include "content/browser/service_worker/service_worker_registration.h" | 16 #include "content/browser/service_worker/service_worker_registration.h" |
16 #include "content/browser/service_worker/service_worker_test_utils.h" | 17 #include "content/browser/service_worker/service_worker_test_utils.h" |
17 #include "content/common/service_worker/service_worker_utils.h" | 18 #include "content/common/service_worker/service_worker_utils.h" |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 base::Bind(&ReceiveTestEventResult, &received_request_id2, | 1355 base::Bind(&ReceiveTestEventResult, &received_request_id2, |
1355 &received_data2, runner2->QuitClosure())); | 1356 &received_data2, runner2->QuitClosure())); |
1356 | 1357 |
1357 // Make sure events got dispatched in same order. | 1358 // Make sure events got dispatched in same order. |
1358 base::RunLoop().RunUntilIdle(); | 1359 base::RunLoop().RunUntilIdle(); |
1359 ASSERT_EQ(2u, helper_->inner_ipc_sink()->message_count()); | 1360 ASSERT_EQ(2u, helper_->inner_ipc_sink()->message_count()); |
1360 const IPC::Message* msg = helper_->inner_ipc_sink()->GetMessageAt(0); | 1361 const IPC::Message* msg = helper_->inner_ipc_sink()->GetMessageAt(0); |
1361 ASSERT_EQ(TestMsg_TestEvent::ID, msg->type()); | 1362 ASSERT_EQ(TestMsg_TestEvent::ID, msg->type()); |
1362 TestMsg_TestEvent::Param params; | 1363 TestMsg_TestEvent::Param params; |
1363 TestMsg_TestEvent::Read(msg, ¶ms); | 1364 TestMsg_TestEvent::Read(msg, ¶ms); |
1364 EXPECT_EQ(request_id1, base::get<0>(params)); | 1365 EXPECT_EQ(request_id1, std::get<0>(params)); |
1365 msg = helper_->inner_ipc_sink()->GetMessageAt(1); | 1366 msg = helper_->inner_ipc_sink()->GetMessageAt(1); |
1366 ASSERT_EQ(TestMsg_TestEvent::ID, msg->type()); | 1367 ASSERT_EQ(TestMsg_TestEvent::ID, msg->type()); |
1367 TestMsg_TestEvent::Read(msg, ¶ms); | 1368 TestMsg_TestEvent::Read(msg, ¶ms); |
1368 EXPECT_EQ(request_id2, base::get<0>(params)); | 1369 EXPECT_EQ(request_id2, std::get<0>(params)); |
1369 | 1370 |
1370 // Reply to second event. | 1371 // Reply to second event. |
1371 std::string reply2("foobar"); | 1372 std::string reply2("foobar"); |
1372 helper_->SimulateSendEventResult( | 1373 helper_->SimulateSendEventResult( |
1373 version_->embedded_worker()->embedded_worker_id(), request_id2, reply2); | 1374 version_->embedded_worker()->embedded_worker_id(), request_id2, reply2); |
1374 runner2->Run(); | 1375 runner2->Run(); |
1375 | 1376 |
1376 // Verify correct message callback got called with correct reply. | 1377 // Verify correct message callback got called with correct reply. |
1377 EXPECT_EQ(0, received_request_id1); | 1378 EXPECT_EQ(0, received_request_id1); |
1378 EXPECT_EQ(request_id2, received_request_id2); | 1379 EXPECT_EQ(request_id2, received_request_id2); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 helper_->SimulateSendSimpleEventResult( | 1463 helper_->SimulateSendSimpleEventResult( |
1463 version_->embedded_worker()->embedded_worker_id(), request_id, | 1464 version_->embedded_worker()->embedded_worker_id(), request_id, |
1464 blink::WebServiceWorkerEventResultRejected); | 1465 blink::WebServiceWorkerEventResultRejected); |
1465 runner->Run(); | 1466 runner->Run(); |
1466 | 1467 |
1467 // Verify callback was called with correct status. | 1468 // Verify callback was called with correct status. |
1468 EXPECT_EQ(SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED, status); | 1469 EXPECT_EQ(SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED, status); |
1469 } | 1470 } |
1470 | 1471 |
1471 } // namespace content | 1472 } // namespace content |
OLD | NEW |