OLD | NEW |
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 "content/browser/service_worker/embedded_worker_instance.h" | 5 #include "content/browser/service_worker/embedded_worker_instance.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status()); | 512 EXPECT_EQ(EmbeddedWorkerStatus::STOPPED, worker->status()); |
513 EXPECT_EQ(ChildProcessHost::kInvalidUniqueID, worker->process_id()); | 513 EXPECT_EQ(ChildProcessHost::kInvalidUniqueID, worker->process_id()); |
514 | 514 |
515 // The start callback should not be aborted by stop (see a comment on the dtor | 515 // The start callback should not be aborted by stop (see a comment on the dtor |
516 // of EmbeddedWorkerInstance::StartTask). | 516 // of EmbeddedWorkerInstance::StartTask). |
517 EXPECT_EQ(SERVICE_WORKER_ERROR_MAX_VALUE, status); | 517 EXPECT_EQ(SERVICE_WORKER_ERROR_MAX_VALUE, status); |
518 | 518 |
519 // "PROCESS_ALLOCATED" event should not be recorded. | 519 // "PROCESS_ALLOCATED" event should not be recorded. |
520 ASSERT_EQ(1u, events_.size()); | 520 ASSERT_EQ(1u, events_.size()); |
521 EXPECT_EQ(DETACHED, events_[0].type); | 521 EXPECT_EQ(DETACHED, events_[0].type); |
522 if (is_mojo_enabled()) { | 522 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[0].status); |
523 // STOPPING should be recorded here because EmbeddedWorkerInstance must be | |
524 // detached while executing RunUntilIdle. | |
525 EXPECT_EQ(EmbeddedWorkerStatus::STOPPING, events_[0].status); | |
526 } else { | |
527 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[0].status); | |
528 } | |
529 events_.clear(); | 523 events_.clear(); |
530 | 524 |
531 // Restart the worker. | 525 // Restart the worker. |
532 status = SERVICE_WORKER_ERROR_MAX_VALUE; | 526 status = SERVICE_WORKER_ERROR_MAX_VALUE; |
533 std::unique_ptr<base::RunLoop> run_loop(new base::RunLoop); | 527 std::unique_ptr<base::RunLoop> run_loop(new base::RunLoop); |
534 params = CreateStartParams(version_id, scope, url); | 528 params = CreateStartParams(version_id, scope, url); |
535 worker->Start( | 529 worker->Start( |
536 std::move(params), CreateEventDispatcher(), | 530 std::move(params), CreateEventDispatcher(), |
537 base::Bind(&SaveStatusAndCall, &status, run_loop->QuitClosure())); | 531 base::Bind(&SaveStatusAndCall, &status, run_loop->QuitClosure())); |
538 run_loop->Run(); | 532 run_loop->Run(); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); | 769 EXPECT_EQ(START_WORKER_MESSAGE_SENT, events_[1].type); |
776 EXPECT_EQ(DETACHED, events_[2].type); | 770 EXPECT_EQ(DETACHED, events_[2].type); |
777 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); | 771 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, events_[2].status); |
778 } | 772 } |
779 | 773 |
780 INSTANTIATE_TEST_CASE_P(EmbeddedWorkerInstanceTest, | 774 INSTANTIATE_TEST_CASE_P(EmbeddedWorkerInstanceTest, |
781 EmbeddedWorkerInstanceTestP, | 775 EmbeddedWorkerInstanceTestP, |
782 ::testing::Values(false, true)); | 776 ::testing::Values(false, true)); |
783 | 777 |
784 } // namespace content | 778 } // namespace content |
OLD | NEW |