OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/test/test_mock_time_task_runner.h" | 7 #include "base/test/test_mock_time_task_runner.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
9 #include "net/base/backoff_entry.h" | 9 #include "net/base/backoff_entry.h" |
10 #include "net/url_request/test_url_fetcher_factory.h" | 10 #include "net/url_request/test_url_fetcher_factory.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 net::TestURLFetcher* GetFetcher() const; | 24 net::TestURLFetcher* GetFetcher() const; |
25 | 25 |
26 // Set the response status and body that will be returned by the URL fetch. | 26 // Set the response status and body that will be returned by the URL fetch. |
27 void SetResponse(net::HttpStatusCode status_code, | 27 void SetResponse(net::HttpStatusCode status_code, |
28 const std::string& response_body); | 28 const std::string& response_body); |
29 | 29 |
30 // Completes the URL fetch. | 30 // Completes the URL fetch. |
31 // It can be overridden by the test class to add additional logic. | 31 // It can be overridden by the test class to add additional logic. |
32 virtual void CompleteFetch(); | 32 virtual void CompleteFetch(); |
33 | 33 |
| 34 // Verifies that the Fetcher's upload_data exactly matches the given |
| 35 // properties. The map will be cleared as a side-effect. Wrap calls to this |
| 36 // with ASSERT_NO_FATAL_FAILURE. |
| 37 void VerifyFetcherUploadData( |
| 38 std::map<std::string, std::string>* expected_pairs); |
| 39 |
34 net::URLRequestContextGetter* url_request_context_getter() const { | 40 net::URLRequestContextGetter* url_request_context_getter() const { |
35 return url_request_context_getter_.get(); | 41 return url_request_context_getter_.get(); |
36 } | 42 } |
37 | 43 |
38 private: | 44 private: |
39 // Fast forward the timer used in the test to retry the request immediately. | 45 // Fast forward the timer used in the test to retry the request immediately. |
40 void FastForwardToTriggerNextRetry(); | 46 void FastForwardToTriggerNextRetry(); |
41 | 47 |
42 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; | 48 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; |
43 base::ThreadTaskRunnerHandle task_runner_handle_; | 49 base::ThreadTaskRunnerHandle task_runner_handle_; |
44 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; | 50 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
45 | 51 |
46 net::TestURLFetcherFactory url_fetcher_factory_; | 52 net::TestURLFetcherFactory url_fetcher_factory_; |
47 | 53 |
48 // Tracks the number of retries so far. | 54 // Tracks the number of retries so far. |
49 int retry_count_; | 55 int retry_count_; |
50 | 56 |
51 DISALLOW_COPY_AND_ASSIGN(GCMRequestTestBase); | 57 DISALLOW_COPY_AND_ASSIGN(GCMRequestTestBase); |
52 }; | 58 }; |
53 | 59 |
54 } // namespace gcm | 60 } // namespace gcm |
OLD | NEW |