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

Side by Side Diff: third_party/WebKit/Source/web/tests/sim/SimTest.cpp

Issue 2521043003: Replace LayoutTests/paint/invalidation/text-selection-focus.html with a SimTest. (Closed)
Patch Set: copyrights. Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/web/tests/sim/SimTest.h ('k') | 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 "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 "platform/LayoutTestSupport.h" 9 #include "platform/LayoutTestSupport.h"
9 #include "platform/scroll/ScrollbarTheme.h" 10 #include "platform/scroll/ScrollbarTheme.h"
10 #include "platform/testing/UnitTestHelpers.h" 11 #include "platform/testing/UnitTestHelpers.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() : m_webViewClient(m_compositor) { 18 SimTest::SimTest() : m_webViewClient(m_compositor) {
18 Document::setThreadedParsingEnabledForTesting(false); 19 Document::setThreadedParsingEnabledForTesting(false);
19 // Use the mock theme to get more predictable code paths, this also avoids 20 // Use the mock theme to get more predictable code paths, this also avoids
20 // the OS callbacks in ScrollAnimatorMac which can schedule frames 21 // the OS callbacks in ScrollAnimatorMac which can schedule frames
21 // unpredictably since the OS will randomly call into blink for 22 // unpredictably since the OS will randomly call into blink for
22 // updateScrollerStyleForNewRecommendedScrollerStyle which then does 23 // updateScrollerStyleForNewRecommendedScrollerStyle which then does
23 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence 24 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence
24 // in the middle of a test. 25 // in the middle of a test.
25 LayoutTestSupport::setMockThemeEnabledForTest(true); 26 LayoutTestSupport::setMockThemeEnabledForTest(true);
26 ScrollbarTheme::setMockScrollbarsEnabled(true); 27 ScrollbarTheme::setMockScrollbarsEnabled(true);
27 m_webViewHelper.initialize(true, nullptr, &m_webViewClient); 28 m_webViewHelper.initialize(true, nullptr, &m_webViewClient);
28 m_compositor.setWebViewImpl(webView()); 29 m_compositor.setWebViewImpl(webView());
30 m_page.setPage(webView().page());
29 } 31 }
30 32
31 SimTest::~SimTest() { 33 SimTest::~SimTest() {
32 // Pump the message loop to process the load event. 34 // Pump the message loop to process the load event.
33 testing::runPendingTasks(); 35 testing::runPendingTasks();
34 36
35 Document::setThreadedParsingEnabledForTesting(true); 37 Document::setThreadedParsingEnabledForTesting(true);
36 LayoutTestSupport::setMockThemeEnabledForTest(false); 38 LayoutTestSupport::setMockThemeEnabledForTest(false);
37 ScrollbarTheme::setMockScrollbarsEnabled(false); 39 ScrollbarTheme::setMockScrollbarsEnabled(false);
38 WebCache::clear(); 40 WebCache::clear();
39 } 41 }
40 42
41 void SimTest::loadURL(const String& url) { 43 void SimTest::loadURL(const String& url) {
42 WebURLRequest request(KURL(ParsedURLString, url)); 44 WebURLRequest request(KURL(ParsedURLString, url));
43 webView().mainFrameImpl()->loadRequest(request); 45 webView().mainFrameImpl()->loadRequest(request);
44 } 46 }
45 47
48 LocalDOMWindow& SimTest::window() {
ojan 2016/11/22 00:46:27 This really makes me want a WebModules thing or so
49 return *document().domWindow();
50 }
51
52 SimPage& SimTest::page() {
53 return m_page;
54 }
55
46 Document& SimTest::document() { 56 Document& SimTest::document() {
47 return *webView().mainFrameImpl()->frame()->document(); 57 return *webView().mainFrameImpl()->frame()->document();
48 } 58 }
49 59
50 WebViewImpl& SimTest::webView() { 60 WebViewImpl& SimTest::webView() {
51 return *m_webViewHelper.webView(); 61 return *m_webViewHelper.webView();
52 } 62 }
53 63
54 const SimWebViewClient& SimTest::webViewClient() const { 64 const SimWebViewClient& SimTest::webViewClient() const {
55 return m_webViewClient; 65 return m_webViewClient;
56 } 66 }
57 67
58 SimCompositor& SimTest::compositor() { 68 SimCompositor& SimTest::compositor() {
59 return m_compositor; 69 return m_compositor;
60 } 70 }
61 71
62 } // namespace blink 72 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/sim/SimTest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698