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/chromeos/drive/search_metadata.h" | 10 #include "chrome/browser/chromeos/drive/search_metadata.h" |
(...skipping 26 matching lines...) Expand all Loading... |
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 TestDriveCacheState, to a | 40 // Converts |cache_state| which is a bit mask of TestDriveCacheState, to a |
41 // DriveCacheEntry. | 41 // DriveCacheEntry. |
42 DriveCacheEntry 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 DriveCacheEntry& a, const DriveCacheEntry& b); | 45 bool CacheStatesEqual(const DriveCacheEntry& a, const DriveCacheEntry& b); |
46 | 46 |
47 // Copies results from DriveFileSystem methods. Used to run asynchronous | |
48 // functions that take GetAvailableSpaceCallback from tests. | |
49 void CopyResultsFromGetAvailableSpaceCallback(DriveFileError* out_error, | |
50 int64* out_bytes_total, | |
51 int64* out_bytes_used, | |
52 DriveFileError error, | |
53 int64 bytes_total, | |
54 int64 bytes_used); | |
55 | |
56 // Copies results from SearchMetadataCallback. | |
57 void CopyResultsFromSearchMetadataCallback( | |
58 DriveFileError* out_error, | |
59 scoped_ptr<MetadataSearchResultVector>* out_result, | |
60 DriveFileError error, | |
61 scoped_ptr<MetadataSearchResultVector> result); | |
62 | |
63 // Copies the results from DriveFileSystem methods and stops the message loop | |
64 // of the current thread. Used to run asynchronous function that take | |
65 // OpenFileCallback. | |
66 void CopyResultsFromOpenFileCallbackAndQuit(DriveFileError* out_error, | |
67 base::FilePath* out_file_path, | |
68 DriveFileError error, | |
69 const base::FilePath& file_path); | |
70 | |
71 // Copies the results from DriveFileSystem methods and stops the message loop | |
72 // of the current thread. Used to run asynchronous function that take | |
73 // CloseFileCallback. | |
74 void CopyResultsFromCloseFileCallbackAndQuit(DriveFileError* out_error, | |
75 DriveFileError error); | |
76 | |
77 // Loads a test json file as root ("/drive") element from a test file stored | 47 // Loads a test json file as root ("/drive") element from a test file stored |
78 // under chrome/test/data/chromeos. Returns true on success. | 48 // under chrome/test/data/chromeos. Returns true on success. |
79 bool LoadChangeFeed(const std::string& relative_path, | 49 bool LoadChangeFeed(const std::string& relative_path, |
80 ChangeListLoader* change_list_loader, | 50 ChangeListLoader* change_list_loader, |
81 bool is_delta_feed, | 51 bool is_delta_feed, |
82 const std::string& root_resource_id, | 52 const std::string& root_resource_id, |
83 int64 root_feed_changestamp); | 53 int64 root_feed_changestamp); |
84 | 54 |
85 // Helper to destroy objects which needs Destroy() to be called on destruction. | 55 // Helper to destroy objects which needs Destroy() to be called on destruction. |
86 // Note: When using this helper, you should destruct objects before | 56 // Note: When using this helper, you should destruct objects before |
87 // BrowserThread. | 57 // BrowserThread. |
88 struct DestroyHelperForTests { | 58 struct DestroyHelperForTests { |
89 template<typename T> | 59 template<typename T> |
90 void operator()(T* object) const { | 60 void operator()(T* object) const { |
91 if (object) { | 61 if (object) { |
92 object->Destroy(); | 62 object->Destroy(); |
93 google_apis::test_util::RunBlockingPoolTask(); // Finish destruction. | 63 google_apis::test_util::RunBlockingPoolTask(); // Finish destruction. |
94 } | 64 } |
95 } | 65 } |
96 }; | 66 }; |
97 | 67 |
98 } // namespace test_util | 68 } // namespace test_util |
99 } // namespace drive | 69 } // namespace drive |
100 | 70 |
101 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ | 71 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_TEST_UTIL_H_ |
OLD | NEW |