| Index: extensions/utility/unpacker_unittest.cc
|
| diff --git a/extensions/utility/unpacker_unittest.cc b/extensions/utility/unpacker_unittest.cc
|
| index 8954b1846bcd41cc2435017c7b46fb93b305b907..25dc87946688194f2f01a0a2ddbb9ce8d6ad73d1 100644
|
| --- a/extensions/utility/unpacker_unittest.cc
|
| +++ b/extensions/utility/unpacker_unittest.cc
|
| @@ -195,4 +195,38 @@ TEST_F(UnpackerTest, ImageDecodingError) {
|
| << unpacker_->error_message() << "\"";
|
| }
|
|
|
| +base::FilePath CreateEmptyTestFile(const base::FilePath& test_dir,
|
| + const base::FilePath& file_path) {
|
| + base::FilePath test_file(test_dir.Append(file_path));
|
| + base::FilePath temp_file;
|
| + EXPECT_TRUE(base::CreateTemporaryFileInDir(test_dir, &temp_file));
|
| + EXPECT_TRUE(base::Move(temp_file, test_file));
|
| + return test_file;
|
| +}
|
| +
|
| +TEST_F(UnpackerTest, BlockedFileTypes) {
|
| + const struct {
|
| + const base::FilePath::CharType* input;
|
| + bool expected;
|
| + } cases[] = {
|
| + {FILE_PATH_LITERAL("foo"), true},
|
| + {FILE_PATH_LITERAL("foo.nexe"), true},
|
| + {FILE_PATH_LITERAL("foo.dll"), true},
|
| + {FILE_PATH_LITERAL("foo.jpg.exe"), false},
|
| + {FILE_PATH_LITERAL("foo.exe"), false},
|
| + {FILE_PATH_LITERAL("foo.EXE"), false},
|
| + };
|
| +
|
| + base::ScopedTempDir temp_dir;
|
| + ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
|
| +
|
| + for (size_t i = 0; i < arraysize(cases); ++i) {
|
| + base::FilePath input(cases[i].input);
|
| + base::FilePath test_file(CreateEmptyTestFile(temp_dir.path(), input));
|
| + bool observed = Unpacker::ShouldExtractFile(test_file);
|
| + EXPECT_EQ(cases[i].expected, observed) << "i: " << i
|
| + << ", input: " << test_file.value();
|
| + }
|
| +}
|
| +
|
| } // namespace extensions
|
|
|