| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "webkit/plugins/npapi/mock_plugin_list.h" | 9 #include "webkit/plugins/npapi/mock_plugin_list.h" |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 EXPECT_FALSE(bar_group->Enabled()); | 91 EXPECT_FALSE(bar_group->Enabled()); |
| 92 } | 92 } |
| 93 | 93 |
| 94 TEST_F(PluginListTest, EmptyGroup) { | 94 TEST_F(PluginListTest, EmptyGroup) { |
| 95 std::vector<PluginGroup> groups; | 95 std::vector<PluginGroup> groups; |
| 96 plugin_list_.GetPluginGroups(false, &groups); | 96 plugin_list_.GetPluginGroups(false, &groups); |
| 97 for (size_t i = 0; i < groups.size(); ++i) | 97 for (size_t i = 0; i < groups.size(); ++i) |
| 98 EXPECT_GE(1U, groups[i].web_plugins_info().size()); | 98 EXPECT_GE(1U, groups[i].web_plugins_info().size()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TEST_F(PluginListTest, DisableOutdated) { | |
| 102 VersionRangeDefinition version_range[] = { | |
| 103 { "0", "4", "3.0.44" }, | |
| 104 { "4", "5", "" } | |
| 105 }; | |
| 106 WebPluginInfo plugin_3043(ASCIIToUTF16("MyPlugin"), | |
| 107 FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), | |
| 108 ASCIIToUTF16("3.0.43"), | |
| 109 ASCIIToUTF16("MyPlugin version 3.0.43")); | |
| 110 WebPluginInfo plugin_3045(ASCIIToUTF16("MyPlugin"), | |
| 111 FilePath(FILE_PATH_LITERAL("/myplugin.3.0.45")), | |
| 112 ASCIIToUTF16("3.0.45"), | |
| 113 ASCIIToUTF16("MyPlugin version 3.0.45")); | |
| 114 plugin_list_.ClearPluginsToLoad(); | |
| 115 plugin_list_.AddPluginToLoad(plugin_3043); | |
| 116 plugin_list_.AddPluginToLoad(plugin_3045); | |
| 117 // Enfore the load to run. | |
| 118 plugin_list_.RefreshPlugins(); | |
| 119 std::vector<WebPluginInfo> plugins; | |
| 120 plugin_list_.GetPlugins(&plugins); | |
| 121 PluginGroup* group_3043 = | |
| 122 const_cast<PluginGroup*>(plugin_list_.GetPluginGroup(plugin_3043)); | |
| 123 const PluginGroup* group_3045 = plugin_list_.GetPluginGroup(plugin_3045); | |
| 124 EXPECT_EQ(group_3043, group_3045); | |
| 125 group_3043->version_ranges_.push_back(VersionRange(version_range[0])); | |
| 126 group_3043->version_ranges_.push_back(VersionRange(version_range[1])); | |
| 127 EXPECT_EQ(plugin_3043.desc, group_3043->description()); | |
| 128 EXPECT_TRUE(group_3043->IsVulnerable()); | |
| 129 group_3043->DisableOutdatedPlugins(); | |
| 130 EXPECT_EQ(plugin_3045.desc, group_3043->description()); | |
| 131 EXPECT_FALSE(group_3043->IsVulnerable()); | |
| 132 } | |
| 133 | |
| 134 TEST_F(PluginListTest, BadPluginDescription) { | 101 TEST_F(PluginListTest, BadPluginDescription) { |
| 135 WebPluginInfo plugin_3043(ASCIIToUTF16(""), | 102 WebPluginInfo plugin_3043(ASCIIToUTF16(""), |
| 136 FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), | 103 FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), |
| 137 ASCIIToUTF16(""), | 104 ASCIIToUTF16(""), |
| 138 ASCIIToUTF16("")); | 105 ASCIIToUTF16("")); |
| 139 // Simulate loading of the plugins. | 106 // Simulate loading of the plugins. |
| 140 plugin_list_.ClearPluginsToLoad(); | 107 plugin_list_.ClearPluginsToLoad(); |
| 141 plugin_list_.AddPluginToLoad(plugin_3043); | 108 plugin_list_.AddPluginToLoad(plugin_3043); |
| 142 // Now we should have them in the state we specified above. | 109 // Now we should have them in the state we specified above. |
| 143 plugin_list_.RefreshPlugins(); | 110 plugin_list_.RefreshPlugins(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 161 |
| 195 plugin_list_.RefreshPlugins(); | 162 plugin_list_.RefreshPlugins(); |
| 196 std::vector<WebPluginInfo> plugins; | 163 std::vector<WebPluginInfo> plugins; |
| 197 plugin_list_.GetPlugins(&plugins); | 164 plugin_list_.GetPlugins(&plugins); |
| 198 ASSERT_EQ(2u, plugins.size()); | 165 ASSERT_EQ(2u, plugins.size()); |
| 199 ASSERT_EQ(WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED, plugins[0].enabled); | 166 ASSERT_EQ(WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED, plugins[0].enabled); |
| 200 } | 167 } |
| 201 | 168 |
| 202 } // namespace npapi | 169 } // namespace npapi |
| 203 } // namespace webkit | 170 } // namespace webkit |
| OLD | NEW |