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_url_request_job.h" | 5 #include "content/browser/service_worker/service_worker_url_request_job.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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | 742 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); |
743 request_ = url_request_context_.CreateRequest( | 743 request_ = url_request_context_.CreateRequest( |
744 GURL("http://example.com/foo.html"), net::DEFAULT_PRIORITY, | 744 GURL("http://example.com/foo.html"), net::DEFAULT_PRIORITY, |
745 &url_request_delegate_); | 745 &url_request_delegate_); |
746 request_->set_method("GET"); | 746 request_->set_method("GET"); |
747 request_->Start(); | 747 request_->Start(); |
748 std::string expected_response; | 748 std::string expected_response; |
749 expected_response.reserve((sizeof(kTestData) - 1) * 1024); | 749 expected_response.reserve((sizeof(kTestData) - 1) * 1024); |
750 for (int i = 0; i < 1024; ++i) { | 750 for (int i = 0; i < 1024; ++i) { |
751 expected_response += kTestData; | 751 expected_response += kTestData; |
752 stream->AddData(kTestData, sizeof(kTestData) - 1);; | 752 stream->AddData(kTestData, sizeof(kTestData) - 1); |
753 stream->Flush(); | 753 stream->Flush(); |
754 base::RunLoop().RunUntilIdle(); | 754 base::RunLoop().RunUntilIdle(); |
755 EXPECT_EQ(expected_response, url_request_delegate_.response_data()); | 755 EXPECT_EQ(expected_response, url_request_delegate_.response_data()); |
756 } | 756 } |
757 stream->Finalize(); | 757 stream->Finalize(); |
758 base::RunLoop().RunUntilIdle(); | 758 base::RunLoop().RunUntilIdle(); |
759 EXPECT_TRUE(request_->status().is_success()); | 759 EXPECT_TRUE(request_->status().is_success()); |
760 EXPECT_EQ(200, | 760 EXPECT_EQ(200, |
761 request_->response_headers()->response_code()); | 761 request_->response_headers()->response_code()); |
762 EXPECT_EQ("OK", | 762 EXPECT_EQ("OK", |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 EXPECT_EQ(blink::WebServiceWorkerResponseTypeDefault, | 927 EXPECT_EQ(blink::WebServiceWorkerResponseTypeDefault, |
928 callback_tracker_.response_type_via_service_worker()); | 928 callback_tracker_.response_type_via_service_worker()); |
929 EXPECT_FALSE(callback_tracker_.service_worker_start_time().is_null()); | 929 EXPECT_FALSE(callback_tracker_.service_worker_start_time().is_null()); |
930 EXPECT_FALSE(callback_tracker_.service_worker_ready_time().is_null()); | 930 EXPECT_FALSE(callback_tracker_.service_worker_ready_time().is_null()); |
931 } | 931 } |
932 | 932 |
933 // TODO(kinuko): Add more tests with different response data and also for | 933 // TODO(kinuko): Add more tests with different response data and also for |
934 // FallbackToNetwork case. | 934 // FallbackToNetwork case. |
935 | 935 |
936 } // namespace content | 936 } // namespace content |
OLD | NEW |