| 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_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 9 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
| 10 #include "chrome/browser/google_apis/gdata_errorcode.h" | 10 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 11 #include "chrome/browser/google_apis/test_util.h" | 11 #include "chrome/browser/google_apis/test_util.h" |
| 12 | 12 |
| 13 namespace base { |
| 13 class FilePath; | 14 class FilePath; |
| 14 | |
| 15 namespace base { | |
| 16 class Value; | 15 class Value; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace drive { | 18 namespace drive { |
| 20 | 19 |
| 21 class DriveCacheEntry; | 20 class DriveCacheEntry; |
| 22 class DriveEntryProto; | 21 class DriveEntryProto; |
| 23 class DriveFeedLoader; | 22 class DriveFeedLoader; |
| 24 | 23 |
| 25 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; | 24 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 44 bool CacheStatesEqual(const DriveCacheEntry& a, const DriveCacheEntry& b); | 43 bool CacheStatesEqual(const DriveCacheEntry& a, const DriveCacheEntry& b); |
| 45 | 44 |
| 46 // Copies |error| to |output|. Used to run asynchronous functions that take | 45 // Copies |error| to |output|. Used to run asynchronous functions that take |
| 47 // FileOperationCallback from tests. | 46 // FileOperationCallback from tests. |
| 48 void CopyErrorCodeFromFileOperationCallback(DriveFileError* output, | 47 void CopyErrorCodeFromFileOperationCallback(DriveFileError* output, |
| 49 DriveFileError error); | 48 DriveFileError error); |
| 50 | 49 |
| 51 // Copies |error| and |moved_file_path| to |out_error| and |out_file_path|. | 50 // Copies |error| and |moved_file_path| to |out_error| and |out_file_path|. |
| 52 // Used to run asynchronous functions that take FileMoveCallback from tests. | 51 // Used to run asynchronous functions that take FileMoveCallback from tests. |
| 53 void CopyResultsFromFileMoveCallback(DriveFileError* out_error, | 52 void CopyResultsFromFileMoveCallback(DriveFileError* out_error, |
| 54 FilePath* out_file_path, | 53 base::FilePath* out_file_path, |
| 55 DriveFileError error, | 54 DriveFileError error, |
| 56 const FilePath& moved_file_path); | 55 const base::FilePath& moved_file_path); |
| 57 | 56 |
| 58 // Copies |error| and |entry_proto| to |out_error| and |out_entry_proto| | 57 // Copies |error| and |entry_proto| to |out_error| and |out_entry_proto| |
| 59 // respectively. Used to run asynchronous functions that take | 58 // respectively. Used to run asynchronous functions that take |
| 60 // GetEntryInfoCallback from tests. | 59 // GetEntryInfoCallback from tests. |
| 61 void CopyResultsFromGetEntryInfoCallback( | 60 void CopyResultsFromGetEntryInfoCallback( |
| 62 DriveFileError* out_error, | 61 DriveFileError* out_error, |
| 63 scoped_ptr<DriveEntryProto>* out_entry_proto, | 62 scoped_ptr<DriveEntryProto>* out_entry_proto, |
| 64 DriveFileError error, | 63 DriveFileError error, |
| 65 scoped_ptr<DriveEntryProto> entry_proto); | 64 scoped_ptr<DriveEntryProto> entry_proto); |
| 66 | 65 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 // ReadDirectoryCallback from tests. | 77 // ReadDirectoryCallback from tests. |
| 79 void CopyResultsFromReadDirectoryByPathCallback( | 78 void CopyResultsFromReadDirectoryByPathCallback( |
| 80 DriveFileError* out_error, | 79 DriveFileError* out_error, |
| 81 scoped_ptr<DriveEntryProtoVector>* out_entries, | 80 scoped_ptr<DriveEntryProtoVector>* out_entries, |
| 82 DriveFileError error, | 81 DriveFileError error, |
| 83 bool /* hide_hosted_documents */, | 82 bool /* hide_hosted_documents */, |
| 84 scoped_ptr<DriveEntryProtoVector> entries); | 83 scoped_ptr<DriveEntryProtoVector> entries); |
| 85 | 84 |
| 86 // Copies |error|, |drive_file_path|, and |entry_proto| to |out_error|, | 85 // Copies |error|, |drive_file_path|, and |entry_proto| to |out_error|, |
| 87 // |out_drive_file_path|, and |out_entry_proto| respectively. Used to run | 86 // |out_drive_file_path|, and |out_entry_proto| respectively. Used to run |
| 88 // asynchronous functions that take GetEntryInfoWithFilePathCallback from | 87 // asynchronous functions that take GetEntryInfoWithbase::FilePathCallback from |
| 89 // tests. | 88 // tests. |
| 90 void CopyResultsFromGetEntryInfoWithFilePathCallback( | 89 void CopyResultsFromGetEntryInfoWithFilePathCallback( |
| 91 DriveFileError* out_error, | 90 DriveFileError* out_error, |
| 92 FilePath* out_drive_file_path, | 91 base::FilePath* out_drive_file_path, |
| 93 scoped_ptr<DriveEntryProto>* out_entry_proto, | 92 scoped_ptr<DriveEntryProto>* out_entry_proto, |
| 94 DriveFileError error, | 93 DriveFileError error, |
| 95 const FilePath& drive_file_path, | 94 const base::FilePath& drive_file_path, |
| 96 scoped_ptr<DriveEntryProto> entry_proto); | 95 scoped_ptr<DriveEntryProto> entry_proto); |
| 97 | 96 |
| 98 // Copies |result| to |out_result|. Used to run asynchronous functions | 97 // Copies |result| to |out_result|. Used to run asynchronous functions |
| 99 // that take GetEntryInfoPairCallback from tests. | 98 // that take GetEntryInfoPairCallback from tests. |
| 100 void CopyResultsFromGetEntryInfoPairCallback( | 99 void CopyResultsFromGetEntryInfoPairCallback( |
| 101 scoped_ptr<EntryInfoPairResult>* out_result, | 100 scoped_ptr<EntryInfoPairResult>* out_result, |
| 102 scoped_ptr<EntryInfoPairResult> result); | 101 scoped_ptr<EntryInfoPairResult> result); |
| 103 | 102 |
| 104 // Copies |success| to |out_success|. Used to run asynchronous functions that | 103 // Copies |success| to |out_success|. Used to run asynchronous functions that |
| 105 // take InitializeCacheCallback from tests. | 104 // take InitializeCacheCallback from tests. |
| 106 void CopyResultFromInitializeCacheCallback(bool* out_success, | 105 void CopyResultFromInitializeCacheCallback(bool* out_success, |
| 107 bool success); | 106 bool success); |
| 108 | 107 |
| 109 // Copies results from DriveCache methods. Used to run asynchronous functions | 108 // Copies results from DriveCache methods. Used to run asynchronous functions |
| 110 // that take GetFileFromCacheCallback from tests. | 109 // that take GetFileFromCacheCallback from tests. |
| 111 void CopyResultsFromGetFileFromCacheCallback(DriveFileError* out_error, | 110 void CopyResultsFromGetFileFromCacheCallback( |
| 112 FilePath* out_cache_file_path, | 111 DriveFileError* out_error, |
| 113 DriveFileError error, | 112 base::FilePath* out_cache_file_path, |
| 114 const FilePath& cache_file_path); | 113 DriveFileError error, |
| 114 const base::FilePath& cache_file_path); |
| 115 | 115 |
| 116 // Copies results from DriveCache methods. Used to run asynchronous functions | 116 // Copies results from DriveCache methods. Used to run asynchronous functions |
| 117 // that take GetCacheEntryCallback from tests. | 117 // that take GetCacheEntryCallback from tests. |
| 118 void CopyResultsFromGetCacheEntryCallback(bool* out_success, | 118 void CopyResultsFromGetCacheEntryCallback(bool* out_success, |
| 119 DriveCacheEntry* out_cache_entry, | 119 DriveCacheEntry* out_cache_entry, |
| 120 bool success, | 120 bool success, |
| 121 const DriveCacheEntry& cache_entry); | 121 const DriveCacheEntry& cache_entry); |
| 122 | 122 |
| 123 // Copies results from DriveFileSystem methods. Used to run asynchronous | 123 // Copies results from DriveFileSystem methods. Used to run asynchronous |
| 124 // functions that take GetFileCallback from tests. | 124 // functions that take GetFileCallback from tests. |
| 125 void CopyResultsFromGetFileCallback(DriveFileError* out_error, | 125 void CopyResultsFromGetFileCallback(DriveFileError* out_error, |
| 126 FilePath* out_file_path, | 126 base::FilePath* out_file_path, |
| 127 DriveFileType* out_file_type, | 127 DriveFileType* out_file_type, |
| 128 DriveFileError error, | 128 DriveFileError error, |
| 129 const FilePath& file_path, | 129 const base::FilePath& file_path, |
| 130 const std::string& mime_type, | 130 const std::string& mime_type, |
| 131 DriveFileType file_type); | 131 DriveFileType file_type); |
| 132 | 132 |
| 133 // Copies results from DriveFileSystem methods. Used to run asynchronous | 133 // Copies results from DriveFileSystem methods. Used to run asynchronous |
| 134 // functions that take GetAvailableSpaceCallback from tests. | 134 // functions that take GetAvailableSpaceCallback from tests. |
| 135 void CopyResultsFromGetAvailableSpaceCallback(DriveFileError* out_error, | 135 void CopyResultsFromGetAvailableSpaceCallback(DriveFileError* out_error, |
| 136 int64* out_bytes_total, | 136 int64* out_bytes_total, |
| 137 int64* out_bytes_used, | 137 int64* out_bytes_used, |
| 138 DriveFileError error, | 138 DriveFileError error, |
| 139 int64 bytes_total, | 139 int64 bytes_total, |
| 140 int64 bytes_used); | 140 int64 bytes_used); |
| 141 | 141 |
| 142 // Copies the results from DriveFileSystem methods and stops the message loop | 142 // Copies the results from DriveFileSystem methods and stops the message loop |
| 143 // of the current thread. Used to run asynchronous function that take | 143 // of the current thread. Used to run asynchronous function that take |
| 144 // OpenFileCallback. | 144 // OpenFileCallback. |
| 145 void CopyResultsFromOpenFileCallbackAndQuit(DriveFileError* out_error, | 145 void CopyResultsFromOpenFileCallbackAndQuit(DriveFileError* out_error, |
| 146 FilePath* out_file_path, | 146 base::FilePath* out_file_path, |
| 147 DriveFileError error, | 147 DriveFileError error, |
| 148 const FilePath& file_path); | 148 const base::FilePath& file_path); |
| 149 | 149 |
| 150 // Copies the results from DriveFileSystem methods and stops the message loop | 150 // Copies the results from DriveFileSystem methods and stops the message loop |
| 151 // of the current thread. Used to run asynchronous function that take | 151 // of the current thread. Used to run asynchronous function that take |
| 152 // CloseFileCallback. | 152 // CloseFileCallback. |
| 153 void CopyResultsFromCloseFileCallbackAndQuit(DriveFileError* out_error, | 153 void CopyResultsFromCloseFileCallbackAndQuit(DriveFileError* out_error, |
| 154 DriveFileError error); | 154 DriveFileError error); |
| 155 | 155 |
| 156 // Loads a test json file as root ("/drive") element from a test file stored | 156 // Loads a test json file as root ("/drive") element from a test file stored |
| 157 // under chrome/test/data/chromeos. Returns true on success. | 157 // under chrome/test/data/chromeos. Returns true on success. |
| 158 bool LoadChangeFeed(const std::string& relative_path, | 158 bool LoadChangeFeed(const std::string& relative_path, |
| 159 DriveFeedLoader* feed_loader, | 159 DriveFeedLoader* feed_loader, |
| 160 bool is_delta_feed, | 160 bool is_delta_feed, |
| 161 int64 root_feed_changestamp); | 161 int64 root_feed_changestamp); |
| 162 | 162 |
| 163 } // namespace test_util | 163 } // namespace test_util |
| 164 } // namespace drive | 164 } // namespace drive |
| 165 | 165 |
| 166 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ | 166 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ |
| OLD | NEW |