| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
| 12 #include "update_engine/action.h" | 12 #include "update_engine/action.h" |
| 13 | 13 |
| 14 // These are some handy functions for unittests. | 14 // These are some handy functions for unittests. |
| 15 | 15 |
| 16 namespace chromeos_update_engine { | 16 namespace chromeos_update_engine { |
| 17 | 17 |
| 18 // Writes the data passed to path. The file at path will be overwritten if it | 18 // Writes the data passed to path. The file at path will be overwritten if it |
| 19 // exists. Returns true on success, false otherwise. | 19 // exists. Returns true on success, false otherwise. |
| 20 bool WriteFile(const char* path, const char* data, int data_len); | |
| 21 bool WriteFileVector(const std::string& path, const std::vector<char>& data); | 20 bool WriteFileVector(const std::string& path, const std::vector<char>& data); |
| 22 bool WriteFileString(const std::string& path, const std::string& data); | 21 bool WriteFileString(const std::string& path, const std::string& data); |
| 23 | 22 |
| 24 // Returns the size of the file at path. If the file doesn't exist or some | 23 // Returns the size of the file at path. If the file doesn't exist or some |
| 25 // error occurrs, -1 is returned. | 24 // error occurrs, -1 is returned. |
| 26 off_t FileSize(const std::string& path); | 25 off_t FileSize(const std::string& path); |
| 27 | 26 |
| 28 // Reads a symlink from disk. Returns empty string on failure. | 27 // Reads a symlink from disk. Returns empty string on failure. |
| 29 std::string Readlink(const std::string& path); | 28 std::string Readlink(const std::string& path); |
| 30 | 29 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 static std::string StaticType() { return "ObjectCollectorAction"; } | 169 static std::string StaticType() { return "ObjectCollectorAction"; } |
| 171 std::string Type() const { return StaticType(); } | 170 std::string Type() const { return StaticType(); } |
| 172 const T& object() const { return object_; } | 171 const T& object() const { return object_; } |
| 173 private: | 172 private: |
| 174 T object_; | 173 T object_; |
| 175 }; | 174 }; |
| 176 | 175 |
| 177 } // namespace chromeos_update_engine | 176 } // namespace chromeos_update_engine |
| 178 | 177 |
| 179 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ | 178 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_TEST_UTILS_H__ |
| OLD | NEW |