OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ |
6 #define CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ | 6 #define CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/policy/logging_work_scheduler.h" | 13 #include "chrome/browser/policy/logging_work_scheduler.h" |
14 #include "content/common/url_fetcher.h" | 14 #include "content/common/url_fetcher.h" |
| 15 #include "content/test/test_url_fetcher_factory.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 | 18 |
18 namespace policy { | 19 namespace policy { |
19 | 20 |
20 class TestingPolicyURLFetcher; | 21 class TestingPolicyURLFetcher; |
21 | 22 |
22 struct TestURLResponse { | 23 struct TestURLResponse { |
23 std::string response_data; | 24 std::string response_data; |
24 int response_code; | 25 int response_code; |
25 }; | 26 }; |
26 | 27 |
27 // Creates mock URLFetchers whose behavior can be controlled in tests. To do so | 28 // Creates mock URLFetchers whose behavior can be controlled in tests. To do so |
28 // specify this factory with URLFetcher::set_factory, and set mock expectations | 29 // set mock expectations on the method |Intercept|. |
29 // on the method |Intercept|. | 30 class TestingPolicyURLFetcherFactory : public URLFetcher::Factory, |
30 class TestingPolicyURLFetcherFactory : public URLFetcher::Factory { | 31 public ScopedURLFetcherFactory { |
31 public: | 32 public: |
32 explicit TestingPolicyURLFetcherFactory(EventLogger* logger); | 33 explicit TestingPolicyURLFetcherFactory(EventLogger* logger); |
33 virtual ~TestingPolicyURLFetcherFactory(); | 34 virtual ~TestingPolicyURLFetcherFactory(); |
34 | 35 |
35 virtual URLFetcher* CreateURLFetcher( | 36 virtual URLFetcher* CreateURLFetcher( |
36 int id, | 37 int id, |
37 const GURL& url, | 38 const GURL& url, |
38 URLFetcher::RequestType request_type, | 39 URLFetcher::RequestType request_type, |
39 URLFetcher::Delegate* delegate); | 40 URLFetcher::Delegate* delegate); |
40 | 41 |
(...skipping 16 matching lines...) Expand all Loading... |
57 scoped_ptr<LoggingWorkScheduler> scheduler_; | 58 scoped_ptr<LoggingWorkScheduler> scheduler_; |
58 | 59 |
59 base::WeakPtrFactory<TestingPolicyURLFetcherFactory> weak_ptr_factory_; | 60 base::WeakPtrFactory<TestingPolicyURLFetcherFactory> weak_ptr_factory_; |
60 | 61 |
61 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcherFactory); | 62 DISALLOW_COPY_AND_ASSIGN(TestingPolicyURLFetcherFactory); |
62 }; | 63 }; |
63 | 64 |
64 } // namespace policy | 65 } // namespace policy |
65 | 66 |
66 #endif // CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ | 67 #endif // CHROME_BROWSER_POLICY_TESTING_POLICY_URL_FETCHER_FACTORY_H_ |
OLD | NEW |