| 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/exported/WebViewBase.h" | 8 #include "core/exported/WebViewBase.h" |
| 9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 10 #include "platform/LayoutTestSupport.h" | 10 #include "platform/LayoutTestSupport.h" |
| 11 #include "platform/scroll/ScrollbarTheme.h" | 11 #include "platform/scroll/ScrollbarTheme.h" |
| 12 #include "platform/testing/UnitTestHelpers.h" | 12 #include "platform/testing/UnitTestHelpers.h" |
| 13 #include "public/platform/WebCache.h" | 13 #include "public/platform/WebCache.h" |
| 14 #include "web/WebLocalFrameImpl.h" | 14 #include "web/WebLocalFrameImpl.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 SimTest::SimTest() : web_view_client_(compositor_), web_frame_client_(*this) { | 18 SimTest::SimTest() : web_view_client_(compositor_), web_frame_client_(*this) { |
| 19 Document::SetThreadedParsingEnabledForTesting(false); | 19 Document::SetThreadedParsingEnabledForTesting(false); |
| 20 // 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 |
| 21 // the OS callbacks in ScrollAnimatorMac which can schedule frames | 21 // the OS callbacks in ScrollAnimatorMac which can schedule frames |
| 22 // unpredictably since the OS will randomly call into blink for | 22 // unpredictably since the OS will randomly call into blink for |
| 23 // updateScrollerStyleForNewRecommendedScrollerStyle which then does | 23 // updateScrollerStyleForNewRecommendedScrollerStyle which then does |
| 24 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence | 24 // FrameView::scrollbarStyleChanged and will adjust the scrollbar existence |
| 25 // in the middle of a test. | 25 // in the middle of a test. |
| 26 LayoutTestSupport::SetMockThemeEnabledForTest(true); | 26 LayoutTestSupport::SetMockThemeEnabledForTest(true); |
| 27 ScrollbarTheme::SetMockScrollbarsEnabled(true); | 27 ScrollbarTheme::SetMockScrollbarsEnabled(true); |
| 28 web_view_helper_.Initialize(true, &web_frame_client_, &web_view_client_); | |
| 29 compositor_.SetWebView(WebView()); | |
| 30 page_.SetPage(WebView().GetPage()); | |
| 31 } | 28 } |
| 32 | 29 |
| 33 SimTest::~SimTest() { | 30 SimTest::~SimTest() { |
| 34 // Pump the message loop to process the load event. | 31 // Pump the message loop to process the load event. |
| 35 testing::RunPendingTasks(); | 32 testing::RunPendingTasks(); |
| 36 | 33 |
| 37 Document::SetThreadedParsingEnabledForTesting(true); | 34 Document::SetThreadedParsingEnabledForTesting(true); |
| 38 LayoutTestSupport::SetMockThemeEnabledForTest(false); | 35 LayoutTestSupport::SetMockThemeEnabledForTest(false); |
| 39 ScrollbarTheme::SetMockScrollbarsEnabled(false); | 36 ScrollbarTheme::SetMockScrollbarsEnabled(false); |
| 40 WebCache::Clear(); | 37 WebCache::Clear(); |
| 41 } | 38 } |
| 42 | 39 |
| 40 void SimTest::SetUp() { |
| 41 Test::SetUp(); |
| 42 |
| 43 web_view_helper_.Initialize(true, &web_frame_client_, &web_view_client_); |
| 44 compositor_.SetWebView(WebView()); |
| 45 page_.SetPage(WebView().GetPage()); |
| 46 } |
| 47 |
| 43 void SimTest::LoadURL(const String& url) { | 48 void SimTest::LoadURL(const String& url) { |
| 44 WebURLRequest request(KURL(kParsedURLString, url)); | 49 WebURLRequest request(KURL(kParsedURLString, url)); |
| 45 WebView().MainFrameImpl()->LoadRequest(request); | 50 WebView().MainFrameImpl()->LoadRequest(request); |
| 46 } | 51 } |
| 47 | 52 |
| 48 LocalDOMWindow& SimTest::Window() { | 53 LocalDOMWindow& SimTest::Window() { |
| 49 return *GetDocument().domWindow(); | 54 return *GetDocument().domWindow(); |
| 50 } | 55 } |
| 51 | 56 |
| 52 SimPage& SimTest::Page() { | 57 SimPage& SimTest::Page() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 | 76 |
| 72 SimCompositor& SimTest::Compositor() { | 77 SimCompositor& SimTest::Compositor() { |
| 73 return compositor_; | 78 return compositor_; |
| 74 } | 79 } |
| 75 | 80 |
| 76 void SimTest::AddConsoleMessage(const String& message) { | 81 void SimTest::AddConsoleMessage(const String& message) { |
| 77 console_messages_.push_back(message); | 82 console_messages_.push_back(message); |
| 78 } | 83 } |
| 79 | 84 |
| 80 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |