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
: public testing::Test
,
19 public BrowserPpapiHostTest
{
21 PepperFileSystemBrowserHostTest() {}
22 virtual ~PepperFileSystemBrowserHostTest() {}
24 virtual void SetUp() OVERRIDE
{
25 PP_Instance pp_instance
= 12345;
26 PP_Resource pp_resource
= 67890;
27 host_
.reset(new PepperFileSystemBrowserHost(GetBrowserPpapiHost(),
30 PP_FILESYSTEMTYPE_ISOLATED
));
33 virtual void TearDown() OVERRIDE
{ host_
.reset(); }
36 std::string
GeneratePluginId(const std::string
& mime_type
) {
37 return host_
->GeneratePluginId(mime_type
);
41 scoped_ptr
<PepperFileSystemBrowserHost
> host_
;
43 DISALLOW_COPY_AND_ASSIGN(PepperFileSystemBrowserHostTest
);
46 TEST_F(PepperFileSystemBrowserHostTest
, GeneratePluginId
) {
47 // Should not contain wild card characters.
48 EXPECT_TRUE(GeneratePluginId("*").empty());
49 EXPECT_TRUE(GeneratePluginId("*/*").empty());
51 // Should contain only one slash.
52 EXPECT_TRUE(GeneratePluginId(".").empty());
53 EXPECT_TRUE(GeneratePluginId("..").empty());
54 EXPECT_TRUE(GeneratePluginId("application").empty());
55 EXPECT_TRUE(GeneratePluginId("application/mime/type").empty());
57 // Should start with "legal_top_level_types"
58 // (ex. "application", "audio", "x-"). See "mime_util.cc" for more details.
59 EXPECT_TRUE(GeneratePluginId("/mime").empty());
60 EXPECT_TRUE(GeneratePluginId("./mime").empty());
61 EXPECT_TRUE(GeneratePluginId("../mime").empty());
62 EXPECT_TRUE(GeneratePluginId("app/mime").empty());
64 // Should not contain characters other than alphanumeric or "._-".
65 EXPECT_TRUE(GeneratePluginId("application/mime+type").empty());
66 EXPECT_TRUE(GeneratePluginId("application/mime:type").empty());
67 EXPECT_TRUE(GeneratePluginId("application/mime;type").empty());
70 EXPECT_EQ("application_mime", GeneratePluginId("application/mime"));
71 EXPECT_EQ("x-app_mime", GeneratePluginId("x-app/mime"));
72 EXPECT_EQ("application_mime.type", GeneratePluginId("application/mime.type"));
73 EXPECT_EQ("application_mime_type", GeneratePluginId("application/mime_type"));
74 EXPECT_EQ("application_mime-type", GeneratePluginId("application/mime-type"));
75 EXPECT_EQ("application_..", GeneratePluginId("application/.."));
78 } // namespace content