| 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 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 GURL script_url("http://www.example.com/service_worker.js"); | 636 GURL script_url("http://www.example.com/service_worker.js"); |
| 637 scoped_refptr<ServiceWorkerRegistration> registration = | 637 scoped_refptr<ServiceWorkerRegistration> registration = |
| 638 RunRegisterJob(GURL("http://www.example.com/"), script_url); | 638 RunRegisterJob(GURL("http://www.example.com/"), script_url); |
| 639 ASSERT_TRUE(registration.get()); | 639 ASSERT_TRUE(registration.get()); |
| 640 | 640 |
| 641 // Manually create the waiting worker since there is no way to become a | 641 // Manually create the waiting worker since there is no way to become a |
| 642 // waiting worker until Update is implemented. | 642 // waiting worker until Update is implemented. |
| 643 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( | 643 scoped_refptr<ServiceWorkerVersion> version = new ServiceWorkerVersion( |
| 644 registration.get(), script_url, 1L, helper_->context()->AsWeakPtr()); | 644 registration.get(), script_url, 1L, helper_->context()->AsWeakPtr()); |
| 645 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; | 645 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_FAILED; |
| 646 version->StartWorker(CreateReceiverOnCurrentThread(&status)); | 646 version->StartWorker(ServiceWorkerMetrics::EventType::UNKNOWN, |
| 647 CreateReceiverOnCurrentThread(&status)); |
| 647 base::RunLoop().RunUntilIdle(); | 648 base::RunLoop().RunUntilIdle(); |
| 648 ASSERT_EQ(SERVICE_WORKER_OK, status); | 649 ASSERT_EQ(SERVICE_WORKER_OK, status); |
| 649 | 650 |
| 650 version->SetStatus(ServiceWorkerVersion::INSTALLED); | 651 version->SetStatus(ServiceWorkerVersion::INSTALLED); |
| 651 registration->SetWaitingVersion(version); | 652 registration->SetWaitingVersion(version); |
| 652 EXPECT_EQ(ServiceWorkerVersion::RUNNING, | 653 EXPECT_EQ(ServiceWorkerVersion::RUNNING, |
| 653 version->running_status()); | 654 version->running_status()); |
| 654 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); | 655 EXPECT_EQ(ServiceWorkerVersion::INSTALLED, version->status()); |
| 655 | 656 |
| 656 RunUnregisterJob(GURL("http://www.example.com/")); | 657 RunUnregisterJob(GURL("http://www.example.com/")); |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 | 1414 |
| 1414 void set_install_callback(const base::Closure& callback) { | 1415 void set_install_callback(const base::Closure& callback) { |
| 1415 install_callback_ = callback; | 1416 install_callback_ = callback; |
| 1416 } | 1417 } |
| 1417 void set_install_event_result(blink::WebServiceWorkerEventResult result) { | 1418 void set_install_event_result(blink::WebServiceWorkerEventResult result) { |
| 1418 install_event_result_ = result; | 1419 install_event_result_ = result; |
| 1419 } | 1420 } |
| 1420 void set_activate_event_result(blink::WebServiceWorkerEventResult result) { | 1421 void set_activate_event_result(blink::WebServiceWorkerEventResult result) { |
| 1421 activate_event_result_ = result; | 1422 activate_event_result_ = result; |
| 1422 } | 1423 } |
| 1423 private: | 1424 |
| 1425 private: |
| 1424 base::Closure install_callback_; | 1426 base::Closure install_callback_; |
| 1425 blink::WebServiceWorkerEventResult install_event_result_; | 1427 blink::WebServiceWorkerEventResult install_event_result_; |
| 1426 blink::WebServiceWorkerEventResult activate_event_result_; | 1428 blink::WebServiceWorkerEventResult activate_event_result_; |
| 1427 }; | 1429 }; |
| 1428 | 1430 |
| 1429 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall) { | 1431 TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall) { |
| 1430 EventCallbackHelper* helper = new EventCallbackHelper; | 1432 EventCallbackHelper* helper = new EventCallbackHelper; |
| 1431 helper_.reset(helper); | 1433 helper_.reset(helper); |
| 1432 | 1434 |
| 1433 GURL pattern("http://www.example.com/one/"); | 1435 GURL pattern("http://www.example.com/one/"); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 ASSERT_TRUE(start_msg); | 1569 ASSERT_TRUE(start_msg); |
| 1568 EmbeddedWorkerMsg_StartWorker::Param param; | 1570 EmbeddedWorkerMsg_StartWorker::Param param; |
| 1569 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); | 1571 EmbeddedWorkerMsg_StartWorker::Read(start_msg, ¶m); |
| 1570 EmbeddedWorkerMsg_StartWorker_Params start_params = base::get<0>(param); | 1572 EmbeddedWorkerMsg_StartWorker_Params start_params = base::get<0>(param); |
| 1571 EXPECT_TRUE(start_params.pause_after_download); | 1573 EXPECT_TRUE(start_params.pause_after_download); |
| 1572 sink->ClearMessages(); | 1574 sink->ClearMessages(); |
| 1573 } | 1575 } |
| 1574 } | 1576 } |
| 1575 | 1577 |
| 1576 } // namespace content | 1578 } // namespace content |
| OLD | NEW |