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

Side by Side Diff: webkit/plugins/npapi/plugin_list_unittest.cc

Issue 19706002: Remove plugin_list.h includes from chrome tests in preparation for moving webkit/plugins to content… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix posix tests Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/npapi/plugin_list.h ('k') | webkit/plugins/webkit_plugins.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webkit/plugins/npapi/plugin_list.h" 5 #include "webkit/plugins/npapi/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 "webkit/plugins/npapi/mock_plugin_list.h"
11 10
12 namespace webkit { 11 namespace webkit {
13 namespace npapi { 12 namespace npapi {
14 13
15 namespace { 14 namespace {
16 15
17 bool Equals(const WebPluginInfo& a, const WebPluginInfo& b) { 16 bool Equals(const WebPluginInfo& a, const WebPluginInfo& b) {
18 return (a.name == b.name && 17 return (a.name == b.name &&
19 a.path == b.path && 18 a.path == b.path &&
20 a.version == b.version && 19 a.version == b.version &&
21 a.desc == b.desc); 20 a.desc == b.desc);
22 } 21 }
23 22
24 bool Contains(const std::vector<WebPluginInfo>& list, 23 bool Contains(const std::vector<WebPluginInfo>& list,
25 const WebPluginInfo& plugin) { 24 const WebPluginInfo& plugin) {
26 for (std::vector<WebPluginInfo>::const_iterator it = list.begin(); 25 for (std::vector<WebPluginInfo>::const_iterator it = list.begin();
27 it != list.end(); ++it) { 26 it != list.end(); ++it) {
28 if (Equals(*it, plugin)) 27 if (Equals(*it, plugin))
29 return true; 28 return true;
30 } 29 }
31 return false; 30 return false;
32 } 31 }
33 32
33 } // namespace
34
35 // Linux Aura doesn't support NPAPI.
36 #if !(defined(OS_LINUX) && defined(USE_AURA))
37
34 base::FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin"); 38 base::FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin");
35 base::FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin"); 39 base::FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin");
36 const char* kFooName = "Foo Plugin"; 40 const char* kFooName = "Foo Plugin";
37 41
38 } // namespace
39
40 class PluginListTest : public testing::Test { 42 class PluginListTest : public testing::Test {
41 public: 43 public:
42 PluginListTest() 44 PluginListTest()
43 : foo_plugin_(ASCIIToUTF16(kFooName), 45 : foo_plugin_(ASCIIToUTF16(kFooName),
44 base::FilePath(kFooPath), 46 base::FilePath(kFooPath),
45 ASCIIToUTF16("1.2.3"), 47 ASCIIToUTF16("1.2.3"),
46 ASCIIToUTF16("foo")), 48 ASCIIToUTF16("foo")),
47 bar_plugin_(ASCIIToUTF16("Bar Plugin"), 49 bar_plugin_(ASCIIToUTF16("Bar Plugin"),
48 base::FilePath(kBarPath), 50 base::FilePath(kBarPath),
49 ASCIIToUTF16("2.3.4"), 51 ASCIIToUTF16("2.3.4"),
50 ASCIIToUTF16("bar")) { 52 ASCIIToUTF16("bar")) {
51 } 53 }
52 54
53 virtual void SetUp() { 55 virtual void SetUp() {
54 plugin_list_.AddPluginToLoad(bar_plugin_); 56 plugin_list_.DisablePluginsDiscovery();
55 plugin_list_.AddPluginToLoad(foo_plugin_); 57 plugin_list_.RegisterInternalPlugin(bar_plugin_, false);
58 plugin_list_.RegisterInternalPlugin(foo_plugin_, false);
56 } 59 }
57 60
58 protected: 61 protected:
59 MockPluginList plugin_list_; 62 PluginList plugin_list_;
60 WebPluginInfo foo_plugin_; 63 WebPluginInfo foo_plugin_;
61 WebPluginInfo bar_plugin_; 64 WebPluginInfo bar_plugin_;
62 }; 65 };
63 66
64 TEST_F(PluginListTest, GetPlugins) { 67 TEST_F(PluginListTest, GetPlugins) {
65 std::vector<WebPluginInfo> plugins; 68 std::vector<WebPluginInfo> plugins;
66 plugin_list_.GetPlugins(&plugins); 69 plugin_list_.GetPlugins(&plugins);
67 EXPECT_EQ(2u, plugins.size()); 70 EXPECT_EQ(2u, plugins.size());
68 EXPECT_TRUE(Contains(plugins, foo_plugin_)); 71 EXPECT_TRUE(Contains(plugins, foo_plugin_));
69 EXPECT_TRUE(Contains(plugins, bar_plugin_)); 72 EXPECT_TRUE(Contains(plugins, bar_plugin_));
70 } 73 }
71 74
72 TEST_F(PluginListTest, BadPluginDescription) { 75 TEST_F(PluginListTest, BadPluginDescription) {
73 WebPluginInfo plugin_3043( 76 WebPluginInfo plugin_3043(
74 base::string16(), base::FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), 77 base::string16(), base::FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")),
75 base::string16(), base::string16()); 78 base::string16(), base::string16());
76 // Simulate loading of the plugins. 79 // Simulate loading of the plugins.
77 plugin_list_.ClearPluginsToLoad(); 80 plugin_list_.RegisterInternalPlugin(plugin_3043, false);
78 plugin_list_.AddPluginToLoad(plugin_3043);
79 // Now we should have them in the state we specified above. 81 // Now we should have them in the state we specified above.
80 plugin_list_.RefreshPlugins(); 82 plugin_list_.RefreshPlugins();
81 std::vector<WebPluginInfo> plugins; 83 std::vector<WebPluginInfo> plugins;
82 plugin_list_.GetPlugins(&plugins); 84 plugin_list_.GetPlugins(&plugins);
83 ASSERT_TRUE(Contains(plugins, plugin_3043)); 85 ASSERT_TRUE(Contains(plugins, plugin_3043));
84 } 86 }
85 87
88 #endif
89
86 #if defined(OS_POSIX) && !defined(OS_MACOSX) 90 #if defined(OS_POSIX) && !defined(OS_MACOSX)
87 91
88 // Test parsing a simple description: Real Audio. 92 // Test parsing a simple description: Real Audio.
89 TEST(MIMEDescriptionParse, Simple) { 93 TEST(MIMEDescriptionParse, Simple) {
90 std::vector<WebPluginMimeType> types; 94 std::vector<WebPluginMimeType> types;
91 PluginList::ParseMIMEDescription( 95 PluginList::ParseMIMEDescription(
92 "audio/x-pn-realaudio-plugin:rpm:RealAudio document;", 96 "audio/x-pn-realaudio-plugin:rpm:RealAudio document;",
93 &types); 97 &types);
94 ASSERT_EQ(1U, types.size()); 98 ASSERT_EQ(1U, types.size());
95 const WebPluginMimeType& type = types[0]; 99 const WebPluginMimeType& type = types[0];
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 "(using IcedTea-Web 1.2 (1.2-2ubuntu0.10.04.2))", 194 "(using IcedTea-Web 1.2 (1.2-2ubuntu0.10.04.2))",
191 &info); 195 &info);
192 EXPECT_EQ(ASCIIToUTF16("1.2"), info.version); 196 EXPECT_EQ(ASCIIToUTF16("1.2"), info.version);
193 } 197 }
194 198
195 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 199 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
196 200
197 201
198 } // namespace npapi 202 } // namespace npapi
199 } // namespace webkit 203 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_list.h ('k') | webkit/plugins/webkit_plugins.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698