Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: webkit/glue/plugins/plugin_lib_unittest.cc

Issue 193046: linux: write a unit test for plugin mime parsing (Closed)
Patch Set: japanese Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webkit/glue/plugins/plugin_lib_linux.cc ('k') | webkit/tools/test_shell/test_shell.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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.
4
5 #include "webkit/glue/plugins/plugin_lib.h"
6
7 #include "build/build_config.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 #if defined(OS_LINUX)
11
12 // Test parsing a simple description: Real Audio.
13 TEST(MIMEDescriptionParse, Simple) {
14 std::vector<WebPluginMimeType> types;
15 ASSERT_TRUE(NPAPI::PluginLib::ParseMIMEDescription(
16 "audio/x-pn-realaudio-plugin:rpm:RealAudio document;",
17 &types));
18 ASSERT_EQ(1U, types.size());
19 const WebPluginMimeType& type = types[0];
20 EXPECT_EQ("audio/x-pn-realaudio-plugin", type.mime_type);
21 ASSERT_EQ(1U, type.file_extensions.size());
22 EXPECT_EQ("rpm", type.file_extensions[0]);
23 EXPECT_EQ(L"RealAudio document", type.description);
24 }
25
26 // Test parsing a multi-entry description: QuickTime as provided by Totem.
27 TEST(MIMEDescriptionParse, Multi) {
28 std::vector<WebPluginMimeType> types;
29 ASSERT_TRUE(NPAPI::PluginLib::ParseMIMEDescription(
30 "video/quicktime:mov:QuickTime video;video/mp4:mp4:MPEG-4 "
31 "video;image/x-macpaint:pntg:MacPaint Bitmap image;image/x"
32 "-quicktime:pict, pict1, pict2:QuickTime image;video/x-m4v"
33 ":m4v:MPEG-4 video;",
34 &types));
35
36 ASSERT_EQ(5U, types.size());
37
38 // Check the x-quicktime one, since it looks tricky with spaces in the
39 // extension list.
40 const WebPluginMimeType& type = types[3];
41 EXPECT_EQ("image/x-quicktime", type.mime_type);
42 ASSERT_EQ(3U, type.file_extensions.size());
43 EXPECT_EQ("pict2", type.file_extensions[2]);
44 EXPECT_EQ(L"QuickTime image", type.description);
45 }
46
47 // Test parsing a Japanese description, since we got this wrong in the past.
48 // This comes from loading Totem with LANG=ja_JP.UTF-8.
49 TEST(MIMEDescriptionParse, JapaneseUTF8) {
50 std::vector<WebPluginMimeType> types;
51 ASSERT_TRUE(NPAPI::PluginLib::ParseMIMEDescription(
52 "audio/x-ogg:ogg:Ogg \xe3\x82\xaa\xe3\x83\xbc\xe3\x83\x87"
53 "\xe3\x82\xa3\xe3\x83\xaa",
54 &types));
55
56 ASSERT_EQ(1U, types.size());
57 // Check we got the right number of Unicode characters out of the parse.
58 EXPECT_EQ(9U, types[0].description.size());
59 }
60
61 /*
62
63 TODO(evanm): write a test that covers the following, which does *not*
64 parse properly with the current code.
65
66 application/x-java-vm:class,jar:IcedTea;application/x-java-applet:class,jar:Iced Tea;application/x-java-applet;version=1.1:class,jar:IcedTea;application/x-java-a pplet;version=1.1.1:class,jar:IcedTea;application/x-java-applet;version=1.1.2:cl ass,jar:IcedTea;application/x-java-applet;version=1.1.3:class,jar:IcedTea;applic ation/x-java-applet;version=1.2:class,jar:IcedTea;application/x-java-applet;vers ion=1.2.1:class,jar:IcedTea;application/x-java-applet;version=1.2.2:class,jar:Ic edTea;application/x-java-applet;version=1.3:class,jar:IcedTea;application/x-java -applet;version=1.3.1:class,jar:IcedTea;application/x-java-applet;version=1.4:cl ass,jar:IcedTea
67 */
68
69
70 #endif // defined(OS_LINUX)
71
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_lib_linux.cc ('k') | webkit/tools/test_shell/test_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698