TestUtil.h 2.1 KB

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