OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_GOOGLE_APIS_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_TEST_UTIL_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_TEST_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/template_util.h" | 16 #include "base/template_util.h" |
17 #include "chrome/browser/google_apis/base_operations.h" | 17 #include "chrome/browser/google_apis/base_requests.h" |
18 #include "chrome/browser/google_apis/gdata_errorcode.h" | 18 #include "chrome/browser/google_apis/gdata_errorcode.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class FilePath; | 23 class FilePath; |
24 class Value; | 24 class Value; |
25 } | 25 } |
26 | 26 |
27 namespace net { | 27 namespace net { |
28 namespace test_server { | 28 namespace test_server { |
29 class BasicHttpResponse; | 29 class BasicHttpResponse; |
30 class HttpResponse; | 30 class HttpResponse; |
31 struct HttpRequest; | 31 struct HttpRequest; |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 namespace google_apis { | 35 namespace google_apis { |
36 | 36 |
37 class AboutResource; | 37 class AboutResource; |
38 class AccountMetadata; | 38 class AccountMetadata; |
39 class AppList; | 39 class AppList; |
40 class AuthenticatedOperationInterface; | 40 class AuthenticatedRequestInterface; |
41 class ResourceEntry; | 41 class ResourceEntry; |
42 class ResourceList; | 42 class ResourceList; |
43 struct UploadRangeResponse; | 43 struct UploadRangeResponse; |
44 | 44 |
45 namespace test_util { | 45 namespace test_util { |
46 | 46 |
47 // Runs a task posted to the blocking pool, including subsequent tasks posted | 47 // Runs a task posted to the blocking pool, including subsequent tasks posted |
48 // to the UI message loop and the blocking pool. | 48 // to the UI message loop and the blocking pool. |
49 // | 49 // |
50 // A task is often posted to the blocking pool with PostTaskAndReply(). In | 50 // A task is often posted to the blocking pool with PostTaskAndReply(). In |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path); | 90 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path); |
91 | 91 |
92 // Returns a HttpResponse created from the given file path. | 92 // Returns a HttpResponse created from the given file path. |
93 scoped_ptr<net::test_server::BasicHttpResponse> CreateHttpResponseFromFile( | 93 scoped_ptr<net::test_server::BasicHttpResponse> CreateHttpResponseFromFile( |
94 const base::FilePath& file_path); | 94 const base::FilePath& file_path); |
95 | 95 |
96 // Handles a request for downloading a file. Reads a file from the test | 96 // Handles a request for downloading a file. Reads a file from the test |
97 // directory and returns the content. Also, copies the |request| to the memory | 97 // directory and returns the content. Also, copies the |request| to the memory |
98 // pointed by |out_request|. | 98 // pointed by |out_request|. |
99 // |base_url| must be set to the server's base url. | 99 // |base_url| must be set to the server's base url. |
100 scoped_ptr<net::test_server::HttpResponse> HandleDownloadRequest( | 100 scoped_ptr<net::test_server::HttpResponse> HandleDownloadFileRequest( |
101 const GURL& base_url, | 101 const GURL& base_url, |
102 net::test_server::HttpRequest* out_request, | 102 net::test_server::HttpRequest* out_request, |
103 const net::test_server::HttpRequest& request); | 103 const net::test_server::HttpRequest& request); |
104 | 104 |
105 // Returns true if |json_data| is not NULL and equals to the content in | 105 // Returns true if |json_data| is not NULL and equals to the content in |
106 // |expected_json_file_path|. The failure reason will be logged into LOG(ERROR) | 106 // |expected_json_file_path|. The failure reason will be logged into LOG(ERROR) |
107 // if necessary. | 107 // if necessary. |
108 bool VerifyJsonData(const base::FilePath& expected_json_file_path, | 108 bool VerifyJsonData(const base::FilePath& expected_json_file_path, |
109 const base::Value* json_data); | 109 const base::Value* json_data); |
110 | 110 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 const GetContentCallback callback_; | 306 const GetContentCallback callback_; |
307 ScopedVector<std::string> data_; | 307 ScopedVector<std::string> data_; |
308 | 308 |
309 DISALLOW_COPY_AND_ASSIGN(TestGetContentCallback); | 309 DISALLOW_COPY_AND_ASSIGN(TestGetContentCallback); |
310 }; | 310 }; |
311 | 311 |
312 } // namespace test_util | 312 } // namespace test_util |
313 } // namespace google_apis | 313 } // namespace google_apis |
314 | 314 |
315 #endif // CHROME_BROWSER_GOOGLE_APIS_TEST_UTIL_H_ | 315 #endif // CHROME_BROWSER_GOOGLE_APIS_TEST_UTIL_H_ |
OLD | NEW |