diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 21:34:49 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 21:34:49 +0000 |
commit | b96aa938b7f86b67f7d4c167e713f5c23fae01d6 (patch) | |
tree | 92c58342b82e416a5ffd29a7c283fdcfe9c0c82b /chrome/browser/shell_integration_unittest.cc | |
parent | 4778bf3be094a4faac5e622a5f18be308908e53c (diff) | |
download | chromium_src-b96aa938b7f86b67f7d4c167e713f5c23fae01d6.zip chromium_src-b96aa938b7f86b67f7d4c167e713f5c23fae01d6.tar.gz chromium_src-b96aa938b7f86b67f7d4c167e713f5c23fae01d6.tar.bz2 |
First step to create application shortcuts on Linux.
Create a working desktop shortcut. For now it displays no UI, but the backend works.
TEST=none
http://crbug.com/17251
Review URL: http://codereview.chromium.org/164280
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/shell_integration_unittest.cc')
-rw-r--r-- | chrome/browser/shell_integration_unittest.cc | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/chrome/browser/shell_integration_unittest.cc b/chrome/browser/shell_integration_unittest.cc new file mode 100644 index 0000000..fe01fc1 --- /dev/null +++ b/chrome/browser/shell_integration_unittest.cc @@ -0,0 +1,94 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/shell_integration.h" + +#include "base/file_path.h" +#include "base/string_util.h" +#include "googleurl/src/gurl.h" +#include "testing/gtest/include/gtest/gtest.h" + +#define FPL FILE_PATH_LITERAL + +#if defined(OS_LINUX) +TEST(ShellIntegrationTest, GetDesktopShortcutFilename) { + const struct { + const FilePath::CharType* path; + const char* url; + } test_cases[] = { + { FPL("http___foo_.desktop"), "http://foo" }, + { FPL("http___foo_bar_.desktop"), "http://foo/bar/" }, + { FPL("http___foo_bar_a=b&c=d.desktop"), "http://foo/bar?a=b&c=d" }, + + // Now we're starting to be more evil... + { FPL("http___foo_.desktop"), "http://foo/bar/baz/../../../../../" }, + { FPL("http___foo_.desktop"), "http://foo/bar/././../baz/././../" }, + { FPL("http___.._.desktop"), "http://../../../../" }, + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { + EXPECT_EQ(test_cases[i].path, ShellIntegration::GetDesktopShortcutFilename( + GURL(test_cases[i].url)).value()) << " while testing " << + test_cases[i].url; + } +} + +TEST(ShellIntegrationTest, GetDesktopFileContents) { + const struct { + const char* url; + const char* title; + const char* template_contents; + const char* expected_output; + } test_cases[] = { + // Dumb case. + { "ignored", "ignored", "", "" }, + + // Real-world case. + { "http://gmail.com", + "GMail", + + "[Desktop Entry]\n" + "Version=1.0\n" + "Encoding=UTF-8\n" + "Name=Google Chrome\n" + "Comment=The web browser from Google\n" + "Exec=/opt/google/chrome/google-chrome %U\n" + "Terminal=false\n" + "Icon=/opt/google/chrome/product_logo_48.png\n" + "Type=Application\n" + "Categories=Application;Network;WebBrowser;\n" + "MimeType=text/html;text/xml;application/xhtml_xml;\n", + + "[Desktop Entry]\n" + "Version=1.0\n" + "Encoding=UTF-8\n" + "Name=GMail\n" + "Exec=/opt/google/chrome/google-chrome \"--app=http://gmail.com/\"\n" + "Terminal=false\n" + "Icon=/opt/google/chrome/product_logo_48.png\n" + "Type=Application\n" + "Categories=Application;Network;WebBrowser;\n" + "MimeType=text/html;text/xml;application/xhtml_xml;\n" + }, + + // Now we're starting to be more evil... + { "http://evil.com/evil --join-the-b0tnet", + "Ownz0red\nExec=rm -rf /", + + "Name=Google Chrome\n" + "Exec=/opt/google/chrome/google-chrome %U\n", + + "Name=http://evil.com/evil%20--join-the-b0tnet\n" + "Exec=/opt/google/chrome/google-chrome " + "\"--app=http://evil.com/evil%%20--join-the-b0tnet\"\n" + }, + }; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { + EXPECT_EQ(test_cases[i].expected_output, + ShellIntegration::GetDesktopFileContents( + test_cases[i].template_contents, + GURL(test_cases[i].url), + ASCIIToUTF16(test_cases[i].title))); + } +} +#endif // defined(OS_LINUX) |