| 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 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/google_apis/gdata_errorcode.h" | 11 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 | 13 |
| 14 namespace base { |
| 14 class FilePath; | 15 class FilePath; |
| 15 | |
| 16 namespace base { | |
| 17 class Value; | 16 class Value; |
| 18 } | 17 } |
| 19 | 18 |
| 20 namespace google_apis { | 19 namespace google_apis { |
| 21 | 20 |
| 22 class AppList; | 21 class AppList; |
| 23 class AccountMetadataFeed; | 22 class AccountMetadataFeed; |
| 24 class AuthenticatedOperationInterface; | 23 class AuthenticatedOperationInterface; |
| 25 class ResourceEntry; | 24 class ResourceEntry; |
| 26 class ResourceList; | 25 class ResourceList; |
| 27 | 26 |
| 28 namespace test_server { | 27 namespace test_server { |
| 29 class HttpResponse; | 28 class HttpResponse; |
| 30 } | 29 } |
| 31 | 30 |
| 32 namespace test_util { | 31 namespace test_util { |
| 33 | 32 |
| 34 // Runs a task posted to the blocking pool, including subsequent tasks posted | 33 // Runs a task posted to the blocking pool, including subsequent tasks posted |
| 35 // to the UI message loop and the blocking pool. | 34 // to the UI message loop and the blocking pool. |
| 36 // | 35 // |
| 37 // A task is often posted to the blocking pool with PostTaskAndReply(). In | 36 // A task is often posted to the blocking pool with PostTaskAndReply(). In |
| 38 // that case, a task is posted back to the UI message loop, which can again | 37 // that case, a task is posted back to the UI message loop, which can again |
| 39 // post a task to the blocking pool. This function processes these tasks | 38 // post a task to the blocking pool. This function processes these tasks |
| 40 // repeatedly. | 39 // repeatedly. |
| 41 void RunBlockingPoolTask(); | 40 void RunBlockingPoolTask(); |
| 42 | 41 |
| 43 // Returns the absolute path for a test file stored under | 42 // Returns the absolute path for a test file stored under |
| 44 // chrome/test/data/chromeos. | 43 // chrome/test/data/chromeos. |
| 45 FilePath GetTestFilePath(const std::string& relative_path); | 44 base::FilePath GetTestFilePath(const std::string& relative_path); |
| 46 | 45 |
| 47 // Returns the base URL for communicating with the local test server for | 46 // Returns the base URL for communicating with the local test server for |
| 48 // testing, running at the specified port number. | 47 // testing, running at the specified port number. |
| 49 GURL GetBaseUrlForTesting(int port); | 48 GURL GetBaseUrlForTesting(int port); |
| 50 | 49 |
| 51 // Loads a test JSON file as a base::Value, from a test file stored under | 50 // Loads a test JSON file as a base::Value, from a test file stored under |
| 52 // chrome/test/data/chromeos. | 51 // chrome/test/data/chromeos. |
| 53 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path); | 52 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path); |
| 54 | 53 |
| 55 // Copies the results from EntryActionCallback. | 54 // Copies the results from EntryActionCallback. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Copies the results from GetAppListCallback. | 95 // Copies the results from GetAppListCallback. |
| 97 void CopyResultsFromGetAppListCallback( | 96 void CopyResultsFromGetAppListCallback( |
| 98 GDataErrorCode* error_out, | 97 GDataErrorCode* error_out, |
| 99 scoped_ptr<AppList>* app_list_out, | 98 scoped_ptr<AppList>* app_list_out, |
| 100 GDataErrorCode error_in, | 99 GDataErrorCode error_in, |
| 101 scoped_ptr<AppList> app_list_in); | 100 scoped_ptr<AppList> app_list_in); |
| 102 | 101 |
| 103 // Copies the results from DownloadActionCallback. | 102 // Copies the results from DownloadActionCallback. |
| 104 void CopyResultsFromDownloadActionCallback( | 103 void CopyResultsFromDownloadActionCallback( |
| 105 GDataErrorCode* error_out, | 104 GDataErrorCode* error_out, |
| 106 FilePath* temp_file_out, | 105 base::FilePath* temp_file_out, |
| 107 GDataErrorCode error_in, | 106 GDataErrorCode error_in, |
| 108 const FilePath& temp_file_in); | 107 const base::FilePath& temp_file_in); |
| 109 | 108 |
| 110 // Returns a HttpResponse created from the given file path. | 109 // Returns a HttpResponse created from the given file path. |
| 111 scoped_ptr<test_server::HttpResponse> CreateHttpResponseFromFile( | 110 scoped_ptr<test_server::HttpResponse> CreateHttpResponseFromFile( |
| 112 const FilePath& file_path); | 111 const base::FilePath& file_path); |
| 113 | 112 |
| 114 // Does nothing for ReAuthenticateCallback(). This function should be used | 113 // Does nothing for ReAuthenticateCallback(). This function should be used |
| 115 // if it is not expected to reach this method as there won't be any | 114 // if it is not expected to reach this method as there won't be any |
| 116 // authentication failures in the test. | 115 // authentication failures in the test. |
| 117 void DoNothingForReAuthenticateCallback( | 116 void DoNothingForReAuthenticateCallback( |
| 118 AuthenticatedOperationInterface* operation); | 117 AuthenticatedOperationInterface* operation); |
| 119 | 118 |
| 120 // Returns true if |json_data| is not NULL and equals to the content in | 119 // Returns true if |json_data| is not NULL and equals to the content in |
| 121 // |expected_json_file_path|. The failure reason will be logged into LOG(ERROR) | 120 // |expected_json_file_path|. The failure reason will be logged into LOG(ERROR) |
| 122 // if necessary. | 121 // if necessary. |
| 123 bool VerifyJsonData(const FilePath& expected_json_file_path, | 122 bool VerifyJsonData(const base::FilePath& expected_json_file_path, |
| 124 const base::Value* json_data); | 123 const base::Value* json_data); |
| 125 | 124 |
| 126 } // namespace test_util | 125 } // namespace test_util |
| 127 } // namespace google_apis | 126 } // namespace google_apis |
| 128 | 127 |
| 129 #endif // CHROME_BROWSER_GOOGLE_APIS_TEST_UTIL_H_ | 128 #endif // CHROME_BROWSER_GOOGLE_APIS_TEST_UTIL_H_ |
| OLD | NEW |