1 // Copyright 2013 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 "content/browser/renderer_host/pepper/pepper_file_system_browser_host.h"
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_resource.h"
14 #include "testing/gtest/include/gtest/gtest.h"
18 class PepperFileSystemBrowserHostTest
19 : public testing::Test
,
20 public BrowserPpapiHostTest
{
22 PepperFileSystemBrowserHostTest() {}
23 virtual ~PepperFileSystemBrowserHostTest() {}
25 virtual void SetUp() OVERRIDE
{
26 PP_Instance pp_instance
= 12345;
27 PP_Resource pp_resource
= 67890;
28 host_
.reset(new PepperFileSystemBrowserHost(
29 GetBrowserPpapiHost(), pp_instance
, pp_resource
,
30 PP_FILESYSTEMTYPE_ISOLATED
));
33 virtual void TearDown() OVERRIDE
{
38 std::string
GeneratePluginId(const std::string
& mime_type
) {
39 return host_
->GeneratePluginId(mime_type
);
43 scoped_ptr
<PepperFileSystemBrowserHost
> host_
;
45 DISALLOW_COPY_AND_ASSIGN(PepperFileSystemBrowserHostTest
);
48 TEST_F(PepperFileSystemBrowserHostTest
, GeneratePluginId
) {
49 // Should not contain wild card characters.
50 EXPECT_TRUE(GeneratePluginId("*").empty());
51 EXPECT_TRUE(GeneratePluginId("*/*").empty());
53 // Should contain only one slash.
54 EXPECT_TRUE(GeneratePluginId(".").empty());
55 EXPECT_TRUE(GeneratePluginId("..").empty());
56 EXPECT_TRUE(GeneratePluginId("application").empty());
57 EXPECT_TRUE(GeneratePluginId("application/mime/type").empty());
59 // Should start with "legal_top_level_types"
60 // (ex. "application", "audio", "x-"). See "mime_util.cc" for more details.
61 EXPECT_TRUE(GeneratePluginId("/mime").empty());
62 EXPECT_TRUE(GeneratePluginId("./mime").empty());
63 EXPECT_TRUE(GeneratePluginId("../mime").empty());
64 EXPECT_TRUE(GeneratePluginId("app/mime").empty());
66 // Should not contain characters other than alphanumeric or "._-".
67 EXPECT_TRUE(GeneratePluginId("application/mime+type").empty());
68 EXPECT_TRUE(GeneratePluginId("application/mime:type").empty());
69 EXPECT_TRUE(GeneratePluginId("application/mime;type").empty());
72 EXPECT_EQ("application_mime", GeneratePluginId("application/mime"));
73 EXPECT_EQ("x-app_mime", GeneratePluginId("x-app/mime"));
74 EXPECT_EQ("application_mime.type", GeneratePluginId("application/mime.type"));
75 EXPECT_EQ("application_mime_type", GeneratePluginId("application/mime_type"));
76 EXPECT_EQ("application_mime-type", GeneratePluginId("application/mime-type"));
77 EXPECT_EQ("application_..", GeneratePluginId("application/.."));
80 } // namespace content