diff options
author | Wei Li <weili@chromium.org> | 2015-11-09 10:22:30 -0800 |
---|---|---|
committer | Wei Li <weili@chromium.org> | 2015-11-09 10:22:30 -0800 |
commit | c0e93a9a942fe7d99800502a61d2fbb58cf9276f (patch) | |
tree | d129c72f56be283d4436b9d493d590c6b3825500 /testing/utils/path_service.h | |
parent | a8f5b7b5e7501bdcfba585fc8af76c4a0fab22cb (diff) | |
download | pdfium-c0e93a9a942fe7d99800502a61d2fbb58cf9276f.tar.xz |
Add path service to retrieve test data directory at run time so tests can be run from any directory.
Previously the tests which read test files assume the current directory is under pdfium. Running from any other directory will break the build.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1408003014 .
Diffstat (limited to 'testing/utils/path_service.h')
-rw-r--r-- | testing/utils/path_service.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/testing/utils/path_service.h b/testing/utils/path_service.h new file mode 100644 index 0000000000..96fd69e889 --- /dev/null +++ b/testing/utils/path_service.h @@ -0,0 +1,37 @@ +// Copyright 2015 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef TESTING_UTILS_PATH_SERVICE_H_ +#define TESTING_UTILS_PATH_SERVICE_H_ + +#include <string> + +#ifdef _WIN32 +#define PATH_SEPARATOR '\\' +#else +#define PATH_SEPARATOR '/' +#endif + +// Get the various file directory and path information. +class PathService { + public: + // Return true when the path ends with a path separator. + static bool EndsWithSeparator(const std::string& path); + + // Retrieve the directory where executables run from. + static bool GetExecutableDir(std::string* path); + + // Retrieve the root directory of the source tree. + // Assume executables always run from out/<Debug|Release>/, the source + // directory is two levels above the executable directory. + static bool GetSourceDir(std::string* path); + + // Retrieve the test data directory where test files are stored. + // Currently, the test dir is under <source_dir>/testing/resources/. + static bool GetTestDataDir(std::string* path); + + // Get the full path for a test file under the test data directory. + static bool GetTestFilePath(const std::string& file_name, std::string* path); +}; +#endif // TESTING_UTILS_PATH_SERVICE_H_ |