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

Side by Side Diff: Source/core/dom/ScriptRunnerTest.cpp

Issue 1024013002: Revert of Oilpan: fix webkit unit tests following r192243. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | « no previous file | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "config.h" 5 #include "config.h"
6 #include "core/dom/ScriptRunner.h" 6 #include "core/dom/ScriptRunner.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/ScriptLoader.h" 9 #include "core/dom/ScriptLoader.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 EXPECT_THAT(m_order, ElementsAre(1)); 375 EXPECT_THAT(m_order, ElementsAre(1));
376 376
377 // Make sure the interrupted tasks are executed next 'tick'. 377 // Make sure the interrupted tasks are executed next 'tick'.
378 m_platform.setShouldYield(false); 378 m_platform.setShouldYield(false);
379 m_platform.runSingleTask(); 379 m_platform.runSingleTask();
380 EXPECT_THAT(m_order, ElementsAre(1, 2, 3)); 380 EXPECT_THAT(m_order, ElementsAre(1, 2, 3));
381 } 381 }
382 382
383 TEST_F(ScriptRunnerTest, QueueReentrantScript_ManyAsyncScripts) 383 TEST_F(ScriptRunnerTest, QueueReentrantScript_ManyAsyncScripts)
384 { 384 {
385 const int loaderCount = 20; 385 OwnPtr<MockScriptLoader> scriptLoaders[20];
386 OwnPtrWillBeRawPtr<MockScriptLoader> scriptLoaders[loaderCount]; 386 for (int i = 0; i < 20; i++) {
387 for (int i = 0; i < loaderCount; i++) 387 scriptLoaders[i] = adoptPtr(new MockScriptLoader(m_element.get()));
388 scriptLoaders[i] = nullptr;
389
390 for (int i = 0; i < loaderCount; i++) {
391 scriptLoaders[i] = adoptPtrWillBeNoop(new MockScriptLoader(m_element.get ()));
392 EXPECT_CALL(*scriptLoaders[i], isReady()).WillRepeatedly(Return(true)); 388 EXPECT_CALL(*scriptLoaders[i], isReady()).WillRepeatedly(Return(true));
393 389
394 m_scriptRunner->queueScriptForExecution(scriptLoaders[i].get(), ScriptRu nner::ASYNC_EXECUTION); 390 m_scriptRunner->queueScriptForExecution(scriptLoaders[i].get(), ScriptRu nner::ASYNC_EXECUTION);
395 391
396 if (i > 0) { 392 if (i > 0) {
397 EXPECT_CALL(*scriptLoaders[i], execute()).WillOnce(Invoke([this, i] { 393 EXPECT_CALL(*scriptLoaders[i], execute()).WillOnce(Invoke([this, i] {
398 m_order.push_back(i); 394 m_order.push_back(i);
399 })); 395 }));
400 } 396 }
401 } 397 }
402 398
403 m_scriptRunner->notifyScriptReady(scriptLoaders[0].get(), ScriptRunner::ASYN C_EXECUTION); 399 m_scriptRunner->notifyScriptReady(scriptLoaders[0].get(), ScriptRunner::ASYN C_EXECUTION);
404 m_scriptRunner->notifyScriptReady(scriptLoaders[1].get(), ScriptRunner::ASYN C_EXECUTION); 400 m_scriptRunner->notifyScriptReady(scriptLoaders[1].get(), ScriptRunner::ASYN C_EXECUTION);
405 m_scriptRunner->resume(); 401 m_scriptRunner->resume();
406 402
407 EXPECT_CALL(*scriptLoaders[0], execute()).WillOnce(Invoke([&scriptLoaders, t his] { 403 EXPECT_CALL(*scriptLoaders[0], execute()).WillOnce(Invoke([&scriptLoaders, t his] {
408 for (int i = 2; i < loaderCount; i++) 404 for (int i = 2; i < 20; i++)
409 m_scriptRunner->notifyScriptReady(scriptLoaders[i].get(), ScriptRunn er::ASYNC_EXECUTION); 405 m_scriptRunner->notifyScriptReady(scriptLoaders[i].get(), ScriptRunn er::ASYNC_EXECUTION);
410 m_scriptRunner->resume(); 406 m_scriptRunner->resume();
411 m_order.push_back(0); 407 m_order.push_back(0);
412 })); 408 }));
413 409
414 m_platform.runAllTasks(); 410 m_platform.runAllTasks();
415 411
416 int expected[] = { 412 int expected[] = {
417 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 413 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
418 }; 414 };
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 testing::Mock::VerifyAndClear(&scriptLoader2); 506 testing::Mock::VerifyAndClear(&scriptLoader2);
511 testing::Mock::VerifyAndClear(&scriptLoader3); 507 testing::Mock::VerifyAndClear(&scriptLoader3);
512 EXPECT_CALL(scriptLoader2, execute()).Times(1); 508 EXPECT_CALL(scriptLoader2, execute()).Times(1);
513 EXPECT_CALL(scriptLoader3, execute()).Times(1); 509 EXPECT_CALL(scriptLoader3, execute()).Times(1);
514 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true)); 510 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true));
515 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true)); 511 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true));
516 m_platform.runAllTasks(); 512 m_platform.runAllTasks();
517 } 513 }
518 514
519 } // namespace blink 515 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698