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_requests.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 #include "chrome/browser/google_apis/task_util.h" |
19 | 20 |
20 class GURL; | 21 class GURL; |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class FilePath; | 24 class FilePath; |
| 25 class RunLoop; |
24 class Value; | 26 class Value; |
25 } | 27 } |
26 | 28 |
27 namespace net { | 29 namespace net { |
28 namespace test_server { | 30 namespace test_server { |
29 class BasicHttpResponse; | 31 class BasicHttpResponse; |
30 class HttpResponse; | 32 class HttpResponse; |
31 struct HttpRequest; | 33 struct HttpRequest; |
32 } | 34 } |
33 } | 35 } |
34 | 36 |
35 namespace google_apis { | 37 namespace google_apis { |
36 | |
37 class AboutResource; | |
38 class AccountMetadata; | |
39 class AppList; | |
40 class AuthenticatedRequestInterface; | |
41 class ResourceEntry; | |
42 class ResourceList; | |
43 struct UploadRangeResponse; | |
44 | |
45 namespace test_util { | 38 namespace test_util { |
46 | 39 |
47 // Runs a task posted to the blocking pool, including subsequent tasks posted | 40 // Runs a task posted to the blocking pool, including subsequent tasks posted |
48 // to the UI message loop and the blocking pool. | 41 // to the UI message loop and the blocking pool. |
49 // | 42 // |
50 // A task is often posted to the blocking pool with PostTaskAndReply(). In | 43 // A task is often posted to the blocking pool with PostTaskAndReply(). In |
51 // that case, a task is posted back to the UI message loop, which can again | 44 // that case, a task is posted back to the UI message loop, which can again |
52 // post a task to the blocking pool. This function processes these tasks | 45 // post a task to the blocking pool. This function processes these tasks |
53 // repeatedly. | 46 // repeatedly. |
54 void RunBlockingPoolTask(); | 47 void RunBlockingPoolTask(); |
55 | 48 |
56 // Runs the closure, and then quits the current MessageLoop. | 49 // Runs the closure, and then quits the |run_loop|. |
57 void RunAndQuit(const base::Closure& closure); | 50 void RunAndQuit(base::RunLoop* run_loop, const base::Closure& closure); |
| 51 |
| 52 // Returns callback which runs the given |callback| and then quits |run_loop|. |
| 53 template<typename CallbackType> |
| 54 CallbackType CreateQuitCallback(base::RunLoop* run_loop, |
| 55 const CallbackType& callback) { |
| 56 return CreateComposedCallback(base::Bind(&RunAndQuit, run_loop), callback); |
| 57 } |
58 | 58 |
59 // Removes |prefix| from |input| and stores the result in |output|. Returns | 59 // Removes |prefix| from |input| and stores the result in |output|. Returns |
60 // true if the prefix is removed. | 60 // true if the prefix is removed. |
61 bool RemovePrefix(const std::string& input, | 61 bool RemovePrefix(const std::string& input, |
62 const std::string& prefix, | 62 const std::string& prefix, |
63 std::string* output); | 63 std::string* output); |
64 | 64 |
65 // Returns the absolute path for a test file stored under | 65 // Returns the absolute path for a test file stored under |
66 // chrome/test/data. | 66 // chrome/test/data. |
67 base::FilePath GetTestFilePath(const std::string& relative_path); | 67 base::FilePath GetTestFilePath(const std::string& relative_path); |
(...skipping 238 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 |