| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // PathService::OverrideAndCreateIfNeeded should obey the |create| parameter. | 104 // PathService::OverrideAndCreateIfNeeded should obey the |create| parameter. |
| 105 PathService::OverrideAndCreateIfNeeded(my_special_key, | 105 PathService::OverrideAndCreateIfNeeded(my_special_key, |
| 106 fake_cache_dir2, | 106 fake_cache_dir2, |
| 107 false); | 107 false); |
| 108 EXPECT_FALSE(file_util::PathExists(fake_cache_dir2)); | 108 EXPECT_FALSE(file_util::PathExists(fake_cache_dir2)); |
| 109 EXPECT_TRUE(PathService::OverrideAndCreateIfNeeded(my_special_key, | 109 EXPECT_TRUE(PathService::OverrideAndCreateIfNeeded(my_special_key, |
| 110 fake_cache_dir2, | 110 fake_cache_dir2, |
| 111 true)); | 111 true)); |
| 112 EXPECT_TRUE(file_util::PathExists(fake_cache_dir2)); | 112 EXPECT_TRUE(file_util::PathExists(fake_cache_dir2)); |
| 113 } | 113 } |
| 114 |
| 115 TEST_F(PathServiceTest, RemoveOverride) { |
| 116 // Before we start the test we have to call RemoveOverride at least once to |
| 117 // clear any overrides that might have been left from other tests. |
| 118 PathService::RemoveOverride(base::DIR_TEMP); |
| 119 |
| 120 FilePath original_user_data_dir; |
| 121 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &original_user_data_dir)); |
| 122 EXPECT_FALSE(PathService::RemoveOverride(base::DIR_TEMP)); |
| 123 |
| 124 ScopedTempDir temp_dir; |
| 125 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 126 EXPECT_TRUE(PathService::Override(base::DIR_TEMP, temp_dir.path())); |
| 127 FilePath new_user_data_dir; |
| 128 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir)); |
| 129 EXPECT_NE(original_user_data_dir, new_user_data_dir); |
| 130 |
| 131 EXPECT_TRUE(PathService::RemoveOverride(base::DIR_TEMP)); |
| 132 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir)); |
| 133 EXPECT_EQ(original_user_data_dir, new_user_data_dir); |
| 134 } |
| OLD | NEW |