diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 04:34:14 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 04:34:14 +0000 |
commit | 8f337212cc8c13bbeb38c54d150f7f848e245b07 (patch) | |
tree | b1691fa32c63bb13271eeff41f31d280ba19a45e /webkit | |
parent | 0dbcdb57b84945b2591ee93e1a7c57012383400b (diff) | |
download | chromium_src-8f337212cc8c13bbeb38c54d150f7f848e245b07.zip chromium_src-8f337212cc8c13bbeb38c54d150f7f848e245b07.tar.gz chromium_src-8f337212cc8c13bbeb38c54d150f7f848e245b07.tar.bz2 |
Remove plugin_list.h includes from chrome tests in preparation for moving webkit/plugins to content/. To do this, I simplified how we disable plugin loading for tests, and also updated the test in content to use the new way.
BUG=237249
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/19706002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212249 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/npapi/mock_plugin_list.cc | 38 | ||||
-rw-r--r-- | webkit/plugins/npapi/mock_plugin_list.h | 39 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list.h | 11 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_list_unittest.cc | 20 | ||||
-rw-r--r-- | webkit/plugins/webkit_plugins.gyp | 14 |
5 files changed, 15 insertions, 107 deletions
diff --git a/webkit/plugins/npapi/mock_plugin_list.cc b/webkit/plugins/npapi/mock_plugin_list.cc deleted file mode 100644 index 89206cf..0000000 --- a/webkit/plugins/npapi/mock_plugin_list.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "webkit/plugins/npapi/mock_plugin_list.h" - -namespace webkit { -namespace npapi { - -MockPluginList::MockPluginList() { -} - -MockPluginList::~MockPluginList() { -} - -void MockPluginList::AddPluginToLoad(const WebPluginInfo& plugin) { - plugins_to_load_.push_back(plugin); -} - -void MockPluginList::ClearPluginsToLoad() { - plugins_to_load_.clear(); -} - -bool MockPluginList::GetPluginsNoRefresh( - std::vector<webkit::WebPluginInfo>* plugins) { - GetPlugins(plugins); - return true; -} - -void MockPluginList::LoadPluginsIntoPluginListInternal( - std::vector<webkit::WebPluginInfo>* plugins) { - for (size_t i = 0; i < plugins_to_load_.size(); ++i) { - plugins->push_back(plugins_to_load_[i]); - } -} - -} // npapi -} // webkit diff --git a/webkit/plugins/npapi/mock_plugin_list.h b/webkit/plugins/npapi/mock_plugin_list.h deleted file mode 100644 index 751d500..0000000 --- a/webkit/plugins/npapi/mock_plugin_list.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_ -#define WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_ - -#include "webkit/plugins/npapi/plugin_list.h" - -namespace webkit { -namespace npapi { - -// A PluginList for tests that avoids file system IO. There is also no reason -// to use |lock_| (but it doesn't hurt either). -class MockPluginList : public PluginList { - public: - MockPluginList(); - virtual ~MockPluginList(); - - void AddPluginToLoad(const WebPluginInfo& plugin); - void ClearPluginsToLoad(); - - // PluginList: - virtual bool GetPluginsNoRefresh( - std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; - - private: - std::vector<WebPluginInfo> plugins_to_load_; - - // PluginList methods: - - virtual void LoadPluginsIntoPluginListInternal( - std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; -}; - -} // npapi -} // webkit - -#endif // WEBKIT_PLUGINS_NPAPI_MOCK_PLUGIN_LIST_H_ diff --git a/webkit/plugins/npapi/plugin_list.h b/webkit/plugins/npapi/plugin_list.h index 73bca62..2b800d8 100644 --- a/webkit/plugins/npapi/plugin_list.h +++ b/webkit/plugins/npapi/plugin_list.h @@ -99,8 +99,6 @@ class PluginList { // Removes a specified internal plugin from the list. The search will match // on the path from the version info previously registered. - // - // This is generally only necessary for tests. void UnregisterInternalPlugin(const base::FilePath& path); // Gets a list of all the registered internal plugins. @@ -130,7 +128,7 @@ class PluginList { // Copies the list of plug-ins into |plugins| without loading them. // Returns true if the list of plugins is up-to-date. - virtual bool GetPluginsNoRefresh( + bool GetPluginsNoRefresh( std::vector<webkit::WebPluginInfo>* plugins); // Returns a list in |info| containing plugins that are found for @@ -189,11 +187,6 @@ class PluginList { webkit::WebPluginInfo* info); #endif - protected: - // Constructors are private for singletons but we expose this one - // for subclasses for test purposes. - PluginList(); - private: enum LoadingState { LOADING_STATE_NEEDS_REFRESH, @@ -209,6 +202,8 @@ class PluginList { friend class PluginListTest; friend struct base::DefaultLazyInstanceTraits<PluginList>; + PluginList(); + // Implements all IO dependent operations of the LoadPlugins method so that // test classes can mock these out. virtual void LoadPluginsIntoPluginListInternal( diff --git a/webkit/plugins/npapi/plugin_list_unittest.cc b/webkit/plugins/npapi/plugin_list_unittest.cc index 246f51b..432b90f 100644 --- a/webkit/plugins/npapi/plugin_list_unittest.cc +++ b/webkit/plugins/npapi/plugin_list_unittest.cc @@ -7,7 +7,6 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/plugins/npapi/mock_plugin_list.h" namespace webkit { namespace npapi { @@ -31,12 +30,15 @@ bool Contains(const std::vector<WebPluginInfo>& list, return false; } +} // namespace + +// Linux Aura doesn't support NPAPI. +#if !(defined(OS_LINUX) && defined(USE_AURA)) + base::FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin"); base::FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin"); const char* kFooName = "Foo Plugin"; -} // namespace - class PluginListTest : public testing::Test { public: PluginListTest() @@ -51,12 +53,13 @@ class PluginListTest : public testing::Test { } virtual void SetUp() { - plugin_list_.AddPluginToLoad(bar_plugin_); - plugin_list_.AddPluginToLoad(foo_plugin_); + plugin_list_.DisablePluginsDiscovery(); + plugin_list_.RegisterInternalPlugin(bar_plugin_, false); + plugin_list_.RegisterInternalPlugin(foo_plugin_, false); } protected: - MockPluginList plugin_list_; + PluginList plugin_list_; WebPluginInfo foo_plugin_; WebPluginInfo bar_plugin_; }; @@ -74,8 +77,7 @@ TEST_F(PluginListTest, BadPluginDescription) { base::string16(), base::FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), base::string16(), base::string16()); // Simulate loading of the plugins. - plugin_list_.ClearPluginsToLoad(); - plugin_list_.AddPluginToLoad(plugin_3043); + plugin_list_.RegisterInternalPlugin(plugin_3043, false); // Now we should have them in the state we specified above. plugin_list_.RefreshPlugins(); std::vector<WebPluginInfo> plugins; @@ -83,6 +85,8 @@ TEST_F(PluginListTest, BadPluginDescription) { ASSERT_TRUE(Contains(plugins, plugin_3043)); } +#endif + #if defined(OS_POSIX) && !defined(OS_MACOSX) // Test parsing a simple description: Real Audio. diff --git a/webkit/plugins/webkit_plugins.gyp b/webkit/plugins/webkit_plugins.gyp index 2f47059..74751ae 100644 --- a/webkit/plugins/webkit_plugins.gyp +++ b/webkit/plugins/webkit_plugins.gyp @@ -71,20 +71,6 @@ }], ], }, - { - 'target_name': 'test_mock_plugin_list', - 'type': 'static_library', - 'dependencies': [ - 'plugins_common' - ], - 'include_dirs': [ - '../..', - ], - 'sources': [ - 'npapi/mock_plugin_list.cc', - 'npapi/mock_plugin_list.h', - ] - }, ], 'conditions': [ ['OS!="android" and OS!="ios"', { |