OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/plugin_loader_posix.h" | 5 #include "content/browser/plugin_loader_posix.h" |
6 | 6 |
| 7 #include "base/at_exit.h" |
7 #include "base/bind.h" | 8 #include "base/bind.h" |
8 #include "base/file_path.h" | 9 #include "base/file_path.h" |
9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "content/browser/browser_thread_impl.h" | 13 #include "content/browser/browser_thread_impl.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webkit/plugins/webplugininfo.h" | 16 #include "webkit/plugins/webplugininfo.h" |
16 | 17 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ASCIIToUTF16("1.0"), string16()), | 66 ASCIIToUTF16("1.0"), string16()), |
66 plugin2_(ASCIIToUTF16("plugin2"), FilePath("/tmp/two.plugin"), | 67 plugin2_(ASCIIToUTF16("plugin2"), FilePath("/tmp/two.plugin"), |
67 ASCIIToUTF16("2.0"), string16()), | 68 ASCIIToUTF16("2.0"), string16()), |
68 plugin3_(ASCIIToUTF16("plugin3"), FilePath("/tmp/three.plugin"), | 69 plugin3_(ASCIIToUTF16("plugin3"), FilePath("/tmp/three.plugin"), |
69 ASCIIToUTF16("3.0"), string16()), | 70 ASCIIToUTF16("3.0"), string16()), |
70 file_thread_(BrowserThread::FILE, &message_loop_), | 71 file_thread_(BrowserThread::FILE, &message_loop_), |
71 io_thread_(BrowserThread::IO, &message_loop_), | 72 io_thread_(BrowserThread::IO, &message_loop_), |
72 plugin_loader_(new MockPluginLoaderPosix) { | 73 plugin_loader_(new MockPluginLoaderPosix) { |
73 } | 74 } |
74 | 75 |
| 76 virtual void SetUp() OVERRIDE { |
| 77 PluginService::GetInstance()->Init(); |
| 78 } |
| 79 |
75 MessageLoop* message_loop() { return &message_loop_; } | 80 MessageLoop* message_loop() { return &message_loop_; } |
76 MockPluginLoaderPosix* plugin_loader() { return plugin_loader_.get(); } | 81 MockPluginLoaderPosix* plugin_loader() { return plugin_loader_.get(); } |
77 | 82 |
78 void AddThreePlugins() { | 83 void AddThreePlugins() { |
79 plugin_loader_->canonical_list()->clear(); | 84 plugin_loader_->canonical_list()->clear(); |
80 plugin_loader_->canonical_list()->push_back(plugin1_.path); | 85 plugin_loader_->canonical_list()->push_back(plugin1_.path); |
81 plugin_loader_->canonical_list()->push_back(plugin2_.path); | 86 plugin_loader_->canonical_list()->push_back(plugin2_.path); |
82 plugin_loader_->canonical_list()->push_back(plugin3_.path); | 87 plugin_loader_->canonical_list()->push_back(plugin3_.path); |
83 } | 88 } |
84 | 89 |
85 // Data used for testing. | 90 // Data used for testing. |
86 webkit::WebPluginInfo plugin1_; | 91 webkit::WebPluginInfo plugin1_; |
87 webkit::WebPluginInfo plugin2_; | 92 webkit::WebPluginInfo plugin2_; |
88 webkit::WebPluginInfo plugin3_; | 93 webkit::WebPluginInfo plugin3_; |
89 | 94 |
90 private: | 95 private: |
| 96 base::ShadowingAtExitManager at_exit_manager_; // Destroys PluginService. |
| 97 |
91 MessageLoopForIO message_loop_; | 98 MessageLoopForIO message_loop_; |
92 BrowserThreadImpl file_thread_; | 99 BrowserThreadImpl file_thread_; |
93 BrowserThreadImpl io_thread_; | 100 BrowserThreadImpl io_thread_; |
94 | 101 |
95 scoped_refptr<MockPluginLoaderPosix> plugin_loader_; | 102 scoped_refptr<MockPluginLoaderPosix> plugin_loader_; |
96 }; | 103 }; |
97 | 104 |
98 TEST_F(PluginLoaderPosixTest, QueueRequests) { | 105 TEST_F(PluginLoaderPosixTest, QueueRequests) { |
99 int did_callback = 0; | 106 int did_callback = 0; |
100 PluginService::GetPluginsCallback callback = | 107 PluginService::GetPluginsCallback callback = |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 &MockPluginLoaderPosix::RealLoadPluginsInternal)); | 316 &MockPluginLoaderPosix::RealLoadPluginsInternal)); |
310 plugin_loader()->OnProcessCrashed(42); | 317 plugin_loader()->OnProcessCrashed(42); |
311 plugin_loader()->OnProcessCrashed(42); | 318 plugin_loader()->OnProcessCrashed(42); |
312 plugin_loader()->OnProcessCrashed(42); | 319 plugin_loader()->OnProcessCrashed(42); |
313 | 320 |
314 message_loop()->RunAllPending(); | 321 message_loop()->RunAllPending(); |
315 EXPECT_EQ(1, did_callback); | 322 EXPECT_EQ(1, did_callback); |
316 | 323 |
317 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size()); | 324 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size()); |
318 } | 325 } |
OLD | NEW |