diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 00:38:27 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-19 00:38:27 +0000 |
commit | 08ae5f310a475f73807df520fa0b50cf7138c4f5 (patch) | |
tree | 981539c905895229315a315646415dd473b2219c | |
parent | 95d3e0c768b1f9fe7d1a9e052294674a76153664 (diff) | |
download | chromium_src-08ae5f310a475f73807df520fa0b50cf7138c4f5.zip chromium_src-08ae5f310a475f73807df520fa0b50cf7138c4f5.tar.gz chromium_src-08ae5f310a475f73807df520fa0b50cf7138c4f5.tar.bz2 |
add unit test for ExtensionURLToRelativeFilePath
BUG=30749
TEST=this patch
Review URL: http://codereview.chromium.org/507054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35013 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/extension_file_util_unittest.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_file_util_unittest.cc b/chrome/browser/extensions/extension_file_util_unittest.cc index 675914d..6266c22 100644 --- a/chrome/browser/extensions/extension_file_util_unittest.cc +++ b/chrome/browser/extensions/extension_file_util_unittest.cc @@ -254,6 +254,39 @@ TEST(ExtensionFileUtil, InvalidPrivacyBlacklist) { "Incorrect header.")) << error; } +#define URL_PREFIX "chrome-extension://extension-id/" + +TEST(ExtensionFileUtil, ExtensionURLToRelativeFilePath) { + struct TestCase { + const char* url; + const char* expected_relative_path; + } test_cases[] = { + { URL_PREFIX "simple.html", + "simple.html" }, + { URL_PREFIX "directory/to/file.html", + "directory/to/file.html" }, + { URL_PREFIX "escape%20spaces.html", + "escape spaces.html" }, + { URL_PREFIX "%C3%9Cber.html", + "\xC3\x9C" "ber.html" }, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { + GURL url(test_cases[i].url); +#if defined(OS_POSIX) + FilePath expected_path(test_cases[i].expected_relative_path); +#elif defined(OS_WIN) + FilePath expected_path(UTF8ToWide(test_cases[i].expected_relative_path)); +#endif + + FilePath actual_path = + extension_file_util::ExtensionURLToRelativeFilePath(url); + EXPECT_FALSE(actual_path.IsAbsolute()) << + " For the path " << actual_path.value(); + EXPECT_EQ(expected_path.value(), actual_path.value()); + } +} + // TODO(aa): More tests as motivation allows. Maybe steal some from // ExtensionsService? Many of them could probably be tested here without the // MessageLoop shenanigans. |