| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/plugin_service.h" | 5 #include "chrome/browser/plugin_service.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
| 10 #include "chrome/test/in_process_browser_test.h" | 10 #include "chrome/test/in_process_browser_test.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 DISALLOW_COPY_AND_ASSIGN(PluginServiceTest); | 65 DISALLOW_COPY_AND_ASSIGN(PluginServiceTest); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // These tests need to be implemented as in process tests because on mac os the | 68 // These tests need to be implemented as in process tests because on mac os the |
| 69 // plugin loading mechanism checks whether plugin paths are in the bundle path | 69 // plugin loading mechanism checks whether plugin paths are in the bundle path |
| 70 // and the test fails this check when run outside of the browser process. | 70 // and the test fails this check when run outside of the browser process. |
| 71 IN_PROC_BROWSER_TEST_F(PluginServiceTest, StartAndFindPluginProcess) { | 71 IN_PROC_BROWSER_TEST_F(PluginServiceTest, StartAndFindPluginProcess) { |
| 72 // Try to load the default plugin and if this is successful consecutive | 72 // Try to load the default plugin and if this is successful consecutive |
| 73 // calls to FindPluginProcess should return non-zero values. | 73 // calls to FindPluginProcess should return non-zero values. |
| 74 PluginProcessHost* default_plugin_process_host = | 74 PluginProcessHost* default_plugin_process_host = |
| 75 plugin_service_->FindOrStartPluginProcess( | 75 plugin_service_->FindOrStartNpapiPluginProcess( |
| 76 FilePath(webkit::npapi::kDefaultPluginLibraryName)); | 76 FilePath(webkit::npapi::kDefaultPluginLibraryName)); |
| 77 | 77 |
| 78 EXPECT_EQ(default_plugin_process_host, plugin_service_->FindPluginProcess( | 78 EXPECT_EQ(default_plugin_process_host, |
| 79 FilePath(webkit::npapi::kDefaultPluginLibraryName))); | 79 plugin_service_->FindNpapiPluginProcess( |
| 80 FilePath(webkit::npapi::kDefaultPluginLibraryName))); |
| 80 } | 81 } |
| 81 | 82 |
| 82 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { | 83 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { |
| 83 MockPluginProcessHostClient mock_client; | 84 MockPluginProcessHostClient mock_client; |
| 84 EXPECT_CALL(mock_client, SetPluginInfo(testing::_)).Times(1); | 85 EXPECT_CALL(mock_client, SetPluginInfo(testing::_)).Times(1); |
| 85 plugin_service_->OpenChannelToPlugin(0, 0, GURL("http://google.com/"), | 86 plugin_service_->OpenChannelToNpapiPlugin(0, 0, GURL("http://google.com/"), |
| 86 "audio/mp3", | 87 "audio/mp3", &mock_client); |
| 87 &mock_client); | |
| 88 message_loop_.RunAllPending(); | 88 message_loop_.RunAllPending(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 IN_PROC_BROWSER_TEST_F(PluginServiceTest, GetFirstAllowedPluginInfo) { | 91 IN_PROC_BROWSER_TEST_F(PluginServiceTest, GetFirstAllowedPluginInfo) { |
| 92 // on ChromeOS the plugin policy gets loaded on the FILE thread and the | 92 // on ChromeOS the plugin policy gets loaded on the FILE thread and the |
| 93 // GetFirstAllowedPluginInfo will fail if we don't allow it to finish. | 93 // GetFirstAllowedPluginInfo will fail if we don't allow it to finish. |
| 94 message_loop_.RunAllPending(); | 94 message_loop_.RunAllPending(); |
| 95 // We should always get a positive response no matter whether we really have | 95 // We should always get a positive response no matter whether we really have |
| 96 // a plugin to support that particular mime type because the Default plugin | 96 // a plugin to support that particular mime type because the Default plugin |
| 97 // supports all mime types. | 97 // supports all mime types. |
| 98 webkit::npapi::WebPluginInfo plugin_info; | 98 webkit::npapi::WebPluginInfo plugin_info; |
| 99 std::string plugin_mime_type; | 99 std::string plugin_mime_type; |
| 100 plugin_service_->GetFirstAllowedPluginInfo(0, 0, GURL("http://google.com/"), | 100 plugin_service_->GetFirstAllowedPluginInfo(0, 0, GURL("http://google.com/"), |
| 101 "application/pdf", | 101 "application/pdf", |
| 102 &plugin_info, | 102 &plugin_info, |
| 103 &plugin_mime_type); | 103 &plugin_mime_type); |
| 104 EXPECT_EQ("application/pdf", plugin_mime_type); | 104 EXPECT_EQ("application/pdf", plugin_mime_type); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace | 107 } // namespace |
| OLD | NEW |