OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/nacl_host/pnacl_host.h" | 5 #include "chrome/browser/nacl_host/pnacl_host.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 FlushQueues(); | 188 FlushQueues(); |
189 EXPECT_EQ(0U, host_->pending_translations()); | 189 EXPECT_EQ(0U, host_->pending_translations()); |
190 // Check another successful miss | 190 // Check another successful miss |
191 GET_NEXE_FD(0, 0, false, info, false); | 191 GET_NEXE_FD(0, 0, false, info, false); |
192 FlushQueues(); | 192 FlushQueues(); |
193 EXPECT_EQ(3, temp_callback_count_); | 193 EXPECT_EQ(3, temp_callback_count_); |
194 host_->TranslationFinished(0, 0, false); | 194 host_->TranslationFinished(0, 0, false); |
195 EXPECT_EQ(0U, host_->pending_translations()); | 195 EXPECT_EQ(0U, host_->pending_translations()); |
196 } | 196 } |
197 | 197 |
198 TEST_F(PnaclHostTest, OverlappedMissesAfterTempReturn) { | 198 // crbug.com/272492; flaky on all platforms. |
| 199 TEST_F(PnaclHostTest, DISABLED_OverlappedMissesAfterTempReturn) { |
199 nacl::PnaclCacheInfo info = GetTestCacheInfo(); | 200 nacl::PnaclCacheInfo info = GetTestCacheInfo(); |
200 GET_NEXE_FD(0, 0, false, info, false); | 201 GET_NEXE_FD(0, 0, false, info, false); |
201 FlushQueues(); | 202 FlushQueues(); |
202 EXPECT_EQ(1, temp_callback_count_); | 203 EXPECT_EQ(1, temp_callback_count_); |
203 EXPECT_EQ(1U, host_->pending_translations()); | 204 EXPECT_EQ(1U, host_->pending_translations()); |
204 // Test that a second request for the same nexe while the first one is still | 205 // Test that a second request for the same nexe while the first one is still |
205 // outstanding eventually hits. | 206 // outstanding eventually hits. |
206 GET_NEXE_FD(0, 1, false, info, true); | 207 GET_NEXE_FD(0, 1, false, info, true); |
207 FlushQueues(); | 208 FlushQueues(); |
208 EXPECT_EQ(2U, host_->pending_translations()); | 209 EXPECT_EQ(2U, host_->pending_translations()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 FlushQueues(); | 261 FlushQueues(); |
261 EXPECT_EQ(0U, host_->pending_translations()); | 262 EXPECT_EQ(0U, host_->pending_translations()); |
262 GET_NEXE_FD(0, 0, false, info, true); | 263 GET_NEXE_FD(0, 0, false, info, true); |
263 FlushQueues(); | 264 FlushQueues(); |
264 GET_NEXE_FD(0, 1, false, info, true); | 265 GET_NEXE_FD(0, 1, false, info, true); |
265 FlushQueues(); | 266 FlushQueues(); |
266 EXPECT_EQ(3, temp_callback_count_); | 267 EXPECT_EQ(3, temp_callback_count_); |
267 EXPECT_EQ(0U, host_->pending_translations()); | 268 EXPECT_EQ(0U, host_->pending_translations()); |
268 } | 269 } |
269 | 270 |
270 TEST_F(PnaclHostTest, OverlappedMissesRendererClosing) { | 271 // crbug.com/272492; flaky on all platforms. |
| 272 TEST_F(PnaclHostTest, DISABLED_OverlappedMissesRendererClosing) { |
271 nacl::PnaclCacheInfo info = GetTestCacheInfo(); | 273 nacl::PnaclCacheInfo info = GetTestCacheInfo(); |
272 GET_NEXE_FD(0, 0, false, info, false); | 274 GET_NEXE_FD(0, 0, false, info, false); |
273 // Send the 2nd fd request from a different renderer. | 275 // Send the 2nd fd request from a different renderer. |
274 // Test that it eventually gets an fd after the first renderer closes. | 276 // Test that it eventually gets an fd after the first renderer closes. |
275 GET_NEXE_FD(1, 1, false, info, false); | 277 GET_NEXE_FD(1, 1, false, info, false); |
276 FlushQueues(); | 278 FlushQueues(); |
277 EXPECT_EQ(1, temp_callback_count_); | 279 EXPECT_EQ(1, temp_callback_count_); |
278 EXPECT_EQ(2U, host_->pending_translations()); | 280 EXPECT_EQ(2U, host_->pending_translations()); |
279 FlushQueues(); | 281 FlushQueues(); |
280 EXPECT_EQ(2U, host_->pending_translations()); | 282 EXPECT_EQ(2U, host_->pending_translations()); |
(...skipping 17 matching lines...) Expand all Loading... |
298 FlushQueues(); | 300 FlushQueues(); |
299 EXPECT_EQ(2, temp_callback_count_); | 301 EXPECT_EQ(2, temp_callback_count_); |
300 host_->TranslationFinished(0, 0, true); | 302 host_->TranslationFinished(0, 0, true); |
301 FlushQueues(); | 303 FlushQueues(); |
302 // Check that an incognito translation can hit from a normal one. | 304 // Check that an incognito translation can hit from a normal one. |
303 GET_NEXE_FD(0, 0, true, info, true); | 305 GET_NEXE_FD(0, 0, true, info, true); |
304 FlushQueues(); | 306 FlushQueues(); |
305 EXPECT_EQ(3, temp_callback_count_); | 307 EXPECT_EQ(3, temp_callback_count_); |
306 } | 308 } |
307 | 309 |
308 TEST_F(PnaclHostTest, IncognitoOverlappedMiss) { | 310 // crbug.com/272492; flaky on all platforms. |
| 311 TEST_F(PnaclHostTest, DISABLED_IncognitoOverlappedMiss) { |
309 nacl::PnaclCacheInfo info = GetTestCacheInfo(); | 312 nacl::PnaclCacheInfo info = GetTestCacheInfo(); |
310 GET_NEXE_FD(0, 0, true, info, false); | 313 GET_NEXE_FD(0, 0, true, info, false); |
311 GET_NEXE_FD(0, 1, false, info, false); | 314 GET_NEXE_FD(0, 1, false, info, false); |
312 FlushQueues(); | 315 FlushQueues(); |
313 // Check that both translations have returned misses, (i.e. that the | 316 // Check that both translations have returned misses, (i.e. that the |
314 // second one has not blocked on the incognito one) | 317 // second one has not blocked on the incognito one) |
315 EXPECT_EQ(2, temp_callback_count_); | 318 EXPECT_EQ(2, temp_callback_count_); |
316 host_->TranslationFinished(0, 0, true); | 319 host_->TranslationFinished(0, 0, true); |
317 host_->TranslationFinished(0, 1, true); | 320 host_->TranslationFinished(0, 1, true); |
318 FlushQueues(); | 321 FlushQueues(); |
319 EXPECT_EQ(0U, host_->pending_translations()); | 322 EXPECT_EQ(0U, host_->pending_translations()); |
320 | 323 |
321 // Same test, but issue the 2nd request after the first has returned a miss. | 324 // Same test, but issue the 2nd request after the first has returned a miss. |
322 info.abi_version = 222; | 325 info.abi_version = 222; |
323 GET_NEXE_FD(0, 0, true, info, false); | 326 GET_NEXE_FD(0, 0, true, info, false); |
324 FlushQueues(); | 327 FlushQueues(); |
325 EXPECT_EQ(3, temp_callback_count_); | 328 EXPECT_EQ(3, temp_callback_count_); |
326 GET_NEXE_FD(0, 1, false, info, false); | 329 GET_NEXE_FD(0, 1, false, info, false); |
327 FlushQueues(); | 330 FlushQueues(); |
328 EXPECT_EQ(4, temp_callback_count_); | 331 EXPECT_EQ(4, temp_callback_count_); |
329 host_->RendererClosing(0); | 332 host_->RendererClosing(0); |
330 } | 333 } |
331 | 334 |
332 TEST_F(PnaclHostTest, IncognitoSecondOverlappedMiss) { | 335 // crbug.com/272492; flaky on all platforms. |
| 336 TEST_F(PnaclHostTest, DISABLED_IncognitoSecondOverlappedMiss) { |
333 // If the non-incognito request comes first, it should | 337 // If the non-incognito request comes first, it should |
334 // behave exactly like OverlappedMissBeforeTempReturn | 338 // behave exactly like OverlappedMissBeforeTempReturn |
335 nacl::PnaclCacheInfo info = GetTestCacheInfo(); | 339 nacl::PnaclCacheInfo info = GetTestCacheInfo(); |
336 GET_NEXE_FD(0, 0, false, info, false); | 340 GET_NEXE_FD(0, 0, false, info, false); |
337 // Send the 2nd fd request before the first one returns a temp file. | 341 // Send the 2nd fd request before the first one returns a temp file. |
338 GET_NEXE_FD(0, 1, true, info, true); | 342 GET_NEXE_FD(0, 1, true, info, true); |
339 FlushQueues(); | 343 FlushQueues(); |
340 EXPECT_EQ(1, temp_callback_count_); | 344 EXPECT_EQ(1, temp_callback_count_); |
341 EXPECT_EQ(2U, host_->pending_translations()); | 345 EXPECT_EQ(2U, host_->pending_translations()); |
342 FlushQueues(); | 346 FlushQueues(); |
(...skipping 22 matching lines...) Expand all Loading... |
365 // Since we are using a memory backend, the clear should happen immediately. | 369 // Since we are using a memory backend, the clear should happen immediately. |
366 host_->ClearTranslationCacheEntriesBetween(base::Time(), base::Time(), | 370 host_->ClearTranslationCacheEntriesBetween(base::Time(), base::Time(), |
367 base::Bind(cb.callback(), 0)); | 371 base::Bind(cb.callback(), 0)); |
368 EXPECT_EQ(0, cb.GetResult(net::ERR_IO_PENDING)); | 372 EXPECT_EQ(0, cb.GetResult(net::ERR_IO_PENDING)); |
369 // Check that the translation cache has been cleared | 373 // Check that the translation cache has been cleared |
370 EXPECT_EQ(0, GetCacheSize()); | 374 EXPECT_EQ(0, GetCacheSize()); |
371 host_->RendererClosing(0); | 375 host_->RendererClosing(0); |
372 } | 376 } |
373 | 377 |
374 } // namespace pnacl | 378 } // namespace pnacl |
OLD | NEW |