Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / utility / safe_browsing / mac / dmg_test_utils.cc
blobcf6c5a2a2d819f199d53967629908fbb9693506a
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 {
14 namespace dmg {
15 namespace test {
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());
31 uint8_t buffer[1024];
32 size_t bytes_read = 0;
33 do {
34 bytes_read = 0;
36 if (!stream->Read(buffer, sizeof(buffer), &bytes_read))
37 return false;
39 data->insert(data->end(), buffer, &buffer[bytes_read]);
40 } while (bytes_read != 0);
42 return true;
45 } // namespace test
46 } // namespace dmg
47 } // namespace safe_browsing