Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / api / file_handlers / api_file_handler_util_unittest.cc
bloba4a8927d49b67d96fecb93a67d347fe4320b63af
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace extensions {
10 namespace app_file_handler_util {
11 namespace {
13 FileHandlerInfo CreateHandlerInfoFromExtension(const std::string& extension) {
14 FileHandlerInfo handler_info;
15 handler_info.extensions.insert(extension);
16 return handler_info;
21 TEST(FileHandlersAppFileHandlerUtilTest, FileHandlerCanHandleFile) {
22 // File handler for extension "gz" should accept "*.gz", including "*.tar.gz".
23 EXPECT_TRUE(FileHandlerCanHandleFile(
24 CreateHandlerInfoFromExtension("gz"),
25 "application/octet-stream",
26 base::FilePath::FromUTF8Unsafe("foo.gz")));
27 EXPECT_FALSE(FileHandlerCanHandleFile(
28 CreateHandlerInfoFromExtension("gz"),
29 "application/octet-stream",
30 base::FilePath::FromUTF8Unsafe("foo.tgz")));
31 EXPECT_TRUE(FileHandlerCanHandleFile(
32 CreateHandlerInfoFromExtension("gz"),
33 "application/octet-stream",
34 base::FilePath::FromUTF8Unsafe("foo.tar.gz")));
35 EXPECT_FALSE(FileHandlerCanHandleFile(
36 CreateHandlerInfoFromExtension("tar.gz"),
37 "application/octet-stream",
38 base::FilePath::FromUTF8Unsafe("foo.gz")));
39 EXPECT_TRUE(FileHandlerCanHandleFile(
40 CreateHandlerInfoFromExtension("tar.gz"),
41 "application/octet-stream",
42 base::FilePath::FromUTF8Unsafe("foo.tar.gz")));
45 } // namespace app_file_handler_util
46 } // namespace extensions