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

Side by Side Diff: content/browser/plugin_loader_posix_unittest.cc

Issue 9349002: Merge 120098 - PluginLoaderPosix: Fix the case where the utility process crashes after all plugin... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1025/src/
Patch Set: Created 8 years, 10 months 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 | « content/browser/plugin_loader_posix.cc ('k') | no next file » | 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) 2011 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/file_path.h" 9 #include "base/file_path.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 EXPECT_EQ(0, did_callback); 163 EXPECT_EQ(0, did_callback);
164 164
165 plugin_loader()->TestOnPluginLoaded(2, plugin3_); 165 plugin_loader()->TestOnPluginLoaded(2, plugin3_);
166 EXPECT_EQ(3u, plugins.size()); 166 EXPECT_EQ(3u, plugins.size());
167 EXPECT_EQ(plugin3_.name, plugins[2].name); 167 EXPECT_EQ(plugin3_.name, plugins[2].name);
168 168
169 message_loop()->RunAllPending(); 169 message_loop()->RunAllPending();
170 EXPECT_EQ(1, did_callback); 170 EXPECT_EQ(1, did_callback);
171 } 171 }
172 172
173 TEST_F(PluginLoaderPosixTest, ThreeSuccessfulLoadsThenCrash) {
174 int did_callback = 0;
175 content::PluginService::GetPluginsCallback callback =
176 base::Bind(&VerifyCallback, base::Unretained(&did_callback));
177
178 plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
179
180 EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(2);
181 message_loop()->RunAllPending();
182
183 AddThreePlugins();
184
185 EXPECT_EQ(0u, plugin_loader()->next_load_index());
186
187 const std::vector<webkit::WebPluginInfo>& plugins(
188 plugin_loader()->loaded_plugins());
189
190 plugin_loader()->TestOnPluginLoaded(0, plugin1_);
191 EXPECT_EQ(1u, plugin_loader()->next_load_index());
192 EXPECT_EQ(1u, plugins.size());
193 EXPECT_EQ(plugin1_.name, plugins[0].name);
194
195 message_loop()->RunAllPending();
196 EXPECT_EQ(0, did_callback);
197
198 plugin_loader()->TestOnPluginLoaded(1, plugin2_);
199 EXPECT_EQ(2u, plugin_loader()->next_load_index());
200 EXPECT_EQ(2u, plugins.size());
201 EXPECT_EQ(plugin2_.name, plugins[1].name);
202
203 message_loop()->RunAllPending();
204 EXPECT_EQ(0, did_callback);
205
206 plugin_loader()->TestOnPluginLoaded(2, plugin3_);
207 EXPECT_EQ(3u, plugins.size());
208 EXPECT_EQ(plugin3_.name, plugins[2].name);
209
210 message_loop()->RunAllPending();
211 EXPECT_EQ(1, did_callback);
212
213 plugin_loader()->OnProcessCrashed(42);
214 }
215
173 TEST_F(PluginLoaderPosixTest, TwoFailures) { 216 TEST_F(PluginLoaderPosixTest, TwoFailures) {
174 int did_callback = 0; 217 int did_callback = 0;
175 content::PluginService::GetPluginsCallback callback = 218 content::PluginService::GetPluginsCallback callback =
176 base::Bind(&VerifyCallback, base::Unretained(&did_callback)); 219 base::Bind(&VerifyCallback, base::Unretained(&did_callback));
177 220
178 plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback); 221 plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
179 222
180 EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1); 223 EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(1);
181 message_loop()->RunAllPending(); 224 message_loop()->RunAllPending();
182 225
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 &MockPluginLoaderPosix::RealLoadPluginsInternal)); 359 &MockPluginLoaderPosix::RealLoadPluginsInternal));
317 plugin_loader()->OnProcessCrashed(42); 360 plugin_loader()->OnProcessCrashed(42);
318 plugin_loader()->OnProcessCrashed(42); 361 plugin_loader()->OnProcessCrashed(42);
319 plugin_loader()->OnProcessCrashed(42); 362 plugin_loader()->OnProcessCrashed(42);
320 363
321 message_loop()->RunAllPending(); 364 message_loop()->RunAllPending();
322 EXPECT_EQ(1, did_callback); 365 EXPECT_EQ(1, did_callback);
323 366
324 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size()); 367 EXPECT_EQ(0u, plugin_loader()->loaded_plugins().size());
325 } 368 }
OLDNEW
« no previous file with comments | « content/browser/plugin_loader_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698