Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/plugin_service_browsertest.cc

Issue 5961004: Revert 69755 - Move the NPAPI files from webkit/glue/plugins to webkit/plugin... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/plugin_service.cc ('k') | chrome/browser/plugin_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "chrome/test/testing_profile.h" 11 #include "chrome/test/testing_profile.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "webkit/plugins/npapi/plugin_list.h" 14 #include "webkit/glue/plugins/plugin_list.h"
15 15
16 namespace { 16 namespace {
17 17
18 // We have to mock the Client class up in order to be able to test the 18 // We have to mock the Client class up in order to be able to test the
19 // OpenChannelToPlugin function. The only really needed function of this mockup 19 // OpenChannelToPlugin function. The only really needed function of this mockup
20 // is SetPluginInfo, which gets called in 20 // is SetPluginInfo, which gets called in
21 // PluginService::FinishOpenChannelToPlugin. 21 // PluginService::FinishOpenChannelToPlugin.
22 class MockPluginProcessHostClient : public PluginProcessHost::Client { 22 class MockPluginProcessHostClient : public PluginProcessHost::Client {
23 public: 23 public:
24 MockPluginProcessHostClient() {} 24 MockPluginProcessHostClient() {}
25 virtual ~MockPluginProcessHostClient() {} 25 virtual ~MockPluginProcessHostClient() {}
26 26
27 MOCK_METHOD0(ID, int()); 27 MOCK_METHOD0(ID, int());
28 MOCK_METHOD0(OffTheRecord, bool()); 28 MOCK_METHOD0(OffTheRecord, bool());
29 MOCK_METHOD1(SetPluginInfo, void(const webkit::npapi::WebPluginInfo& info)); 29 MOCK_METHOD1(SetPluginInfo, void(const WebPluginInfo& info));
30 MOCK_METHOD1(OnChannelOpened, void(const IPC::ChannelHandle& handle)); 30 MOCK_METHOD1(OnChannelOpened, void(const IPC::ChannelHandle& handle));
31 MOCK_METHOD0(OnError, void()); 31 MOCK_METHOD0(OnError, void());
32 32
33 private: 33 private:
34 DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient); 34 DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient);
35 }; 35 };
36 36
37 class PluginServiceTest : public testing::Test { 37 class PluginServiceTest : public testing::Test {
38 public: 38 public:
39 PluginServiceTest() 39 PluginServiceTest()
(...skipping 26 matching lines...) Expand all
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_->FindOrStartPluginProcess(
76 FilePath(webkit::npapi::kDefaultPluginLibraryName)); 76 FilePath(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_->FindPluginProcess(FilePath(kDefaultPluginLibraryName)));
80 } 80 }
81 81
82 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { 82 IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) {
83 MockPluginProcessHostClient mock_client; 83 MockPluginProcessHostClient mock_client;
84 EXPECT_CALL(mock_client, SetPluginInfo(testing::_)).Times(1); 84 EXPECT_CALL(mock_client, SetPluginInfo(testing::_)).Times(1);
85 plugin_service_->OpenChannelToPlugin(GURL("http://google.com/"), 85 plugin_service_->OpenChannelToPlugin(GURL("http://google.com/"),
86 "audio/mp3", 86 "audio/mp3",
87 &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 WebPluginInfo plugin_info;
99 std::string plugin_mime_type; 99 std::string plugin_mime_type;
100 plugin_service_->GetFirstAllowedPluginInfo(GURL("http://google.com/"), 100 plugin_service_->GetFirstAllowedPluginInfo(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
OLDNEW
« no previous file with comments | « chrome/browser/plugin_service.cc ('k') | chrome/browser/plugin_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698