| 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 "web/tests/sim/SimTest.h" | 5 #include "web/tests/sim/SimTest.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/LocalDOMWindow.h" | 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "platform/LayoutTestSupport.h" | 9 #include "platform/LayoutTestSupport.h" |
| 10 #include "platform/scroll/ScrollbarTheme.h" | 10 #include "platform/scroll/ScrollbarTheme.h" |
| 11 #include "platform/testing/UnitTestHelpers.h" | 11 #include "platform/testing/UnitTestHelpers.h" |
| 12 #include "public/platform/WebCache.h" | 12 #include "public/platform/WebCache.h" |
| 13 #include "web/WebLocalFrameImpl.h" | 13 #include "web/WebLocalFrameImpl.h" |
| 14 #include "web/WebViewImpl.h" | 14 #include "web/WebViewImpl.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 SimTest::SimTest() : m_webViewClient(m_compositor) { | 18 SimTest::SimTest() : SimTest(nullptr) { |
| 19 } |
| 20 |
| 21 SimTest::SimTest(void (*updateSettingsFunc)(WebSettings*)) : m_webViewClient(m_c
ompositor) { |
| 19 Document::setThreadedParsingEnabledForTesting(false); | 22 Document::setThreadedParsingEnabledForTesting(false); |
| 20 // Use the mock theme to get more predictable code paths, this also avoids | 23 // Use the mock theme to get more predictable code paths, this also avoids |
| 21 // the OS callbacks in ScrollAnimatorMac which can schedule frames | 24 // the OS callbacks in ScrollAnimatorMac which can schedule frames |
| 22 // unpredictably since the OS will randomly call into blink for | 25 // unpredictably since the OS will randomly call into blink for |
| 23 // updateScrollerStyleForNewRecommendedScrollerStyle which then does | 26 // updateScrollerStyleForNewRecommendedScrollerStyle which then does |
| 24 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence | 27 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence |
| 25 // in the middle of a test. | 28 // in the middle of a test. |
| 26 LayoutTestSupport::setMockThemeEnabledForTest(true); | 29 LayoutTestSupport::setMockThemeEnabledForTest(true); |
| 27 ScrollbarTheme::setMockScrollbarsEnabled(true); | 30 ScrollbarTheme::setMockScrollbarsEnabled(true); |
| 28 m_webViewHelper.initialize(true, nullptr, &m_webViewClient); | 31 m_webViewHelper.initialize(true, nullptr, &m_webViewClient, nullptr, updateSet
tingsFunc); |
| 29 m_compositor.setWebViewImpl(webView()); | 32 m_compositor.setWebViewImpl(webView()); |
| 30 m_page.setPage(webView().page()); | 33 m_page.setPage(webView().page()); |
| 31 } | 34 } |
| 32 | 35 |
| 33 SimTest::~SimTest() { | 36 SimTest::~SimTest() { |
| 34 // Pump the message loop to process the load event. | 37 // Pump the message loop to process the load event. |
| 35 testing::runPendingTasks(); | 38 testing::runPendingTasks(); |
| 36 | 39 |
| 37 Document::setThreadedParsingEnabledForTesting(true); | 40 Document::setThreadedParsingEnabledForTesting(true); |
| 38 LayoutTestSupport::setMockThemeEnabledForTest(false); | 41 LayoutTestSupport::setMockThemeEnabledForTest(false); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 67 | 70 |
| 68 const SimWebViewClient& SimTest::webViewClient() const { | 71 const SimWebViewClient& SimTest::webViewClient() const { |
| 69 return m_webViewClient; | 72 return m_webViewClient; |
| 70 } | 73 } |
| 71 | 74 |
| 72 SimCompositor& SimTest::compositor() { | 75 SimCompositor& SimTest::compositor() { |
| 73 return m_compositor; | 76 return m_compositor; |
| 74 } | 77 } |
| 75 | 78 |
| 76 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |