OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/plugin_list.h" | 5 #include "content/common/plugin_list.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 return true; | 34 return true; |
35 } | 35 } |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 class PluginListTest : public testing::Test { | 41 class PluginListTest : public testing::Test { |
42 public: | 42 public: |
43 PluginListTest() | 43 PluginListTest() |
44 : foo_plugin_(ASCIIToUTF16(kFooName), | 44 : foo_plugin_(base::ASCIIToUTF16(kFooName), |
45 base::FilePath(kFooPath), | 45 base::FilePath(kFooPath), |
46 ASCIIToUTF16("1.2.3"), | 46 base::ASCIIToUTF16("1.2.3"), |
47 ASCIIToUTF16("foo")), | 47 base::ASCIIToUTF16("foo")), |
48 bar_plugin_(ASCIIToUTF16("Bar Plugin"), | 48 bar_plugin_(base::ASCIIToUTF16("Bar Plugin"), |
49 base::FilePath(kBarPath), | 49 base::FilePath(kBarPath), |
50 ASCIIToUTF16("2.3.4"), | 50 base::ASCIIToUTF16("2.3.4"), |
51 ASCIIToUTF16("bar")) { | 51 base::ASCIIToUTF16("bar")) { |
52 } | 52 } |
53 | 53 |
54 virtual void SetUp() { | 54 virtual void SetUp() { |
55 plugin_list_.DisablePluginsDiscovery(); | 55 plugin_list_.DisablePluginsDiscovery(); |
56 plugin_list_.RegisterInternalPlugin(bar_plugin_, false); | 56 plugin_list_.RegisterInternalPlugin(bar_plugin_, false); |
57 foo_plugin_.mime_types.push_back( | 57 foo_plugin_.mime_types.push_back( |
58 WebPluginMimeType(kFooMimeType, kFooFileType, std::string())); | 58 WebPluginMimeType(kFooMimeType, kFooFileType, std::string())); |
59 plugin_list_.RegisterInternalPlugin(foo_plugin_, false); | 59 plugin_list_.RegisterInternalPlugin(foo_plugin_, false); |
60 } | 60 } |
61 | 61 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 TEST(MIMEDescriptionParse, Simple) { | 142 TEST(MIMEDescriptionParse, Simple) { |
143 std::vector<WebPluginMimeType> types; | 143 std::vector<WebPluginMimeType> types; |
144 PluginList::ParseMIMEDescription( | 144 PluginList::ParseMIMEDescription( |
145 "audio/x-pn-realaudio-plugin:rpm:RealAudio document;", | 145 "audio/x-pn-realaudio-plugin:rpm:RealAudio document;", |
146 &types); | 146 &types); |
147 ASSERT_EQ(1U, types.size()); | 147 ASSERT_EQ(1U, types.size()); |
148 const WebPluginMimeType& type = types[0]; | 148 const WebPluginMimeType& type = types[0]; |
149 EXPECT_EQ("audio/x-pn-realaudio-plugin", type.mime_type); | 149 EXPECT_EQ("audio/x-pn-realaudio-plugin", type.mime_type); |
150 ASSERT_EQ(1U, type.file_extensions.size()); | 150 ASSERT_EQ(1U, type.file_extensions.size()); |
151 EXPECT_EQ("rpm", type.file_extensions[0]); | 151 EXPECT_EQ("rpm", type.file_extensions[0]); |
152 EXPECT_EQ(ASCIIToUTF16("RealAudio document"), type.description); | 152 EXPECT_EQ(base::ASCIIToUTF16("RealAudio document"), type.description); |
153 } | 153 } |
154 | 154 |
155 // Test parsing a multi-entry description: QuickTime as provided by Totem. | 155 // Test parsing a multi-entry description: QuickTime as provided by Totem. |
156 TEST(MIMEDescriptionParse, Multi) { | 156 TEST(MIMEDescriptionParse, Multi) { |
157 std::vector<WebPluginMimeType> types; | 157 std::vector<WebPluginMimeType> types; |
158 PluginList::ParseMIMEDescription( | 158 PluginList::ParseMIMEDescription( |
159 "video/quicktime:mov:QuickTime video;video/mp4:mp4:MPEG-4 " | 159 "video/quicktime:mov:QuickTime video;video/mp4:mp4:MPEG-4 " |
160 "video;image/x-macpaint:pntg:MacPaint Bitmap image;image/x" | 160 "video;image/x-macpaint:pntg:MacPaint Bitmap image;image/x" |
161 "-quicktime:pict, pict1, pict2:QuickTime image;video/x-m4v" | 161 "-quicktime:pict, pict1, pict2:QuickTime image;video/x-m4v" |
162 ":m4v:MPEG-4 video;", | 162 ":m4v:MPEG-4 video;", |
163 &types); | 163 &types); |
164 | 164 |
165 ASSERT_EQ(5U, types.size()); | 165 ASSERT_EQ(5U, types.size()); |
166 | 166 |
167 // Check the x-quicktime one, since it looks tricky with spaces in the | 167 // Check the x-quicktime one, since it looks tricky with spaces in the |
168 // extension list. | 168 // extension list. |
169 const WebPluginMimeType& type = types[3]; | 169 const WebPluginMimeType& type = types[3]; |
170 EXPECT_EQ("image/x-quicktime", type.mime_type); | 170 EXPECT_EQ("image/x-quicktime", type.mime_type); |
171 ASSERT_EQ(3U, type.file_extensions.size()); | 171 ASSERT_EQ(3U, type.file_extensions.size()); |
172 EXPECT_EQ("pict2", type.file_extensions[2]); | 172 EXPECT_EQ("pict2", type.file_extensions[2]); |
173 EXPECT_EQ(ASCIIToUTF16("QuickTime image"), type.description); | 173 EXPECT_EQ(base::ASCIIToUTF16("QuickTime image"), type.description); |
174 } | 174 } |
175 | 175 |
176 // Test parsing a Japanese description, since we got this wrong in the past. | 176 // Test parsing a Japanese description, since we got this wrong in the past. |
177 // This comes from loading Totem with LANG=ja_JP.UTF-8. | 177 // This comes from loading Totem with LANG=ja_JP.UTF-8. |
178 TEST(MIMEDescriptionParse, JapaneseUTF8) { | 178 TEST(MIMEDescriptionParse, JapaneseUTF8) { |
179 std::vector<WebPluginMimeType> types; | 179 std::vector<WebPluginMimeType> types; |
180 PluginList::ParseMIMEDescription( | 180 PluginList::ParseMIMEDescription( |
181 "audio/x-ogg:ogg:Ogg \xe3\x82\xaa\xe3\x83\xbc\xe3\x83\x87" | 181 "audio/x-ogg:ogg:Ogg \xe3\x82\xaa\xe3\x83\xbc\xe3\x83\x87" |
182 "\xe3\x82\xa3\xe3\x83\xaa", | 182 "\xe3\x82\xa3\xe3\x83\xaa", |
183 &types); | 183 &types); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 "1.2:class,jar:IcedTea;application/x-java-applet;version=1." | 215 "1.2:class,jar:IcedTea;application/x-java-applet;version=1." |
216 "2.1:class,jar:IcedTea;application/x-java-applet;version=1." | 216 "2.1:class,jar:IcedTea;application/x-java-applet;version=1." |
217 "2.2:class,jar:IcedTea;application/x-java-applet;version=1." | 217 "2.2:class,jar:IcedTea;application/x-java-applet;version=1." |
218 "3:class,jar:IcedTea;application/x-java-applet;version=1.3." | 218 "3:class,jar:IcedTea;application/x-java-applet;version=1.3." |
219 "1:class,jar:IcedTea;application/x-java-applet;version=1.4:" | 219 "1:class,jar:IcedTea;application/x-java-applet;version=1.4:" |
220 "class,jar:IcedTea", | 220 "class,jar:IcedTea", |
221 &types); | 221 &types); |
222 | 222 |
223 ASSERT_EQ(12U, types.size()); | 223 ASSERT_EQ(12U, types.size()); |
224 for (size_t i = 0; i < types.size(); ++i) | 224 for (size_t i = 0; i < types.size(); ++i) |
225 EXPECT_EQ(ASCIIToUTF16("IcedTea"), types[i].description); | 225 EXPECT_EQ(base::ASCIIToUTF16("IcedTea"), types[i].description); |
226 | 226 |
227 // Verify that the mime types with semis are coming through ok. | 227 // Verify that the mime types with semis are coming through ok. |
228 EXPECT_TRUE(types[4].mime_type.find(';') != std::string::npos); | 228 EXPECT_TRUE(types[4].mime_type.find(';') != std::string::npos); |
229 } | 229 } |
230 | 230 |
231 // Make sure we understand how to get the version numbers for common Linux | 231 // Make sure we understand how to get the version numbers for common Linux |
232 // plug-ins. | 232 // plug-ins. |
233 TEST(PluginDescriptionParse, ExtractVersion) { | 233 TEST(PluginDescriptionParse, ExtractVersion) { |
234 WebPluginInfo info; | 234 WebPluginInfo info; |
235 PluginList::ExtractVersionString("Shockwave Flash 10.1 r102", &info); | 235 PluginList::ExtractVersionString("Shockwave Flash 10.1 r102", &info); |
236 EXPECT_EQ(ASCIIToUTF16("10.1 r102"), info.version); | 236 EXPECT_EQ(base::ASCIIToUTF16("10.1 r102"), info.version); |
237 PluginList::ExtractVersionString("Java(TM) Plug-in 1.6.0_22", &info); | 237 PluginList::ExtractVersionString("Java(TM) Plug-in 1.6.0_22", &info); |
238 EXPECT_EQ(ASCIIToUTF16("1.6.0_22"), info.version); | 238 EXPECT_EQ(base::ASCIIToUTF16("1.6.0_22"), info.version); |
239 // It's actually much more likely for a modern Linux distribution to have | 239 // It's actually much more likely for a modern Linux distribution to have |
240 // IcedTea. | 240 // IcedTea. |
241 PluginList::ExtractVersionString( | 241 PluginList::ExtractVersionString( |
242 "IcedTea-Web Plugin " | 242 "IcedTea-Web Plugin " |
243 "(using IcedTea-Web 1.2 (1.2-2ubuntu0.10.04.2))", | 243 "(using IcedTea-Web 1.2 (1.2-2ubuntu0.10.04.2))", |
244 &info); | 244 &info); |
245 EXPECT_EQ(ASCIIToUTF16("1.2"), info.version); | 245 EXPECT_EQ(base::ASCIIToUTF16("1.2"), info.version); |
246 } | 246 } |
247 | 247 |
248 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) | 248 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
249 | 249 |
250 | 250 |
251 } // namespace content | 251 } // namespace content |
OLD | NEW |