| 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_DRIVE_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_TEST_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_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/gdata/drive_resource_metadata.h" | 9 #include "chrome/browser/chromeos/gdata/drive_resource_metadata.h" |
| 10 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
| 10 #include "chrome/browser/google_apis/gdata_errorcode.h" | 11 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 11 | 12 |
| 12 class FilePath; | 13 class FilePath; |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class Value; | 16 class Value; |
| 16 } | 17 } |
| 17 | 18 |
| 18 namespace gdata { | 19 namespace gdata { |
| 19 | 20 |
| 20 class DriveCacheEntry; | 21 class DriveCacheEntry; |
| 21 class DriveEntryProto; | 22 class DriveEntryProto; |
| 22 class DriveFileSystem; | 23 class DriveFileSystem; |
| 23 | 24 |
| 24 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; | 25 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; |
| 25 | 26 |
| 26 namespace test_util { | 27 namespace test_util { |
| 27 | 28 |
| 28 // Runs a task posted to the blocking pool, including subsequent tasks posted | |
| 29 // to the UI message loop and the blocking pool. | |
| 30 // | |
| 31 // A task is often posted to the blocking pool with PostTaskAndReply(). In | |
| 32 // that case, a task is posted back to the UI message loop, which can again | |
| 33 // post a task to the blocking pool. This function processes these tasks | |
| 34 // repeatedly. | |
| 35 void RunBlockingPoolTask(); | |
| 36 | |
| 37 // This is a bitmask of cache states in DriveCacheEntry. Used only in tests. | 29 // This is a bitmask of cache states in DriveCacheEntry. Used only in tests. |
| 38 enum TestDriveCacheState { | 30 enum TestDriveCacheState { |
| 39 TEST_CACHE_STATE_NONE = 0, | 31 TEST_CACHE_STATE_NONE = 0, |
| 40 TEST_CACHE_STATE_PINNED = 1 << 0, | 32 TEST_CACHE_STATE_PINNED = 1 << 0, |
| 41 TEST_CACHE_STATE_PRESENT = 1 << 1, | 33 TEST_CACHE_STATE_PRESENT = 1 << 1, |
| 42 TEST_CACHE_STATE_DIRTY = 1 << 2, | 34 TEST_CACHE_STATE_DIRTY = 1 << 2, |
| 43 TEST_CACHE_STATE_MOUNTED = 1 << 3, | 35 TEST_CACHE_STATE_MOUNTED = 1 << 3, |
| 44 TEST_CACHE_STATE_PERSISTENT = 1 << 4, | 36 TEST_CACHE_STATE_PERSISTENT = 1 << 4, |
| 45 }; | 37 }; |
| 46 | 38 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 DriveFileError error, | 84 DriveFileError error, |
| 93 const FilePath& drive_file_path, | 85 const FilePath& drive_file_path, |
| 94 scoped_ptr<DriveEntryProto> entry_proto); | 86 scoped_ptr<DriveEntryProto> entry_proto); |
| 95 | 87 |
| 96 // Copies |result| to |out_result|. Used to run asynchronous functions | 88 // Copies |result| to |out_result|. Used to run asynchronous functions |
| 97 // that take GetEntryInfoPairCallback from tests. | 89 // that take GetEntryInfoPairCallback from tests. |
| 98 void CopyResultsFromGetEntryInfoPairCallback( | 90 void CopyResultsFromGetEntryInfoPairCallback( |
| 99 scoped_ptr<EntryInfoPairResult>* out_result, | 91 scoped_ptr<EntryInfoPairResult>* out_result, |
| 100 scoped_ptr<EntryInfoPairResult> result); | 92 scoped_ptr<EntryInfoPairResult> result); |
| 101 | 93 |
| 102 // Returns the absolute path for a test file stored under | |
| 103 // chrome/test/data/chromeos. | |
| 104 FilePath GetTestFilePath(const std::string& relative_path); | |
| 105 | |
| 106 // Loads a test JSON file as a base::Value, from a test file stored under | |
| 107 // chrome/test/data/chromeos. | |
| 108 scoped_ptr<base::Value> LoadJSONFile(const std::string& relative_path); | |
| 109 | |
| 110 // Loads a test json file as root ("/drive") element from a test file stored | 94 // Loads a test json file as root ("/drive") element from a test file stored |
| 111 // under chrome/test/data/chromeos. | 95 // under chrome/test/data/chromeos. |
| 112 void LoadChangeFeed(const std::string& relative_path, | 96 void LoadChangeFeed(const std::string& relative_path, |
| 113 DriveFileSystem* file_system, | 97 DriveFileSystem* file_system, |
| 114 int64 start_changestamp, | 98 int64 start_changestamp, |
| 115 int64 root_feed_changestamp); | 99 int64 root_feed_changestamp); |
| 116 | 100 |
| 117 } // namespace test_util | 101 } // namespace test_util |
| 118 } // namespace gdata | 102 } // namespace gdata |
| 119 | 103 |
| 120 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_TEST_UTIL_H_ | 104 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_TEST_UTIL_H_ |
| OLD | NEW |