blob: 6908137240a9c38cd5fc75c965f9117a08c1d2ba [file] [log] [blame]
[email protected]01c988d2012-12-11 23:02:541// Copyright (c) 2012 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.
4
5#include "chromeos/chromeos_test_utils.h"
6
[email protected]57999812013-02-24 05:40:527#include "base/files/file_path.h"
thestigb44bd352014-09-10 01:47:068#include "base/files/file_util.h"
[email protected]01c988d2012-12-11 23:02:549#include "base/path_service.h"
10
11namespace chromeos {
12namespace test_utils {
13
14bool GetTestDataPath(const std::string& component,
15 const std::string& filename,
[email protected]a3ef4832013-02-02 05:12:3316 base::FilePath* data_dir) {
17 base::FilePath path;
Avi Drissmanea15ea02018-05-07 18:55:1218 if (!base::PathService::Get(base::DIR_SOURCE_ROOT, &path))
[email protected]01c988d2012-12-11 23:02:5419 return false;
20 path = path.Append(FILE_PATH_LITERAL("chromeos"));
21 path = path.Append(FILE_PATH_LITERAL("test"));
22 path = path.Append(FILE_PATH_LITERAL("data"));
[email protected]7567484142013-07-11 17:36:0723 if (!base::PathExists(path)) // We don't want to create this.
[email protected]01c988d2012-12-11 23:02:5424 return false;
25 DCHECK(data_dir);
26 path = path.Append(component);
27 *data_dir = path.Append(filename);
28 return true;
29}
30
31} // namespace test_utils
32} // namespace chromeos