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

Unified Diff: chrome/browser/shell_integration_unittest.cc

Issue 12386077: shell_integration_linux: Follow the XDG Base Directory Specification. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Swap /usr/share and /usr/local/share to match the spec. Created 7 years, 10 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_unittest.cc
diff --git a/chrome/browser/shell_integration_unittest.cc b/chrome/browser/shell_integration_unittest.cc
index 39ca70ad9a1852253b7545663f90b34bf5dbcc64..186e14f745ee42da96cc4165b3b5e7fe8aee4ffc 100644
--- a/chrome/browser/shell_integration_unittest.cc
+++ b/chrome/browser/shell_integration_unittest.cc
@@ -119,14 +119,41 @@ TEST(ShellIntegrationTest, GetDesktopShortcutTemplate) {
MessageLoop message_loop;
content::TestBrowserThread file_thread(BrowserThread::FILE, &message_loop);
+ // Test that it searches $XDG_DATA_HOME/applications.
{
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
MockEnvironment env;
env.Set("XDG_DATA_HOME", temp_dir.path().value());
+ // Create a file in a non-applications directory. This should be ignored.
ASSERT_TRUE(file_util::WriteFile(
temp_dir.path().AppendASCII(kTemplateFilename),
+ kTestData2, strlen(kTestData2)));
+ ASSERT_TRUE(file_util::CreateDirectory(
+ temp_dir.path().AppendASCII("applications")));
+ ASSERT_TRUE(file_util::WriteFile(
+ temp_dir.path().AppendASCII("applications")
+ .AppendASCII(kTemplateFilename),
+ kTestData1, strlen(kTestData1)));
+ std::string contents;
+ ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env,
+ &contents));
+ EXPECT_EQ(kTestData1, contents);
+ }
+
+ // Test that it falls back to $HOME/.local/share/applications.
+ {
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+
+ MockEnvironment env;
+ env.Set("HOME", temp_dir.path().value());
+ ASSERT_TRUE(file_util::CreateDirectory(
+ temp_dir.path().AppendASCII(".local/share/applications")));
+ ASSERT_TRUE(file_util::WriteFile(
+ temp_dir.path().AppendASCII(".local/share/applications")
+ .AppendASCII(kTemplateFilename),
kTestData1, strlen(kTestData1)));
std::string contents;
ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env,
@@ -134,6 +161,7 @@ TEST(ShellIntegrationTest, GetDesktopShortcutTemplate) {
EXPECT_EQ(kTestData1, contents);
}
+ // Test that it searches $XDG_DATA_DIRS/applications.
{
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -152,26 +180,31 @@ TEST(ShellIntegrationTest, GetDesktopShortcutTemplate) {
EXPECT_EQ(kTestData2, contents);
}
+ // Test that it searches $X/applications for each X in $XDG_DATA_DIRS.
{
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ base::ScopedTempDir temp_dir1;
+ ASSERT_TRUE(temp_dir1.CreateUniqueTempDir());
+ base::ScopedTempDir temp_dir2;
+ ASSERT_TRUE(temp_dir2.CreateUniqueTempDir());
MockEnvironment env;
- env.Set("XDG_DATA_DIRS", temp_dir.path().value() + ":" +
- temp_dir.path().AppendASCII("applications").value());
- ASSERT_TRUE(file_util::CreateDirectory(
- temp_dir.path().AppendASCII("applications")));
+ env.Set("XDG_DATA_DIRS", temp_dir1.path().value() + ":" +
+ temp_dir2.path().value());
+ // Create a file in a non-applications directory. This should be ignored.
ASSERT_TRUE(file_util::WriteFile(
- temp_dir.path().AppendASCII(kTemplateFilename),
+ temp_dir1.path().AppendASCII(kTemplateFilename),
kTestData1, strlen(kTestData1)));
+ // Only create a findable desktop file in the second path.
+ ASSERT_TRUE(file_util::CreateDirectory(
+ temp_dir2.path().AppendASCII("applications")));
ASSERT_TRUE(file_util::WriteFile(
- temp_dir.path().AppendASCII("applications")
+ temp_dir2.path().AppendASCII("applications")
.AppendASCII(kTemplateFilename),
kTestData2, strlen(kTestData2)));
std::string contents;
ASSERT_TRUE(ShellIntegrationLinux::GetDesktopShortcutTemplate(&env,
&contents));
- EXPECT_EQ(kTestData1, contents);
+ EXPECT_EQ(kTestData2, contents);
}
}
« 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