TestUtil.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "common.h"
  2. #include <string>
  3. #include "SharedHandle.h"
  4. #include "Cookie.h"
  5. #include "WrDiskCacheEntry.h"
  6. #include "GroupId.h"
  7. namespace aria2 {
  8. class MessageDigest;
  9. class RequestGroupMan;
  10. class RequestGroup;
  11. class Option;
  12. void createFile(const std::string& filename, size_t length);
  13. std::string readFile(const std::string& path);
  14. class CookieSorter {
  15. public:
  16. bool operator()(const Cookie& lhs, const Cookie& rhs) const
  17. {
  18. if(lhs.getDomain() == rhs.getDomain()) {
  19. return lhs.getName() < rhs.getName();
  20. } else {
  21. return lhs.getDomain() < rhs.getDomain();
  22. }
  23. }
  24. };
  25. Cookie createCookie
  26. (const std::string& name,
  27. const std::string& value,
  28. const std::string& domain,
  29. bool hostOnly,
  30. const std::string& path,
  31. bool secure);
  32. Cookie createCookie
  33. (const std::string& name,
  34. const std::string& value,
  35. time_t expiryTime,
  36. const std::string& domain,
  37. bool hostOnly,
  38. const std::string& path,
  39. bool secure);
  40. std::string fromHex(const std::string& s);
  41. #ifdef ENABLE_MESSAGE_DIGEST
  42. // Returns hex digest of contents of file denoted by filename.
  43. std::string fileHexDigest
  44. (const SharedHandle<MessageDigest>& ctx, const std::string& filename);
  45. #endif // ENABLE_MESSAGE_DIGEST
  46. WrDiskCacheEntry::DataCell* createDataCell(int64_t goff,
  47. const char* data,
  48. size_t offset = 0);
  49. SharedHandle<RequestGroup> findReservedGroup
  50. (const SharedHandle<RequestGroupMan>& rgman, a2_gid_t gid);
  51. SharedHandle<RequestGroup> getReservedGroup
  52. (const SharedHandle<RequestGroupMan>& rgman, size_t index);
  53. SharedHandle<RequestGroup> createRequestGroup(int32_t pieceLength,
  54. int64_t totalLength,
  55. const std::string& path,
  56. const std::string& uri,
  57. const SharedHandle<Option>& opt);
  58. } // namespace aria2