| // Copyright 2018 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "ios/chrome/browser/download/download_test_util.h" |
| |
| #include "base/base_paths.h" |
| #include "base/files/file.h" |
| #include "base/files/file_path.h" |
| #include "base/path_service.h" |
| |
| namespace testing { |
| |
| const char kPkPassFilePath[] = |
| "ios/testing/data/http_server_files/generic.pkpass"; |
| const char kUsdzFilePath[] = "ios/testing/data/http_server_files/redchair.usdz"; |
| |
| std::string GetTestFileContents(const char* file_path) { |
| base::FilePath path; |
| base::PathService::Get(base::DIR_MODULE, &path); |
| path = path.Append(FILE_PATH_LITERAL(file_path)); |
| base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); |
| size_t size_to_read = file.GetLength(); |
| std::string contents; |
| contents.resize(size_to_read); |
| size_t size_read = file.ReadAtCurrentPos(&contents[0], size_to_read); |
| contents.resize(size_read); |
| return contents; |
| } |
| |
| } // namespace testing |