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

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

Issue 1026753002: Oilpan: fix webkit unit tests following r192243. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: do not adopt on construction 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 OwnPtr<MockScriptLoader> scriptLoaders[20]; 385 const int loaderCount = 20;
386 for (int i = 0; i < 20; i++) { 386 OwnPtrWillBeRawPtr<MockScriptLoader> scriptLoaders[loaderCount];
387 scriptLoaders[i] = adoptPtr(new MockScriptLoader(m_element.get())); 387 for (int i = 0; i < loaderCount; i++)
388 scriptLoaders[i] = nullptr;
389
390 for (int i = 0; i < loaderCount; i++) {
391 scriptLoaders[i] = adoptPtrWillBeNoop(new MockScriptLoader(m_element.get ()));
388 EXPECT_CALL(*scriptLoaders[i], isReady()).WillRepeatedly(Return(true)); 392 EXPECT_CALL(*scriptLoaders[i], isReady()).WillRepeatedly(Return(true));
389 393
390 m_scriptRunner->queueScriptForExecution(scriptLoaders[i].get(), ScriptRu nner::ASYNC_EXECUTION); 394 m_scriptRunner->queueScriptForExecution(scriptLoaders[i].get(), ScriptRu nner::ASYNC_EXECUTION);
391 395
392 if (i > 0) { 396 if (i > 0) {
393 EXPECT_CALL(*scriptLoaders[i], execute()).WillOnce(Invoke([this, i] { 397 EXPECT_CALL(*scriptLoaders[i], execute()).WillOnce(Invoke([this, i] {
394 m_order.push_back(i); 398 m_order.push_back(i);
395 })); 399 }));
396 } 400 }
397 } 401 }
398 402
399 m_scriptRunner->notifyScriptReady(scriptLoaders[0].get(), ScriptRunner::ASYN C_EXECUTION); 403 m_scriptRunner->notifyScriptReady(scriptLoaders[0].get(), ScriptRunner::ASYN C_EXECUTION);
400 m_scriptRunner->notifyScriptReady(scriptLoaders[1].get(), ScriptRunner::ASYN C_EXECUTION); 404 m_scriptRunner->notifyScriptReady(scriptLoaders[1].get(), ScriptRunner::ASYN C_EXECUTION);
401 m_scriptRunner->resume(); 405 m_scriptRunner->resume();
402 406
403 EXPECT_CALL(*scriptLoaders[0], execute()).WillOnce(Invoke([&scriptLoaders, t his] { 407 EXPECT_CALL(*scriptLoaders[0], execute()).WillOnce(Invoke([&scriptLoaders, t his] {
404 for (int i = 2; i < 20; i++) 408 for (int i = 2; i < loaderCount; i++)
405 m_scriptRunner->notifyScriptReady(scriptLoaders[i].get(), ScriptRunn er::ASYNC_EXECUTION); 409 m_scriptRunner->notifyScriptReady(scriptLoaders[i].get(), ScriptRunn er::ASYNC_EXECUTION);
406 m_scriptRunner->resume(); 410 m_scriptRunner->resume();
407 m_order.push_back(0); 411 m_order.push_back(0);
408 })); 412 }));
409 413
410 m_platform.runAllTasks(); 414 m_platform.runAllTasks();
411 415
412 int expected[] = { 416 int expected[] = {
413 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 417 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
414 }; 418 };
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 testing::Mock::VerifyAndClear(&scriptLoader2); 510 testing::Mock::VerifyAndClear(&scriptLoader2);
507 testing::Mock::VerifyAndClear(&scriptLoader3); 511 testing::Mock::VerifyAndClear(&scriptLoader3);
508 EXPECT_CALL(scriptLoader2, execute()).Times(1); 512 EXPECT_CALL(scriptLoader2, execute()).Times(1);
509 EXPECT_CALL(scriptLoader3, execute()).Times(1); 513 EXPECT_CALL(scriptLoader3, execute()).Times(1);
510 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true)); 514 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true));
511 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true)); 515 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true));
512 m_platform.runAllTasks(); 516 m_platform.runAllTasks();
513 } 517 }
514 518
515 } // namespace blink 519 } // 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