diff options
author | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 17:37:12 +0000 |
---|---|---|
committer | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-24 17:37:12 +0000 |
commit | b83ff229cfe2c15a6dab2278acf7d328645470a5 (patch) | |
tree | a1b9183bbb3c9aaa91364b5e15c22115336b9786 /webkit/plugins/npapi/plugin_group_unittest.cc | |
parent | 77d13338e12da7ac2c177f4da53b9293850ff357 (diff) | |
download | chromium_src-b83ff229cfe2c15a6dab2278acf7d328645470a5.zip chromium_src-b83ff229cfe2c15a6dab2278acf7d328645470a5.tar.gz chromium_src-b83ff229cfe2c15a6dab2278acf7d328645470a5.tar.bz2 |
Refactor the plugin lists handling code.
Effects of this refactor:
1. The WebPluginInfo now keep information not only if a plugin is disabled but also the reason for that. It can either be user, policy or both. That way we can restore the right value after policies stop to control the feature.
2. Plugins can be correctly enabled and disabled either as a group or separately.
3. The code is cleaner and PluginGroup is not duplicating information from PluginList but stores all needed information and provides it through cleaner interface.
BUG=54681,66505,69374,69148
TEST=Manual for the policy. DefaultPluginUITest.DefaultPluginLoadTest from ui_tests and Plugin* from test_shell_tests.
Review URL: http://codereview.chromium.org/5699005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/npapi/plugin_group_unittest.cc')
-rw-r--r-- | webkit/plugins/npapi/plugin_group_unittest.cc | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/webkit/plugins/npapi/plugin_group_unittest.cc b/webkit/plugins/npapi/plugin_group_unittest.cc index 6fc3db2..a4ea89b 100644 --- a/webkit/plugins/npapi/plugin_group_unittest.cc +++ b/webkit/plugins/npapi/plugin_group_unittest.cc @@ -92,7 +92,7 @@ TEST(PluginGroupTest, PluginGroupMatch) { EXPECT_TRUE(group->Match(kPlugin3045)); EXPECT_TRUE(group->Match(kPlugin3045r)); EXPECT_FALSE(group->Match(kPluginNoVersion)); - group->AddPlugin(kPlugin3045, 0); + group->AddPlugin(kPlugin3045); EXPECT_FALSE(group->IsVulnerable()); group.reset(PluginGroupTest::CreatePluginGroup(kPluginDef)); @@ -130,42 +130,26 @@ TEST(PluginGroupTest, PluginGroupDescription) { scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( plugindefs[i])); EXPECT_TRUE(group->Match(plugin3043)); - group->AddPlugin(plugin3043, 0); + group->AddPlugin(plugin3043); EXPECT_EQ(desc3043, group->description()); EXPECT_TRUE(group->IsVulnerable()); EXPECT_TRUE(group->Match(plugin3045)); - group->AddPlugin(plugin3045, 1); + group->AddPlugin(plugin3045); EXPECT_EQ(desc3043, group->description()); EXPECT_TRUE(group->IsVulnerable()); } - - { - // Disable the first plugin. - plugin3043.enabled = false; - scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( - plugindefs[i])); - EXPECT_TRUE(group->Match(plugin3043)); - group->AddPlugin(plugin3043, 0); - EXPECT_EQ(desc3043, group->description()); - EXPECT_TRUE(group->IsVulnerable()); - EXPECT_FALSE(group->Enabled()); - EXPECT_TRUE(group->Match(plugin3045)); - group->AddPlugin(plugin3045, 1); - EXPECT_EQ(desc3045, group->description()); - EXPECT_FALSE(group->IsVulnerable()); - } - { // Disable the second plugin. - plugin3045.enabled = false; + plugin3045.enabled = + webkit::npapi::WebPluginInfo::USER_DISABLED_POLICY_UNMANAGED; scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( plugindefs[i])); EXPECT_TRUE(group->Match(plugin3043)); - group->AddPlugin(plugin3043, 1); + group->AddPlugin(plugin3043); EXPECT_EQ(desc3043, group->description()); EXPECT_TRUE(group->IsVulnerable()); EXPECT_TRUE(group->Match(plugin3045)); - group->AddPlugin(plugin3045, 0); + group->AddPlugin(plugin3045); EXPECT_EQ(desc3043, group->description()); EXPECT_TRUE(group->IsVulnerable()); } @@ -188,8 +172,9 @@ TEST(PluginGroupTest, DisableOutdated) { for (size_t i = 0; i < 2; ++i) { scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( plugindefs[i])); - group->AddPlugin(kPlugin3043, 0); - group->AddPlugin(kPlugin3045, 1); + group->AddPlugin(kPlugin3043); + group->AddPlugin(kPlugin3045); + EXPECT_EQ(ASCIIToUTF16("MyPlugin version 3.0.43"), group->description()); EXPECT_TRUE(group->IsVulnerable()); @@ -218,7 +203,7 @@ TEST(PluginGroupTest, VersionExtraction) { ASCIIToUTF16(versions[i][0]), string16()); scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup(plugin)); EXPECT_TRUE(group->Match(plugin)); - group->AddPlugin(plugin, 0); + group->AddPlugin(plugin); scoped_ptr<DictionaryValue> data(group->GetDataForUI()); std::string version; data->GetString("version", &version); @@ -256,7 +241,7 @@ TEST(PluginGroupTest, IsVulnerable) { ASCIIToUTF16("adobe reader 10")); scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup( adobe_reader_plugin_def)); - group->AddPlugin(adobe_reader_plugin, 0); + group->AddPlugin(adobe_reader_plugin); PluginGroup group_copy(*group); // Exercise the copy constructor. EXPECT_FALSE(group_copy.IsVulnerable()); @@ -274,7 +259,7 @@ TEST(PluginGroupTest, IsVulnerable) { ASCIIToUTF16("4.0.50917.0"), ASCIIToUTF16("silverlight 4")); group.reset(PluginGroupTest::CreatePluginGroup(silverlight_plugin_def)); - group->AddPlugin(silverlight_plugin, 0); + group->AddPlugin(silverlight_plugin); EXPECT_FALSE(PluginGroup(*group).IsVulnerable()); } } // namespace npapi |