Chromium Code Reviews| 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_GDATA_GDATA_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_TEST_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" | 9 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" |
| 10 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 11 | 11 |
| 12 class FilePath; | 12 class FilePath; |
| 13 | 13 |
| 14 namespace gdata { | 14 namespace gdata { |
| 15 | 15 |
| 16 class GDataEntryProto; | 16 class DriveCacheEntry; |
| 17 class GDataCacheEntry; | 17 class DriveEntryProto; |
|
kinaba
2012/08/21 09:15:14
No declaration for DriveEntryProtoVector.
kochi
2012/08/21 09:37:34
Done.
| |
| 18 | 18 |
| 19 namespace test_util { | 19 namespace test_util { |
| 20 | 20 |
| 21 // Runs a task posted to the blocking pool, including subquent tasks posted | 21 // Runs a task posted to the blocking pool, including subquent tasks posted |
| 22 // to the UI message loop and the blocking pool. | 22 // to the UI message loop and the blocking pool. |
| 23 // | 23 // |
| 24 // A task is often posted to the blocking pool with PostTaskAndReply(). In | 24 // A task is often posted to the blocking pool with PostTaskAndReply(). In |
| 25 // that case, a task is posted back to the UI message loop, which can again | 25 // that case, a task is posted back to the UI message loop, which can again |
| 26 // post a task to the blocking pool. This function processes these tasks | 26 // post a task to the blocking pool. This function processes these tasks |
| 27 // repeatedly. | 27 // repeatedly. |
| 28 void RunBlockingPoolTask(); | 28 void RunBlockingPoolTask(); |
| 29 | 29 |
| 30 // This is a bitmask of cache states in GDataCacheEntry. Used only in tests. | 30 // This is a bitmask of cache states in DriveCacheEntry. Used only in tests. |
| 31 enum TestGDataCacheState { | 31 enum TestGDataCacheState { |
| 32 TEST_CACHE_STATE_NONE = 0, | 32 TEST_CACHE_STATE_NONE = 0, |
| 33 TEST_CACHE_STATE_PINNED = 1 << 0, | 33 TEST_CACHE_STATE_PINNED = 1 << 0, |
| 34 TEST_CACHE_STATE_PRESENT = 1 << 1, | 34 TEST_CACHE_STATE_PRESENT = 1 << 1, |
| 35 TEST_CACHE_STATE_DIRTY = 1 << 2, | 35 TEST_CACHE_STATE_DIRTY = 1 << 2, |
| 36 TEST_CACHE_STATE_MOUNTED = 1 << 3, | 36 TEST_CACHE_STATE_MOUNTED = 1 << 3, |
| 37 TEST_CACHE_STATE_PERSISTENT = 1 << 4, | 37 TEST_CACHE_STATE_PERSISTENT = 1 << 4, |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Converts |cache_state| which is a bit mask of TestGDataCacheState, to a | 40 // Converts |cache_state| which is a bit mask of TestGDataCacheState, to a |
| 41 // GDataCacheEntry. | 41 // DriveCacheEntry. |
| 42 GDataCacheEntry ToCacheEntry(int cache_state); | 42 DriveCacheEntry ToCacheEntry(int cache_state); |
| 43 | 43 |
| 44 // Returns true if the cache state of the given two cache entries are equal. | 44 // Returns true if the cache state of the given two cache entries are equal. |
| 45 bool CacheStatesEqual(const GDataCacheEntry& a, const GDataCacheEntry& b); | 45 bool CacheStatesEqual(const DriveCacheEntry& a, const DriveCacheEntry& b); |
| 46 | 46 |
| 47 // Copies |error| to |output|. Used to run asynchronous functions that take | 47 // Copies |error| to |output|. Used to run asynchronous functions that take |
| 48 // FileOperationCallback from tests. | 48 // FileOperationCallback from tests. |
| 49 void CopyErrorCodeFromFileOperationCallback(GDataFileError* output, | 49 void CopyErrorCodeFromFileOperationCallback(GDataFileError* output, |
| 50 GDataFileError error); | 50 GDataFileError error); |
| 51 | 51 |
| 52 // Copies |error| and |moved_file_path| to |out_error| and |out_file_path|. | 52 // Copies |error| and |moved_file_path| to |out_error| and |out_file_path|. |
| 53 // Used to run asynchronous functions that take FileMoveCallback from tests. | 53 // Used to run asynchronous functions that take FileMoveCallback from tests. |
| 54 void CopyResultsFromFileMoveCallback(GDataFileError* out_error, | 54 void CopyResultsFromFileMoveCallback(GDataFileError* out_error, |
| 55 FilePath* out_file_path, | 55 FilePath* out_file_path, |
| 56 GDataFileError error, | 56 GDataFileError error, |
| 57 const FilePath& moved_file_path); | 57 const FilePath& moved_file_path); |
| 58 | 58 |
| 59 // Copies |error| and |entry_proto| to |out_error| and |out_entry_proto| | 59 // Copies |error| and |entry_proto| to |out_error| and |out_entry_proto| |
| 60 // respectively. Used to run asynchronous functions that take | 60 // respectively. Used to run asynchronous functions that take |
| 61 // GetEntryInfoCallback from tests. | 61 // GetEntryInfoCallback from tests. |
| 62 void CopyResultsFromGetEntryInfoCallback( | 62 void CopyResultsFromGetEntryInfoCallback( |
| 63 GDataFileError* out_error, | 63 GDataFileError* out_error, |
| 64 scoped_ptr<GDataEntryProto>* out_entry_proto, | 64 scoped_ptr<DriveEntryProto>* out_entry_proto, |
| 65 GDataFileError error, | 65 GDataFileError error, |
| 66 scoped_ptr<GDataEntryProto> entry_proto); | 66 scoped_ptr<DriveEntryProto> entry_proto); |
| 67 | 67 |
| 68 // Copies |error| and |entries| to |out_error| and |out_entries| | 68 // Copies |error| and |entries| to |out_error| and |out_entries| |
| 69 // respectively. Used to run asynchronous functions that take | 69 // respectively. Used to run asynchronous functions that take |
| 70 // GetEntryInfoCallback from tests. | 70 // GetEntryInfoCallback from tests. |
| 71 void CopyResultsFromReadDirectoryCallback( | 71 void CopyResultsFromReadDirectoryCallback( |
| 72 GDataFileError* out_error, | 72 GDataFileError* out_error, |
| 73 scoped_ptr<GDataEntryProtoVector>* out_entries, | 73 scoped_ptr<DriveEntryProtoVector>* out_entries, |
| 74 GDataFileError error, | 74 GDataFileError error, |
| 75 scoped_ptr<GDataEntryProtoVector> entries); | 75 scoped_ptr<DriveEntryProtoVector> entries); |
| 76 | 76 |
| 77 // Copies |error|, |drive_file_path|, and |entry_proto| to |out_error|, | 77 // Copies |error|, |drive_file_path|, and |entry_proto| to |out_error|, |
| 78 // |out_drive_file_path|, and |out_entry_proto| respectively. Used to run | 78 // |out_drive_file_path|, and |out_entry_proto| respectively. Used to run |
| 79 // asynchronous functions that take GetEntryInfoWithFilePathCallback from | 79 // asynchronous functions that take GetEntryInfoWithFilePathCallback from |
| 80 // tests. | 80 // tests. |
| 81 void CopyResultsFromGetEntryInfoWithFilePathCallback( | 81 void CopyResultsFromGetEntryInfoWithFilePathCallback( |
| 82 GDataFileError* out_error, | 82 GDataFileError* out_error, |
| 83 FilePath* out_drive_file_path, | 83 FilePath* out_drive_file_path, |
| 84 scoped_ptr<GDataEntryProto>* out_entry_proto, | 84 scoped_ptr<DriveEntryProto>* out_entry_proto, |
| 85 GDataFileError error, | 85 GDataFileError error, |
| 86 const FilePath& drive_file_path, | 86 const FilePath& drive_file_path, |
| 87 scoped_ptr<GDataEntryProto> entry_proto); | 87 scoped_ptr<DriveEntryProto> entry_proto); |
| 88 | 88 |
| 89 // Copies |result| to |out_result|. Used to run asynchronous functions | 89 // Copies |result| to |out_result|. Used to run asynchronous functions |
| 90 // that take GetEntryInfoPairCallback from tests. | 90 // that take GetEntryInfoPairCallback from tests. |
| 91 void CopyResultsFromGetEntryInfoPairCallback( | 91 void CopyResultsFromGetEntryInfoPairCallback( |
| 92 scoped_ptr<EntryInfoPairResult>* out_result, | 92 scoped_ptr<EntryInfoPairResult>* out_result, |
| 93 scoped_ptr<EntryInfoPairResult> result); | 93 scoped_ptr<EntryInfoPairResult> result); |
| 94 | 94 |
| 95 } // namespace test_util | 95 } // namespace test_util |
| 96 } // namespace gdata | 96 } // namespace gdata |
| 97 | 97 |
| 98 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_TEST_UTIL_H_ | 98 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_TEST_UTIL_H_ |
| OLD | NEW |