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 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1638 private: | 1638 private: |
1639 base::Optional<bool> next_pause_after_download_; | 1639 base::Optional<bool> next_pause_after_download_; |
1640 int num_of_startworker_ = 0; | 1640 int num_of_startworker_ = 0; |
1641 DISALLOW_COPY_AND_ASSIGN(CheckPauseAfterDownloadEmbeddedWorkerInstanceClient); | 1641 DISALLOW_COPY_AND_ASSIGN(CheckPauseAfterDownloadEmbeddedWorkerInstanceClient); |
1642 }; | 1642 }; |
1643 | 1643 |
1644 TEST_P(ServiceWorkerJobTestP, Update_PauseAfterDownload) { | 1644 TEST_P(ServiceWorkerJobTestP, Update_PauseAfterDownload) { |
1645 UpdateJobTestHelper* update_helper = new UpdateJobTestHelper; | 1645 UpdateJobTestHelper* update_helper = new UpdateJobTestHelper; |
1646 helper_.reset(update_helper); | 1646 helper_.reset(update_helper); |
1647 IPC::TestSink* sink = update_helper->ipc_sink(); | 1647 IPC::TestSink* sink = update_helper->ipc_sink(); |
1648 std::vector<CheckPauseAfterDownloadEmbeddedWorkerInstanceClient*> clients = { | 1648 |
1649 helper_->CreateAndRegisterMockInstanceClient< | 1649 std::vector<CheckPauseAfterDownloadEmbeddedWorkerInstanceClient*> clients; |
1650 CheckPauseAfterDownloadEmbeddedWorkerInstanceClient>( | 1650 if (is_mojo_enabled()) { |
horo
2016/10/20 02:25:50
This change is already in https://codereview.chrom
shimazu
2016/10/20 08:36:34
Done.
| |
1651 helper_->AsWeakPtr()), | 1651 clients.push_back(helper_->CreateAndRegisterMockInstanceClient< |
1652 helper_->CreateAndRegisterMockInstanceClient< | 1652 CheckPauseAfterDownloadEmbeddedWorkerInstanceClient>( |
1653 CheckPauseAfterDownloadEmbeddedWorkerInstanceClient>( | 1653 helper_->AsWeakPtr())); |
1654 helper_->AsWeakPtr())}; | 1654 clients.push_back(helper_->CreateAndRegisterMockInstanceClient< |
1655 CheckPauseAfterDownloadEmbeddedWorkerInstanceClient>( | |
1656 helper_->AsWeakPtr())); | |
1657 } | |
1655 | 1658 |
1656 // The initial version should not pause after download. | 1659 // The initial version should not pause after download. |
1657 clients[0]->set_next_pause_after_download(false); | 1660 if (is_mojo_enabled()) |
1661 clients[0]->set_next_pause_after_download(false); | |
1658 scoped_refptr<ServiceWorkerRegistration> registration = | 1662 scoped_refptr<ServiceWorkerRegistration> registration = |
1659 update_helper->SetupInitialRegistration(kNewVersionOrigin); | 1663 update_helper->SetupInitialRegistration(kNewVersionOrigin); |
1660 if (is_mojo_enabled()) { | 1664 if (is_mojo_enabled()) { |
1661 ASSERT_EQ(1, clients[0]->num_of_startworker()); | 1665 ASSERT_EQ(1, clients[0]->num_of_startworker()); |
1662 } else { | 1666 } else { |
1663 const IPC::Message* start_msg = | 1667 const IPC::Message* start_msg = |
1664 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); | 1668 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); |
1665 ASSERT_TRUE(start_msg); | 1669 ASSERT_TRUE(start_msg); |
1666 EmbeddedWorkerMsg_StartWorker::Param param; | 1670 EmbeddedWorkerMsg_StartWorker::Param param; |
1667 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); | 1671 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); |
1668 const EmbeddedWorkerStartParams& start_params = std::get<0>(param); | 1672 const EmbeddedWorkerStartParams& start_params = std::get<0>(param); |
1669 EXPECT_FALSE(start_params.pause_after_download); | 1673 EXPECT_FALSE(start_params.pause_after_download); |
1670 sink->ClearMessages(); | 1674 sink->ClearMessages(); |
1671 } | 1675 } |
1672 | 1676 |
1673 // The updated version should pause after download. | 1677 // The updated version should pause after download. |
1674 clients[1]->set_next_pause_after_download(true); | 1678 if (is_mojo_enabled()) |
1679 clients[1]->set_next_pause_after_download(true); | |
1675 registration->AddListener(update_helper); | 1680 registration->AddListener(update_helper); |
1676 registration->active_version()->StartUpdate(); | 1681 registration->active_version()->StartUpdate(); |
1677 base::RunLoop().RunUntilIdle(); | 1682 base::RunLoop().RunUntilIdle(); |
1678 if (is_mojo_enabled()) { | 1683 if (is_mojo_enabled()) { |
1679 ASSERT_EQ(1, clients[1]->num_of_startworker()); | 1684 ASSERT_EQ(1, clients[1]->num_of_startworker()); |
1680 } else { | 1685 } else { |
1681 const IPC::Message* start_msg = | 1686 const IPC::Message* start_msg = |
1682 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); | 1687 sink->GetUniqueMessageMatching(EmbeddedWorkerMsg_StartWorker::ID); |
1683 ASSERT_TRUE(start_msg); | 1688 ASSERT_TRUE(start_msg); |
1684 EmbeddedWorkerMsg_StartWorker::Param param; | 1689 EmbeddedWorkerMsg_StartWorker::Param param; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1744 EXPECT_EQ(new_version.get(), registration->active_version()); | 1749 EXPECT_EQ(new_version.get(), registration->active_version()); |
1745 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1750 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
1746 registration->RemoveListener(update_helper); | 1751 registration->RemoveListener(update_helper); |
1747 } | 1752 } |
1748 | 1753 |
1749 INSTANTIATE_TEST_CASE_P(ServiceWorkerJobTest, | 1754 INSTANTIATE_TEST_CASE_P(ServiceWorkerJobTest, |
1750 ServiceWorkerJobTestP, | 1755 ServiceWorkerJobTestP, |
1751 ::testing::Values(false, true)); | 1756 ::testing::Values(false, true)); |
1752 | 1757 |
1753 } // namespace content | 1758 } // namespace content |
OLD | NEW |