| 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/string16.h" |
| 7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "webkit/plugins/npapi/mock_plugin_list.h" | 10 #include "webkit/plugins/npapi/mock_plugin_list.h" |
| 10 | 11 |
| 11 namespace webkit { | 12 namespace webkit { |
| 12 namespace npapi { | 13 namespace npapi { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 bool Equals(const WebPluginInfo& a, const WebPluginInfo& b) { | 17 bool Equals(const WebPluginInfo& a, const WebPluginInfo& b) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 90 } |
| 90 | 91 |
| 91 TEST_F(PluginListTest, EmptyGroup) { | 92 TEST_F(PluginListTest, EmptyGroup) { |
| 92 std::vector<PluginGroup> groups; | 93 std::vector<PluginGroup> groups; |
| 93 plugin_list_.GetPluginGroups(false, &groups); | 94 plugin_list_.GetPluginGroups(false, &groups); |
| 94 for (size_t i = 0; i < groups.size(); ++i) | 95 for (size_t i = 0; i < groups.size(); ++i) |
| 95 EXPECT_GE(1U, groups[i].web_plugin_infos().size()); | 96 EXPECT_GE(1U, groups[i].web_plugin_infos().size()); |
| 96 } | 97 } |
| 97 | 98 |
| 98 TEST_F(PluginListTest, BadPluginDescription) { | 99 TEST_F(PluginListTest, BadPluginDescription) { |
| 99 WebPluginInfo plugin_3043(ASCIIToUTF16(""), | 100 WebPluginInfo plugin_3043( |
| 100 FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), | 101 string16(), FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), |
| 101 ASCIIToUTF16(""), | 102 string16(), string16()); |
| 102 ASCIIToUTF16("")); | |
| 103 // Simulate loading of the plugins. | 103 // Simulate loading of the plugins. |
| 104 plugin_list_.ClearPluginsToLoad(); | 104 plugin_list_.ClearPluginsToLoad(); |
| 105 plugin_list_.AddPluginToLoad(plugin_3043); | 105 plugin_list_.AddPluginToLoad(plugin_3043); |
| 106 // Now we should have them in the state we specified above. | 106 // Now we should have them in the state we specified above. |
| 107 plugin_list_.RefreshPlugins(); | 107 plugin_list_.RefreshPlugins(); |
| 108 std::vector<WebPluginInfo> plugins; | 108 std::vector<WebPluginInfo> plugins; |
| 109 plugin_list_.GetPlugins(&plugins); | 109 plugin_list_.GetPlugins(&plugins); |
| 110 ASSERT_TRUE(Contains(plugins, plugin_3043)); | 110 ASSERT_TRUE(Contains(plugins, plugin_3043)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 TEST_F(PluginListTest, HardcodedGroups) { | 113 TEST_F(PluginListTest, HardcodedGroups) { |
| 114 std::vector<PluginGroup> groups; | 114 std::vector<PluginGroup> groups; |
| 115 plugin_list_.GetPluginGroups(true, &groups); | 115 plugin_list_.GetPluginGroups(true, &groups); |
| 116 ASSERT_EQ(2u, groups.size()); | 116 ASSERT_EQ(2u, groups.size()); |
| 117 EXPECT_EQ(1u, groups[0].web_plugin_infos().size()); | 117 EXPECT_EQ(1u, groups[0].web_plugin_infos().size()); |
| 118 EXPECT_TRUE(groups[0].ContainsPlugin(FilePath(kBarPath))); | 118 EXPECT_TRUE(groups[0].ContainsPlugin(FilePath(kBarPath))); |
| 119 EXPECT_EQ("bar.plugin", groups[0].identifier()); | 119 EXPECT_EQ("bar.plugin", groups[0].identifier()); |
| 120 EXPECT_EQ(1u, groups[1].web_plugin_infos().size()); | 120 EXPECT_EQ(1u, groups[1].web_plugin_infos().size()); |
| 121 EXPECT_TRUE(groups[1].ContainsPlugin(FilePath(kFooPath))); | 121 EXPECT_TRUE(groups[1].ContainsPlugin(FilePath(kFooPath))); |
| 122 EXPECT_EQ(kFooIdentifier, groups[1].identifier()); | 122 EXPECT_EQ(kFooIdentifier, groups[1].identifier()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 } // namespace npapi | 125 } // namespace npapi |
| 126 } // namespace webkit | 126 } // namespace webkit |
| OLD | NEW |