diff options
-rw-r--r-- | chrome/browser/plugin_service_browsertest.cc | 87 | ||||
-rw-r--r-- | chrome/browser/plugin_service_unittest.cc | 76 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 |
3 files changed, 0 insertions, 165 deletions
diff --git a/chrome/browser/plugin_service_browsertest.cc b/chrome/browser/plugin_service_browsertest.cc deleted file mode 100644 index e62224e..0000000 --- a/chrome/browser/plugin_service_browsertest.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) 2010 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 "chrome/browser/plugin_service.h" - -#include "base/auto_reset.h" -#include "base/command_line.h" -#include "chrome/browser/browser_thread.h" -#include "chrome/test/in_process_browser_test.h" -#include "chrome/test/testing_profile.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "webkit/glue/plugins/plugin_list.h" - -namespace { - -// We have to mock the Client class up in order to be able to test the -// OpenChannelToPlugin function. The only really needed function of this mockup -// is SetPluginInfo, which gets called in -// PluginService::FinishOpenChannelToPlugin. -class PluginProcessHostClientMock : public PluginProcessHost::Client { - public: - virtual ~PluginProcessHostClientMock() {} - - MOCK_METHOD0(ID, int()); - MOCK_METHOD0(OffTheRecord, bool()); - MOCK_METHOD1(SetPluginInfo, void(const WebPluginInfo& info)); - MOCK_METHOD1(OnChannelOpened, void(const IPC::ChannelHandle& handle)); - MOCK_METHOD0(OnError, void()); -}; - -class PluginServiceTest : public testing::Test { - public: - PluginServiceTest() - : message_loop_(MessageLoop::TYPE_IO), - ui_thread_(BrowserThread::UI, &message_loop_), - file_thread_(BrowserThread::FILE, &message_loop_), - io_thread_(BrowserThread::IO, &message_loop_) {} - - virtual ~PluginServiceTest() {} - - virtual void SetUp() { - profile_.reset(new TestingProfile()); - - PluginService::InitGlobalInstance(profile_.get()); - plugin_service_ = PluginService::GetInstance(); - ASSERT_TRUE(plugin_service_); - } - - protected: - MessageLoop message_loop_; - PluginService* plugin_service_; - - private: - BrowserThread ui_thread_; - BrowserThread file_thread_; - BrowserThread io_thread_; - scoped_ptr<TestingProfile> profile_; - - DISALLOW_COPY_AND_ASSIGN(PluginServiceTest); -}; - -// These tests need to be implemented as in process tests because on mac os the -// plugin loading mechanism checks whether plugin paths are in the bundle path -// and the test fails this check when run outside of the browser process. -IN_PROC_BROWSER_TEST_F(PluginServiceTest, StartAndFindPluginProcess) { - // Try to load the default plugin and if this is successful consecutive - // calls to FindPluginProcess should return non-zero values. - PluginProcessHost* default_plugin_process_host = - plugin_service_->FindOrStartPluginProcess( - FilePath(kDefaultPluginLibraryName)); - - EXPECT_EQ(default_plugin_process_host, - plugin_service_->FindPluginProcess(FilePath(kDefaultPluginLibraryName))); -} - -IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { - PluginProcessHostClientMock mock_client; - EXPECT_CALL(mock_client, SetPluginInfo(testing::_)).Times(1); - plugin_service_->OpenChannelToPlugin(GURL("http://google.com/"), - "audio/mp3", - &mock_client); - message_loop_.RunAllPending(); -} - -} // namespace diff --git a/chrome/browser/plugin_service_unittest.cc b/chrome/browser/plugin_service_unittest.cc deleted file mode 100644 index 69172598..0000000 --- a/chrome/browser/plugin_service_unittest.cc +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2010 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 "chrome/browser/plugin_service.h" - -#include "base/auto_reset.h" -#include "base/command_line.h" -#include "chrome/browser/browser_thread.h" -#include "chrome/test/testing_profile.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/plugins/plugin_list.h" - -namespace { - -class PluginServiceTest : public testing::Test { - public: - PluginServiceTest() - : message_loop_(MessageLoop::TYPE_IO), - ui_thread_(BrowserThread::UI, &message_loop_), - file_thread_(BrowserThread::FILE, &message_loop_), - io_thread_(BrowserThread::IO, &message_loop_) {} - - virtual ~PluginServiceTest() {} - - virtual void SetUp() { - profile_.reset(new TestingProfile()); - - PluginService::InitGlobalInstance(profile_.get()); - plugin_service_ = PluginService::GetInstance(); - ASSERT_TRUE(plugin_service_); - } - - protected: - MessageLoop message_loop_; - PluginService* plugin_service_; - - private: - BrowserThread ui_thread_; - BrowserThread file_thread_; - BrowserThread io_thread_; - scoped_ptr<TestingProfile> profile_; - - DISALLOW_COPY_AND_ASSIGN(PluginServiceTest); -}; - -TEST_F(PluginServiceTest, SetGetChromePluginDataDir) { - // Check that after setting the same plugin dir we just read it is set - // correctly. - FilePath plugin_data_dir = plugin_service_->GetChromePluginDataDir(); - FilePath new_plugin_data_dir(FILE_PATH_LITERAL("/a/bogus/dir")); - plugin_service_->SetChromePluginDataDir(new_plugin_data_dir); - EXPECT_EQ(new_plugin_data_dir, plugin_service_->GetChromePluginDataDir()); - plugin_service_->SetChromePluginDataDir(plugin_data_dir); - EXPECT_EQ(plugin_data_dir, plugin_service_->GetChromePluginDataDir()); -} - -TEST_F(PluginServiceTest, GetUILocale) { - // Check for a non-empty locale string. - EXPECT_NE("", plugin_service_->GetUILocale()); -} - -TEST_F(PluginServiceTest, GetFirstAllowedPluginInfo) { - // We should always get a positive response no matter whether we really have - // a plugin to support that particular mime type because the Default plugin - // supports all mime types. - WebPluginInfo plugin_info; - std::string plugin_mime_type; - plugin_service_->GetFirstAllowedPluginInfo(GURL("http://google.com/"), - "application/pdf", - &plugin_info, - &plugin_mime_type); - EXPECT_EQ("application/pdf", plugin_mime_type); -} - -} // namespace diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 2519804..cef55a2 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1389,7 +1389,6 @@ 'browser/password_manager/password_store_mac_unittest.cc', 'browser/password_manager/password_store_win_unittest.cc', 'browser/plugin_exceptions_table_model_unittest.cc', - 'browser/plugin_service_unittest.cc', 'browser/policy/config_dir_policy_provider_unittest.cc', 'browser/policy/configuration_policy_pref_store_unittest.cc', 'browser/policy/configuration_policy_provider_mac_unittest.cc', @@ -2037,7 +2036,6 @@ 'browser/in_process_webkit/indexed_db_browsertest.cc', 'browser/net/cookie_policy_browsertest.cc', 'browser/net/ftp_browsertest.cc', - 'browser/plugin_service_browsertest.cc', 'browser/policy/device_management_backend_impl_mock.h', 'browser/policy/device_management_backend_impl_browsertest.cc', 'browser/popup_blocker_browsertest.cc', |