OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 ASCIIToUTF16("3.0"), string16()), | 72 ASCIIToUTF16("3.0"), string16()), |
73 file_thread_(BrowserThread::FILE, &message_loop_), | 73 file_thread_(BrowserThread::FILE, &message_loop_), |
74 io_thread_(BrowserThread::IO, &message_loop_), | 74 io_thread_(BrowserThread::IO, &message_loop_), |
75 plugin_loader_(new MockPluginLoaderPosix) { | 75 plugin_loader_(new MockPluginLoaderPosix) { |
76 } | 76 } |
77 | 77 |
78 virtual void SetUp() OVERRIDE { | 78 virtual void SetUp() OVERRIDE { |
79 PluginServiceImpl::GetInstance()->Init(); | 79 PluginServiceImpl::GetInstance()->Init(); |
80 } | 80 } |
81 | 81 |
82 MessageLoop* message_loop() { return &message_loop_; } | 82 base::MessageLoop* message_loop() { return &message_loop_; } |
83 MockPluginLoaderPosix* plugin_loader() { return plugin_loader_.get(); } | 83 MockPluginLoaderPosix* plugin_loader() { return plugin_loader_.get(); } |
84 | 84 |
85 void AddThreePlugins() { | 85 void AddThreePlugins() { |
86 plugin_loader_->canonical_list()->clear(); | 86 plugin_loader_->canonical_list()->clear(); |
87 plugin_loader_->canonical_list()->push_back(plugin1_.path); | 87 plugin_loader_->canonical_list()->push_back(plugin1_.path); |
88 plugin_loader_->canonical_list()->push_back(plugin2_.path); | 88 plugin_loader_->canonical_list()->push_back(plugin2_.path); |
89 plugin_loader_->canonical_list()->push_back(plugin3_.path); | 89 plugin_loader_->canonical_list()->push_back(plugin3_.path); |
90 } | 90 } |
91 | 91 |
92 // Data used for testing. | 92 // Data used for testing. |
93 webkit::WebPluginInfo plugin1_; | 93 webkit::WebPluginInfo plugin1_; |
94 webkit::WebPluginInfo plugin2_; | 94 webkit::WebPluginInfo plugin2_; |
95 webkit::WebPluginInfo plugin3_; | 95 webkit::WebPluginInfo plugin3_; |
96 | 96 |
97 private: | 97 private: |
98 base::ShadowingAtExitManager at_exit_manager_; // Destroys PluginService. | 98 base::ShadowingAtExitManager at_exit_manager_; // Destroys PluginService. |
99 | 99 |
100 MessageLoopForIO message_loop_; | 100 base::MessageLoopForIO message_loop_; |
101 BrowserThreadImpl file_thread_; | 101 BrowserThreadImpl file_thread_; |
102 BrowserThreadImpl io_thread_; | 102 BrowserThreadImpl io_thread_; |
103 | 103 |
104 scoped_refptr<MockPluginLoaderPosix> plugin_loader_; | 104 scoped_refptr<MockPluginLoaderPosix> plugin_loader_; |
105 }; | 105 }; |
106 | 106 |
107 TEST_F(PluginLoaderPosixTest, QueueRequests) { | 107 TEST_F(PluginLoaderPosixTest, QueueRequests) { |
108 int did_callback = 0; | 108 int did_callback = 0; |
109 PluginService::GetPluginsCallback callback = | 109 PluginService::GetPluginsCallback callback = |
110 base::Bind(&VerifyCallback, base::Unretained(&did_callback)); | 110 base::Bind(&VerifyCallback, base::Unretained(&did_callback)); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 plugin_loader()->OnProcessCrashed(42); | 370 plugin_loader()->OnProcessCrashed(42); |
371 plugin_loader()->OnProcessCrashed(42); | 371 plugin_loader()->OnProcessCrashed(42); |
372 | 372 |
373 message_loop()->RunUntilIdle(); | 373 message_loop()->RunUntilIdle(); |
374 EXPECT_EQ(1, did_callback); | 374 EXPECT_EQ(1, did_callback); |
375 | 375 |
376 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size()); | 376 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size()); |
377 } | 377 } |
378 | 378 |
379 } // namespace content | 379 } // namespace content |
OLD | NEW |