| 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 "platform/LayoutTestSupport.h" | 8 #include "platform/LayoutTestSupport.h" |
| 9 #include "platform/scroll/ScrollbarTheme.h" | 9 #include "platform/scroll/ScrollbarTheme.h" |
| 10 #include "platform/testing/UnitTestHelpers.h" |
| 10 #include "public/platform/WebSecurityOrigin.h" | 11 #include "public/platform/WebSecurityOrigin.h" |
| 11 #include "public/web/WebCache.h" | 12 #include "public/web/WebCache.h" |
| 12 #include "web/WebLocalFrameImpl.h" | 13 #include "web/WebLocalFrameImpl.h" |
| 13 #include "web/WebViewImpl.h" | 14 #include "web/WebViewImpl.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 SimTest::SimTest() | 18 SimTest::SimTest() |
| 18 : m_webViewClient(m_compositor) | 19 : m_webViewClient(m_compositor) |
| 19 { | 20 { |
| 20 Document::setThreadedParsingEnabledForTesting(false); | 21 Document::setThreadedParsingEnabledForTesting(false); |
| 21 // Use the mock theme to get more predictable code paths, this also avoids | 22 // Use the mock theme to get more predictable code paths, this also avoids |
| 22 // the OS callbacks in ScrollAnimatorMac which can schedule frames | 23 // the OS callbacks in ScrollAnimatorMac which can schedule frames |
| 23 // unpredictably since the OS will randomly call into blink for | 24 // unpredictably since the OS will randomly call into blink for |
| 24 // updateScrollerStyleForNewRecommendedScrollerStyle which then does | 25 // updateScrollerStyleForNewRecommendedScrollerStyle which then does |
| 25 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence | 26 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence |
| 26 // in the middle of a test. | 27 // in the middle of a test. |
| 27 LayoutTestSupport::setMockThemeEnabledForTest(true); | 28 LayoutTestSupport::setMockThemeEnabledForTest(true); |
| 28 ScrollbarTheme::setMockScrollbarsEnabled(true); | 29 ScrollbarTheme::setMockScrollbarsEnabled(true); |
| 29 m_webViewHelper.initialize(true, nullptr, &m_webViewClient); | 30 m_webViewHelper.initialize(true, nullptr, &m_webViewClient); |
| 30 m_compositor.setWebViewImpl(webView()); | 31 m_compositor.setWebViewImpl(webView()); |
| 31 } | 32 } |
| 32 | 33 |
| 33 SimTest::~SimTest() | 34 SimTest::~SimTest() |
| 34 { | 35 { |
| 36 // Pump the message loop to process the load event. |
| 37 testing::runPendingTasks(); |
| 38 |
| 35 Document::setThreadedParsingEnabledForTesting(true); | 39 Document::setThreadedParsingEnabledForTesting(true); |
| 36 LayoutTestSupport::setMockThemeEnabledForTest(false); | 40 LayoutTestSupport::setMockThemeEnabledForTest(false); |
| 37 ScrollbarTheme::setMockScrollbarsEnabled(false); | 41 ScrollbarTheme::setMockScrollbarsEnabled(false); |
| 38 WebCache::clear(); | 42 WebCache::clear(); |
| 39 } | 43 } |
| 40 | 44 |
| 41 void SimTest::loadURL(const String& url) | 45 void SimTest::loadURL(const String& url) |
| 42 { | 46 { |
| 43 WebURLRequest request; | 47 WebURLRequest request; |
| 44 request.setURL(KURL(ParsedURLString, url)); | 48 request.setURL(KURL(ParsedURLString, url)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 { | 64 { |
| 61 return m_webViewClient; | 65 return m_webViewClient; |
| 62 } | 66 } |
| 63 | 67 |
| 64 SimCompositor& SimTest::compositor() | 68 SimCompositor& SimTest::compositor() |
| 65 { | 69 { |
| 66 return m_compositor; | 70 return m_compositor; |
| 67 } | 71 } |
| 68 | 72 |
| 69 } // namespace blink | 73 } // namespace blink |
| OLD | NEW |