blob: b8cfd4a22a14543853aa25d85c093ff4024051f3 [file] [log] [blame]
[email protected]d3e6d252012-09-27 00:45:361// 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 "base/test/scoped_path_override.h"
6
7#include "base/logging.h"
8#include "base/path_service.h"
9
10namespace base {
11
12ScopedPathOverride::ScopedPathOverride(int key) : key_(key) {
13 bool result = temp_dir_.CreateUniqueTempDir();
14 CHECK(result);
vabr411f4fc2016-09-08 09:26:2715 result = PathService::Override(key, temp_dir_.GetPath());
[email protected]d3e6d252012-09-27 00:45:3616 CHECK(result);
17}
18
[email protected]023ad6ab2013-02-17 05:07:2319ScopedPathOverride::ScopedPathOverride(int key, const base::FilePath& dir)
[email protected]d3e6d252012-09-27 00:45:3620 : key_(key) {
21 bool result = PathService::Override(key, dir);
22 CHECK(result);
23}
24
grt71a91482014-11-27 23:39:5125ScopedPathOverride::ScopedPathOverride(int key,
26 const FilePath& path,
27 bool is_absolute,
28 bool create)
29 : key_(key) {
30 bool result =
31 PathService::OverrideAndCreateIfNeeded(key, path, is_absolute, create);
32 CHECK(result);
33}
34
[email protected]d3e6d252012-09-27 00:45:3635ScopedPathOverride::~ScopedPathOverride() {
36 bool result = PathService::RemoveOverride(key_);
37 CHECK(result) << "The override seems to have been removed already!";
38}
39
40} // namespace base