Chromium Code Reviews| 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/ScriptLoader.h" | 9 #include "core/dom/ScriptLoader.h" |
| 10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 private: | 80 private: |
| 81 Deque<OwnPtr<WebThread::Task>> m_tasks; | 81 Deque<OwnPtr<WebThread::Task>> m_tasks; |
| 82 bool m_shouldYield; | 82 bool m_shouldYield; |
| 83 bool m_shouldYieldEveryOtherTime; | 83 bool m_shouldYieldEveryOtherTime; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 class ScriptRunnerTest : public testing::Test { | 86 class ScriptRunnerTest : public testing::Test { |
| 87 public: | 87 public: |
| 88 void SetUp() override | 88 void SetUp() override |
| 89 { | 89 { |
| 90 Scheduler::shutdown(); | |
|
Sami
2015/02/27 18:29:52
I wonder if we should have some testing helper for
| |
| 91 | |
| 92 m_oldPlatform = Platform::current(); | |
| 93 Platform::initialize(&m_platform); | |
| 90 m_document = Document::create(); | 94 m_document = Document::create(); |
| 91 m_element = m_document->createElement("foo", ASSERT_NO_EXCEPTION); | 95 m_element = m_document->createElement("foo", ASSERT_NO_EXCEPTION); |
| 92 | 96 |
| 93 m_scriptRunner = ScriptRunner::create(m_document.get()); | 97 m_scriptRunner = ScriptRunner::create(m_document.get()); |
| 94 m_oldPlatform = Platform::current(); | |
| 95 Platform::initialize(&m_platform); | |
| 96 m_platform.setShouldYield(false); | 98 m_platform.setShouldYield(false); |
| 97 m_platform.setShouldYieldEveryOtherTime(false); | 99 m_platform.setShouldYieldEveryOtherTime(false); |
| 98 } | 100 } |
| 99 | 101 |
| 100 void TearDown() override | 102 void TearDown() override |
| 101 { | 103 { |
| 102 m_scriptRunner.release(); | 104 m_scriptRunner.release(); |
| 103 Scheduler::shutdown(); | 105 Scheduler::shutdown(); |
| 104 Platform::initialize(m_oldPlatform); | 106 Platform::initialize(m_oldPlatform); |
| 105 } | 107 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 | 461 |
| 460 // We can't safely distruct ScriptRunner with unexecuted MockScriptLoaders ( real ScriptLoader is fine) so drain them. | 462 // We can't safely distruct ScriptRunner with unexecuted MockScriptLoaders ( real ScriptLoader is fine) so drain them. |
| 461 testing::Mock::VerifyAndClear(&scriptLoader2); | 463 testing::Mock::VerifyAndClear(&scriptLoader2); |
| 462 testing::Mock::VerifyAndClear(&scriptLoader3); | 464 testing::Mock::VerifyAndClear(&scriptLoader3); |
| 463 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true)); | 465 EXPECT_CALL(scriptLoader2, isReady()).WillRepeatedly(Return(true)); |
| 464 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true)); | 466 EXPECT_CALL(scriptLoader3, isReady()).WillRepeatedly(Return(true)); |
| 465 m_platform.runAllTasks(); | 467 m_platform.runAllTasks(); |
| 466 } | 468 } |
| 467 | 469 |
| 468 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |