OLD | NEW |
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/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "core/dom/ScriptLoader.h" | 10 #include "core/dom/ScriptLoader.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 private: | 81 private: |
82 Deque<OwnPtr<WebThread::Task>> m_tasks; | 82 Deque<OwnPtr<WebThread::Task>> m_tasks; |
83 bool m_shouldYield; | 83 bool m_shouldYield; |
84 bool m_shouldYieldEveryOtherTime; | 84 bool m_shouldYieldEveryOtherTime; |
85 }; | 85 }; |
86 | 86 |
87 class ScriptRunnerTest : public testing::Test { | 87 class ScriptRunnerTest : public testing::Test { |
88 public: | 88 public: |
89 void SetUp() override | 89 void SetUp() override |
90 { | 90 { |
| 91 Scheduler::shutdown(); |
| 92 |
| 93 m_oldPlatform = Platform::current(); |
| 94 Platform::initialize(&m_platform); |
91 m_document = Document::create(); | 95 m_document = Document::create(); |
92 m_element = m_document->createElement("foo", ASSERT_NO_EXCEPTION); | 96 m_element = m_document->createElement("foo", ASSERT_NO_EXCEPTION); |
93 | 97 |
94 m_scriptRunner = ScriptRunner::create(m_document.get()); | 98 m_scriptRunner = ScriptRunner::create(m_document.get()); |
95 m_oldPlatform = Platform::current(); | 99 m_oldPlatform = Platform::current(); |
96 m_oldScheduler = Scheduler::shared(); | 100 m_oldScheduler = Scheduler::shared(); |
97 | 101 |
98 // Force Platform::initialize to create a new one pointing at MockPlatfo
rm. | 102 // Force Platform::initialize to create a new one pointing at MockPlatfo
rm. |
99 Scheduler::setForTesting(nullptr); | 103 Scheduler::setForTesting(nullptr); |
100 Platform::initialize(&m_platform); | 104 Platform::initialize(&m_platform); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 testing::Mock::VerifyAndClear(&scriptLoader2); | 514 testing::Mock::VerifyAndClear(&scriptLoader2); |
511 testing::Mock::VerifyAndClear(&scriptLoader3); | 515 testing::Mock::VerifyAndClear(&scriptLoader3); |
512 EXPECT_CALL(scriptLoader2, execute()).Times(1); | 516 EXPECT_CALL(scriptLoader2, execute()).Times(1); |
513 EXPECT_CALL(scriptLoader3, execute()).Times(1); | 517 EXPECT_CALL(scriptLoader3, execute()).Times(1); |
514 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true)); | 518 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true)); |
515 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true)); | 519 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true)); |
516 m_platform.runAllTasks(); | 520 m_platform.runAllTasks(); |
517 } | 521 } |
518 | 522 |
519 } // namespace blink | 523 } // namespace blink |
OLD | NEW |