gtest-utils.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright 2020 The Chromium Authors. All Rights Reserved.
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. */
  20. #ifndef THIRD_PARTY_LIBJPEG_TURBO_GTEST_UTILS_H_
  21. #define THIRD_PARTY_LIBJPEG_TURBO_GTEST_UTILS_H_
  22. #include "base/files/file.h"
  23. #include "base/files/file_util.h"
  24. #include "base/hash/md5.h"
  25. #include "base/path_service.h"
  26. #include "gtest-utils.h"
  27. #include <gtest/gtest.h>
  28. #include <string>
  29. // Returns the absolute path of the test output directory as a string.
  30. // On Android this path is /sdcard; on all other platforms it is the current
  31. // directory.
  32. #if defined(OS_WIN)
  33. std::wstring GetTargetDirectory();
  34. #else
  35. std::string GetTargetDirectory();
  36. #endif
  37. // Files used as input for libjpeg-turbo unit tests are stored in
  38. // <chromium>/src/third_party/libjpeg_turbo/testimages.
  39. // Given a test file |filename|, this function will set |path| to
  40. // <chromium>/src/third_party/libjpeg_turbo/testimages/filename
  41. // If the file does not exit an assertion will fail.
  42. void GetTestFilePath(base::FilePath* path,
  43. const std::string filename);
  44. // Returns true if the MD5 sum of the file at the given |path| matches that of
  45. // the |expected_md5|, false otherwise.
  46. bool CompareFileAndMD5(const base::FilePath& path,
  47. const std::string expected_md5);
  48. #endif // THIRD_PARTY_LIBJPEG_TURBO_GTEST_UTILS_H_