Chromium Code Reviews| Index: base/path_service_unittest.cc |
| diff --git a/base/path_service_unittest.cc b/base/path_service_unittest.cc |
| index 81d1fef0b96c61379712f4c9ee2a87e720b2a37a..78b39bd3682e38c7d72102ae1bb688db6c9b6bee 100644 |
| --- a/base/path_service_unittest.cc |
| +++ b/base/path_service_unittest.cc |
| @@ -111,3 +111,48 @@ TEST_F(PathServiceTest, Override) { |
| true)); |
| EXPECT_TRUE(file_util::PathExists(fake_cache_dir2)); |
| } |
| + |
| +// Check if multiple overrides can co-excist. |
|
jar (doing other things)
2012/09/17 17:06:08
nit: excist --> exist
pastarmovj
2012/09/18 14:27:13
Done.
|
| +TEST_F(PathServiceTest, OverrideMultiple) { |
| + int my_special_key = 666; |
| + ScopedTempDir temp_dir; |
| + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| + FilePath fake_cache_dir1(temp_dir.path().AppendASCII("1")); |
| + // PathService::Override should always create the path provided if it doesn't |
| + // exist. |
| + EXPECT_TRUE(PathService::Override(my_special_key, fake_cache_dir1)); |
| + EXPECT_TRUE(file_util::PathExists(fake_cache_dir1)); |
| + |
| + FilePath fake_cache_dir2(temp_dir.path().AppendASCII("2")); |
| + // PathService::Override should always create the path provided if it doesn't |
| + // exist. |
| + EXPECT_TRUE(PathService::Override(my_special_key + 1, fake_cache_dir2)); |
| + EXPECT_TRUE(file_util::PathExists(fake_cache_dir2)); |
| + |
| + FilePath result; |
| + EXPECT_TRUE(PathService::Get(my_special_key, &result)); |
| + EXPECT_EQ(fake_cache_dir1, result); |
| + EXPECT_TRUE(PathService::Get(my_special_key + 1, &result)); |
| + EXPECT_EQ(fake_cache_dir2, result); |
| +} |
| + |
| +TEST_F(PathServiceTest, RemoveOverride) { |
| + // Before we start the test we have to call RemoveOverride at least once to |
| + // clear any overrides that might have been left from other tests. |
| + PathService::RemoveOverride(base::DIR_TEMP); |
| + |
| + FilePath original_user_data_dir; |
| + EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &original_user_data_dir)); |
| + EXPECT_FALSE(PathService::RemoveOverride(base::DIR_TEMP)); |
| + |
| + ScopedTempDir temp_dir; |
| + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| + EXPECT_TRUE(PathService::Override(base::DIR_TEMP, temp_dir.path())); |
| + FilePath new_user_data_dir; |
| + EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir)); |
| + EXPECT_NE(original_user_data_dir, new_user_data_dir); |
| + |
| + EXPECT_TRUE(PathService::RemoveOverride(base::DIR_TEMP)); |
| + EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &new_user_data_dir)); |
| + EXPECT_EQ(original_user_data_dir, new_user_data_dir); |
| +} |