1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/utility/safe_browsing/mac/dmg_test_utils.h"
7 #include "base/files/file_path.h"
8 #include "base/logging.h"
9 #include "base/path_service.h"
10 #include "chrome/common/chrome_paths.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace safe_browsing
{
17 void GetTestFile(const char* file_name
, base::File
* file
) {
18 base::FilePath test_data
;
19 ASSERT_TRUE(PathService::Get(chrome::DIR_GEN_TEST_DATA
, &test_data
));
21 base::FilePath path
= test_data
.AppendASCII("chrome")
22 .AppendASCII("safe_browsing_dmg")
23 .AppendASCII(file_name
);
25 *file
= base::File(path
, base::File::FLAG_OPEN
| base::File::FLAG_READ
);
26 ASSERT_TRUE(file
->IsValid());
29 bool ReadEntireStream(ReadStream
* stream
, std::vector
<uint8_t>* data
) {
30 DCHECK(data
->empty());
32 size_t bytes_read
= 0;
36 if (!stream
->Read(buffer
, sizeof(buffer
), &bytes_read
))
39 data
->insert(data
->end(), buffer
, &buffer
[bytes_read
]);
40 } while (bytes_read
!= 0);
47 } // namespace safe_browsing