Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: chrome/browser/shell_integration_linux_unittest.cc

Issue 827013004: Linux: Change ShellIntegration code to use GetXDGDirectory(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_linux_unittest.cc
diff --git a/chrome/browser/shell_integration_linux_unittest.cc b/chrome/browser/shell_integration_linux_unittest.cc
index 05438f06157d7197f06bc8947cf492c07d543e7f..d99a8c8ac0b1a84c65796676d8f5e979bb700032 100644
--- a/chrome/browser/shell_integration_linux_unittest.cc
+++ b/chrome/browser/shell_integration_linux_unittest.cc
@@ -99,28 +99,25 @@ TEST(ShellIntegrationTest, GetDataWriteLocation) {
// Test that it returns $XDG_DATA_HOME.
{
MockEnvironment env;
- env.Set("HOME", "/home/user");
+ base::ScopedPathOverride home_override(base::DIR_HOME,
+ base::FilePath("/home/user"),
+ true /* absolute? */,
+ false /* create? */);
env.Set("XDG_DATA_HOME", "/user/path");
- base::FilePath path;
- ASSERT_TRUE(GetDataWriteLocation(&env, &path));
+ base::FilePath path = GetDataWriteLocation(&env);
EXPECT_EQ("/user/path", path.value());
}
// Test that $XDG_DATA_HOME falls back to $HOME/.local/share.
{
MockEnvironment env;
- env.Set("HOME", "/home/user");
- base::FilePath path;
- ASSERT_TRUE(GetDataWriteLocation(&env, &path));
+ base::ScopedPathOverride home_override(base::DIR_HOME,
+ base::FilePath("/home/user"),
+ true /* absolute? */,
+ false /* create? */);
+ base::FilePath path = GetDataWriteLocation(&env);
EXPECT_EQ("/home/user/.local/share", path.value());
}
-
- // Test that if neither $XDG_DATA_HOME nor $HOME are specified, it fails.
- {
- MockEnvironment env;
- base::FilePath path;
- ASSERT_FALSE(GetDataWriteLocation(&env, &path));
- }
}
TEST(ShellIntegrationTest, GetDataSearchLocations) {
@@ -130,7 +127,10 @@ TEST(ShellIntegrationTest, GetDataSearchLocations) {
// Test that it returns $XDG_DATA_HOME + $XDG_DATA_DIRS.
{
MockEnvironment env;
- env.Set("HOME", "/home/user");
+ base::ScopedPathOverride home_override(base::DIR_HOME,
+ base::FilePath("/home/user"),
+ true /* absolute? */,
+ false /* create? */);
env.Set("XDG_DATA_HOME", "/user/path");
env.Set("XDG_DATA_DIRS", "/system/path/1:/system/path/2");
EXPECT_THAT(
@@ -143,7 +143,10 @@ TEST(ShellIntegrationTest, GetDataSearchLocations) {
// Test that $XDG_DATA_HOME falls back to $HOME/.local/share.
{
MockEnvironment env;
- env.Set("HOME", "/home/user");
+ base::ScopedPathOverride home_override(base::DIR_HOME,
+ base::FilePath("/home/user"),
+ true /* absolute? */,
+ false /* create? */);
env.Set("XDG_DATA_DIRS", "/system/path/1:/system/path/2");
EXPECT_THAT(
FilePathsToStrings(GetDataSearchLocations(&env)),
@@ -157,16 +160,21 @@ TEST(ShellIntegrationTest, GetDataSearchLocations) {
{
MockEnvironment env;
env.Set("XDG_DATA_DIRS", "/system/path/1:/system/path/2");
- EXPECT_THAT(
- FilePathsToStrings(GetDataSearchLocations(&env)),
- ElementsAre("/system/path/1",
- "/system/path/2"));
+ std::vector<std::string> results =
+ FilePathsToStrings(GetDataSearchLocations(&env));
+ ASSERT_EQ(3U, results.size());
+ EXPECT_FALSE(results[0].empty());
+ EXPECT_EQ("/system/path/1", results[1]);
+ EXPECT_EQ("/system/path/2", results[2]);
}
// Test that $XDG_DATA_DIRS falls back to the two default paths.
{
MockEnvironment env;
- env.Set("HOME", "/home/user");
+ base::ScopedPathOverride home_override(base::DIR_HOME,
+ base::FilePath("/home/user"),
+ true /* absolute? */,
+ false /* create? */);
env.Set("XDG_DATA_HOME", "/user/path");
EXPECT_THAT(
FilePathsToStrings(GetDataSearchLocations(&env)),
@@ -316,7 +324,10 @@ TEST(ShellIntegrationTest, GetExistingShortcutContents) {
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
MockEnvironment env;
- env.Set("HOME", temp_dir.path().value());
+ base::ScopedPathOverride home_override(base::DIR_HOME,
+ temp_dir.path(),
+ true /* absolute? */,
+ false /* create? */);
ASSERT_TRUE(base::CreateDirectory(
temp_dir.path().Append(".local/share/applications")));
ASSERT_TRUE(WriteString(
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698