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 <stdint.h> | 5 #include <stdint.h> |
6 #include <tuple> | 6 #include <tuple> |
7 | 7 |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1615 | 1615 |
1616 // The initial version should not pause after download. | 1616 // The initial version should not pause after download. |
1617 scoped_refptr<ServiceWorkerRegistration> registration = | 1617 scoped_refptr<ServiceWorkerRegistration> registration = |
1618 update_helper->SetupInitialRegistration(kNewVersionOrigin); | 1618 update_helper->SetupInitialRegistration(kNewVersionOrigin); |
1619 { | 1619 { |
1620 const IPC::Message* start_msg = | 1620 const IPC::Message* start_msg = |
1621 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); | 1621 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); |
1622 ASSERT_TRUE(start_msg); | 1622 ASSERT_TRUE(start_msg); |
1623 EmbeddedWorkerMsg_StartWorker::Param param; | 1623 EmbeddedWorkerMsg_StartWorker::Param param; |
1624 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); | 1624 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); |
1625 EmbeddedWorkerMsg_StartWorker_Params start_params = std::get<0>(param); | 1625 const EmbeddedWorkerStartParams& start_params = std::get<0>(param); |
1626 EXPECT_FALSE(start_params.pause_after_download); | 1626 EXPECT_FALSE(start_params.pause_after_download); |
1627 sink->ClearMessages(); | 1627 sink->ClearMessages(); |
1628 } | 1628 } |
1629 | 1629 |
1630 // The updated version should pause after download. | 1630 // The updated version should pause after download. |
1631 registration->AddListener(update_helper); | 1631 registration->AddListener(update_helper); |
1632 registration->active_version()->StartUpdate(); | 1632 registration->active_version()->StartUpdate(); |
1633 base::RunLoop().RunUntilIdle(); | 1633 base::RunLoop().RunUntilIdle(); |
1634 { | 1634 { |
1635 const IPC::Message* start_msg = | 1635 const IPC::Message* start_msg = |
1636 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); | 1636 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); |
1637 ASSERT_TRUE(start_msg); | 1637 ASSERT_TRUE(start_msg); |
1638 EmbeddedWorkerMsg_StartWorker::Param param; | 1638 EmbeddedWorkerMsg_StartWorker::Param param; |
1639 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); | 1639 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); |
1640 EmbeddedWorkerMsg_StartWorker_Params start_params = std::get<0>(param); | 1640 const EmbeddedWorkerStartParams& start_params = std::get<0>(param); |
1641 EXPECT_TRUE(start_params.pause_after_download); | 1641 EXPECT_TRUE(start_params.pause_after_download); |
1642 sink->ClearMessages(); | 1642 sink->ClearMessages(); |
1643 } | 1643 } |
1644 } | 1644 } |
1645 | 1645 |
1646 // Test that activation doesn't complete if it's triggered by removing a | 1646 // Test that activation doesn't complete if it's triggered by removing a |
1647 // controllee and starting the worker failed due to shutdown. | 1647 // controllee and starting the worker failed due to shutdown. |
1648 TEST_F(ServiceWorkerJobTest, ActivateCancelsOnShutdown) { | 1648 TEST_F(ServiceWorkerJobTest, ActivateCancelsOnShutdown) { |
1649 UpdateJobTestHelper* update_helper = new UpdateJobTestHelper; | 1649 UpdateJobTestHelper* update_helper = new UpdateJobTestHelper; |
1650 helper_.reset(update_helper); | 1650 helper_.reset(update_helper); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 // should not be promoted to ACTIVATED because failure occur | 1694 // should not be promoted to ACTIVATED because failure occur |
1695 // during shutdown. | 1695 // during shutdown. |
1696 runner->RunUntilIdle(); | 1696 runner->RunUntilIdle(); |
1697 base::RunLoop().RunUntilIdle(); | 1697 base::RunLoop().RunUntilIdle(); |
1698 EXPECT_EQ(new_version.get(), registration->active_version()); | 1698 EXPECT_EQ(new_version.get(), registration->active_version()); |
1699 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1699 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
1700 registration->RemoveListener(update_helper); | 1700 registration->RemoveListener(update_helper); |
1701 } | 1701 } |
1702 | 1702 |
1703 } // namespace content | 1703 } // namespace content |
OLD | NEW |