| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/offline_pages/core/prefetch/get_operation_request.h" | 5 #include "components/offline_pages/core/prefetch/get_operation_request.h" |
| 6 | 6 |
| 7 #include "base/test/mock_callback.h" | 7 #include "base/test/mock_callback.h" |
| 8 #include "components/offline_pages/core/prefetch/prefetch_request_test_base.h" | 8 #include "components/offline_pages/core/prefetch/prefetch_request_test_base.h" |
| 9 #include "components/offline_pages/core/prefetch/prefetch_types.h" | 9 #include "components/offline_pages/core/prefetch/prefetch_types.h" |
| 10 #include "components/offline_pages/core/prefetch/proto/offline_pages.pb.h" | 10 #include "components/offline_pages/core/prefetch/proto/offline_pages.pb.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 EXPECT_TRUE(fetcher->upload_content_type().empty()); | 57 EXPECT_TRUE(fetcher->upload_content_type().empty()); |
| 58 EXPECT_TRUE(fetcher->upload_data().empty()); | 58 EXPECT_TRUE(fetcher->upload_data().empty()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 TEST_F(GetOperationRequestTest, EmptyResponse) { | 61 TEST_F(GetOperationRequestTest, EmptyResponse) { |
| 62 base::MockCallback<PrefetchRequestFinishedCallback> callback; | 62 base::MockCallback<PrefetchRequestFinishedCallback> callback; |
| 63 std::unique_ptr<GetOperationRequest> request(CreateRequest(callback.Get())); | 63 std::unique_ptr<GetOperationRequest> request(CreateRequest(callback.Get())); |
| 64 | 64 |
| 65 PrefetchRequestStatus status; | 65 PrefetchRequestStatus status; |
| 66 std::string operation_name; |
| 66 std::vector<RenderPageInfo> pages; | 67 std::vector<RenderPageInfo> pages; |
| 67 EXPECT_CALL(callback, Run(_, _)) | 68 EXPECT_CALL(callback, Run(_, _, _)) |
| 68 .WillOnce(DoAll(SaveArg<0>(&status), SaveArg<1>(&pages))); | 69 .WillOnce(DoAll(SaveArg<0>(&status), SaveArg<1>(&operation_name), |
| 70 SaveArg<2>(&pages))); |
| 69 RespondWithData(""); | 71 RespondWithData(""); |
| 70 | 72 |
| 71 EXPECT_EQ(PrefetchRequestStatus::SHOULD_RETRY_WITH_BACKOFF, status); | 73 EXPECT_EQ(PrefetchRequestStatus::SHOULD_RETRY_WITH_BACKOFF, status); |
| 74 EXPECT_TRUE(operation_name.empty()); |
| 72 EXPECT_TRUE(pages.empty()); | 75 EXPECT_TRUE(pages.empty()); |
| 73 } | 76 } |
| 74 | 77 |
| 75 TEST_F(GetOperationRequestTest, InvalidResponse) { | 78 TEST_F(GetOperationRequestTest, InvalidResponse) { |
| 76 base::MockCallback<PrefetchRequestFinishedCallback> callback; | 79 base::MockCallback<PrefetchRequestFinishedCallback> callback; |
| 77 std::unique_ptr<GetOperationRequest> request(CreateRequest(callback.Get())); | 80 std::unique_ptr<GetOperationRequest> request(CreateRequest(callback.Get())); |
| 78 | 81 |
| 79 PrefetchRequestStatus status; | 82 PrefetchRequestStatus status; |
| 83 std::string operation_name; |
| 80 std::vector<RenderPageInfo> pages; | 84 std::vector<RenderPageInfo> pages; |
| 81 EXPECT_CALL(callback, Run(_, _)) | 85 EXPECT_CALL(callback, Run(_, _, _)) |
| 82 .WillOnce(DoAll(SaveArg<0>(&status), SaveArg<1>(&pages))); | 86 .WillOnce(DoAll(SaveArg<0>(&status), SaveArg<1>(&operation_name), |
| 87 SaveArg<2>(&pages))); |
| 83 RespondWithData("Some invalid data"); | 88 RespondWithData("Some invalid data"); |
| 84 | 89 |
| 85 EXPECT_EQ(PrefetchRequestStatus::SHOULD_RETRY_WITH_BACKOFF, status); | 90 EXPECT_EQ(PrefetchRequestStatus::SHOULD_RETRY_WITH_BACKOFF, status); |
| 91 EXPECT_TRUE(operation_name.empty()); |
| 86 EXPECT_TRUE(pages.empty()); | 92 EXPECT_TRUE(pages.empty()); |
| 87 } | 93 } |
| 88 | 94 |
| 89 } // namespace offline_pages | 95 } // namespace offline_pages |
| OLD | NEW |