OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/service/cloud_print/printer_job_handler.h" |
| 6 |
| 7 #include <memory> |
| 8 |
5 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
6 #include "base/location.h" | 10 #include "base/location.h" |
7 #include "base/md5.h" | 11 #include "base/md5.h" |
8 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
11 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
12 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
13 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
14 #include "chrome/common/cloud_print/cloud_print_constants.h" | 17 #include "chrome/common/cloud_print/cloud_print_constants.h" |
15 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" | 18 #include "chrome/service/cloud_print/cloud_print_service_helpers.h" |
16 #include "chrome/service/cloud_print/cloud_print_token_store.h" | 19 #include "chrome/service/cloud_print/cloud_print_token_store.h" |
17 #include "chrome/service/cloud_print/print_system.h" | 20 #include "chrome/service/cloud_print/print_system.h" |
18 #include "chrome/service/cloud_print/printer_job_handler.h" | |
19 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
20 #include "net/http/http_status_code.h" | 22 #include "net/http/http_status_code.h" |
21 #include "net/url_request/test_url_fetcher_factory.h" | 23 #include "net/url_request/test_url_fetcher_factory.h" |
22 #include "net/url_request/url_request_status.h" | 24 #include "net/url_request/url_request_status.h" |
23 #include "net/url_request/url_request_test_util.h" | 25 #include "net/url_request/url_request_test_util.h" |
24 #include "printing/backend/print_backend.h" | 26 #include "printing/backend/print_backend.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
27 | 29 |
28 using ::testing::AtLeast; | 30 using ::testing::AtLeast; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 ~CloudPrintURLFetcherNoServiceProcessFactory() override {} | 277 ~CloudPrintURLFetcherNoServiceProcessFactory() override {} |
276 }; | 278 }; |
277 | 279 |
278 | 280 |
279 // This class handles the callback from FakeURLFetcher | 281 // This class handles the callback from FakeURLFetcher |
280 // It is a separate class because callback methods must be | 282 // It is a separate class because callback methods must be |
281 // on RefCounted classes | 283 // on RefCounted classes |
282 | 284 |
283 class TestURLFetcherCallback { | 285 class TestURLFetcherCallback { |
284 public: | 286 public: |
285 scoped_ptr<net::FakeURLFetcher> CreateURLFetcher( | 287 std::unique_ptr<net::FakeURLFetcher> CreateURLFetcher( |
286 const GURL& url, | 288 const GURL& url, |
287 net::URLFetcherDelegate* d, | 289 net::URLFetcherDelegate* d, |
288 const std::string& response_data, | 290 const std::string& response_data, |
289 net::HttpStatusCode response_code, | 291 net::HttpStatusCode response_code, |
290 net::URLRequestStatus::Status status) { | 292 net::URLRequestStatus::Status status) { |
291 scoped_ptr<net::FakeURLFetcher> fetcher( | 293 std::unique_ptr<net::FakeURLFetcher> fetcher( |
292 new net::FakeURLFetcher(url, d, response_data, response_code, status)); | 294 new net::FakeURLFetcher(url, d, response_data, response_code, status)); |
293 OnRequestCreate(url, fetcher.get()); | 295 OnRequestCreate(url, fetcher.get()); |
294 return fetcher; | 296 return fetcher; |
295 } | 297 } |
296 MOCK_METHOD2(OnRequestCreate, | 298 MOCK_METHOD2(OnRequestCreate, |
297 void(const GURL&, net::FakeURLFetcher*)); | 299 void(const GURL&, net::FakeURLFetcher*)); |
298 }; | 300 }; |
299 | 301 |
300 | 302 |
301 class MockPrinterJobHandlerDelegate | 303 class MockPrinterJobHandlerDelegate |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 .WillOnce(InvokeWithoutArgs( | 820 .WillOnce(InvokeWithoutArgs( |
819 this, &PrinterJobHandlerTest::MakeJobFetchReturnNoJobs)); | 821 this, &PrinterJobHandlerTest::MakeJobFetchReturnNoJobs)); |
820 | 822 |
821 EXPECT_CALL(url_callback_, OnRequestCreate(TicketURI(1), _)) | 823 EXPECT_CALL(url_callback_, OnRequestCreate(TicketURI(1), _)) |
822 .Times(AtLeast(kNumRetriesBeforeAbandonJob)); | 824 .Times(AtLeast(kNumRetriesBeforeAbandonJob)); |
823 | 825 |
824 BeginTest(70); | 826 BeginTest(70); |
825 } | 827 } |
826 | 828 |
827 } // namespace cloud_print | 829 } // namespace cloud_print |
OLD | NEW |