| 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_group.h" | 5 #include "webkit/plugins/npapi/plugin_group.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 TEST_F(PluginGroupTest, PluginGroupDefinition) { | 168 TEST_F(PluginGroupTest, PluginGroupDefinition) { |
| 169 for (size_t i = 0; i < arraysize(kPluginDefinitions); ++i) { | 169 for (size_t i = 0; i < arraysize(kPluginDefinitions); ++i) { |
| 170 scoped_ptr<PluginGroup> def_group( | 170 scoped_ptr<PluginGroup> def_group( |
| 171 PluginGroupTest::CreatePluginGroup(kPluginDefinitions[i])); | 171 PluginGroupTest::CreatePluginGroup(kPluginDefinitions[i])); |
| 172 ASSERT_TRUE(def_group.get() != NULL); | 172 ASSERT_TRUE(def_group.get() != NULL); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 TEST_F(PluginGroupTest, DisableOutdated) { | |
| 177 PluginGroupDefinition plugindefs[] = { kPluginDef3, kPluginDef34 }; | |
| 178 for (size_t i = 0; i < 2; ++i) { | |
| 179 scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( | |
| 180 plugindefs[i])); | |
| 181 group->AddPlugin(kPlugin3043); | |
| 182 group->AddPlugin(kPlugin3045); | |
| 183 | |
| 184 EXPECT_EQ(ASCIIToUTF16("MyPlugin version 3.0.43"), group->description()); | |
| 185 EXPECT_TRUE(group->IsVulnerable()); | |
| 186 | |
| 187 group->DisableOutdatedPlugins(); | |
| 188 EXPECT_EQ(ASCIIToUTF16("MyPlugin version 3.0.45"), group->description()); | |
| 189 EXPECT_FALSE(group->IsVulnerable()); | |
| 190 } | |
| 191 } | |
| 192 | |
| 193 TEST_F(PluginGroupTest, VersionExtraction) { | 176 TEST_F(PluginGroupTest, VersionExtraction) { |
| 194 // Some real-world plugin versions (spaces, commata, parentheses, 'r', oh my) | 177 // Some real-world plugin versions (spaces, commata, parentheses, 'r', oh my) |
| 195 const char* versions[][2] = { | 178 const char* versions[][2] = { |
| 196 { "7.6.6 (1671)", "7.6.6.1671" }, // Quicktime | 179 { "7.6.6 (1671)", "7.6.6.1671" }, // Quicktime |
| 197 { "2, 0, 0, 254", "2.0.0.254" }, // DivX | 180 { "2, 0, 0, 254", "2.0.0.254" }, // DivX |
| 198 { "3, 0, 0, 0", "3.0.0.0" }, // Picasa | 181 { "3, 0, 0, 0", "3.0.0.0" }, // Picasa |
| 199 { "1, 0, 0, 1", "1.0.0.1" }, // Earth | 182 { "1, 0, 0, 1", "1.0.0.1" }, // Earth |
| 200 { "10,0,45,2", "10.0.45.2" }, // Flash | 183 { "10,0,45,2", "10.0.45.2" }, // Flash |
| 201 { "10.1 r102", "10.1.102"}, // Flash | 184 { "10.1 r102", "10.1.102"}, // Flash |
| 202 { "10.3 d180", "10.3.180" }, // Flash (Debug) | 185 { "10.3 d180", "10.3.180" }, // Flash (Debug) |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 EXPECT_EQ(kPlugin3043.desc, group->description()); | 389 EXPECT_EQ(kPlugin3043.desc, group->description()); |
| 407 EXPECT_TRUE(group->IsVulnerable()); | 390 EXPECT_TRUE(group->IsVulnerable()); |
| 408 | 391 |
| 409 EXPECT_TRUE(group->RemovePlugin(kPlugin3043.path)); | 392 EXPECT_TRUE(group->RemovePlugin(kPlugin3043.path)); |
| 410 EXPECT_TRUE(group->IsEmpty()); | 393 EXPECT_TRUE(group->IsEmpty()); |
| 411 EXPECT_EQ(string16(), group->description()); | 394 EXPECT_EQ(string16(), group->description()); |
| 412 } | 395 } |
| 413 | 396 |
| 414 } // namespace npapi | 397 } // namespace npapi |
| 415 } // namespace webkit | 398 } // namespace webkit |
| OLD | NEW |