| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 6 |
| 7 #include "core/frame/PinchViewport.h" | 7 #include "core/frame/PinchViewport.h" |
| 8 | 8 |
| 9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 do { \ | 45 do { \ |
| 46 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ | 46 EXPECT_FLOAT_EQ((expected).x(), (actual).x()); \ |
| 47 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ | 47 EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \ |
| 48 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ | 48 EXPECT_FLOAT_EQ((expected).width(), (actual).width()); \ |
| 49 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ | 49 EXPECT_FLOAT_EQ((expected).height(), (actual).height()); \ |
| 50 } while (false) | 50 } while (false) |
| 51 | 51 |
| 52 | 52 |
| 53 using namespace WebCore; | 53 using namespace WebCore; |
| 54 using namespace blink; | 54 using namespace blink; |
| 55 using blink::FrameTestHelpers::runPendingTasks; | |
| 56 | 55 |
| 57 namespace { | 56 namespace { |
| 58 | 57 |
| 59 class PinchViewportTest : public testing::Test { | 58 class PinchViewportTest : public testing::Test { |
| 60 public: | 59 public: |
| 61 PinchViewportTest() | 60 PinchViewportTest() |
| 62 : m_baseURL("http://www.test.com/") | 61 : m_baseURL("http://www.test.com/") |
| 63 { | 62 { |
| 64 } | 63 } |
| 65 | 64 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 76 } | 75 } |
| 77 | 76 |
| 78 virtual ~PinchViewportTest() | 77 virtual ~PinchViewportTest() |
| 79 { | 78 { |
| 80 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 79 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 void navigateTo(const std::string& url) | 82 void navigateTo(const std::string& url) |
| 84 { | 83 { |
| 85 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url); | 84 FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url); |
| 86 Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests(
); | |
| 87 } | 85 } |
| 88 | 86 |
| 89 void forceFullCompositingUpdate() | 87 void forceFullCompositingUpdate() |
| 90 { | 88 { |
| 91 webViewImpl()->layout(); | 89 webViewImpl()->layout(); |
| 92 } | 90 } |
| 93 | 91 |
| 94 void registerMockedHttpURLLoad(const std::string& fileName) | 92 void registerMockedHttpURLLoad(const std::string& fileName) |
| 95 { | 93 { |
| 96 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 94 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| 97 } | 95 } |
| 98 | 96 |
| 99 void executeScript(const WebString& code) | |
| 100 { | |
| 101 webViewImpl()->mainFrame()->executeScript(WebScriptSource(code)); | |
| 102 runPendingTasks(); | |
| 103 } | |
| 104 | |
| 105 WebLayer* getRootScrollLayer() | 97 WebLayer* getRootScrollLayer() |
| 106 { | 98 { |
| 107 RenderLayerCompositor* compositor = frame()->contentRenderer()->composit
or(); | 99 RenderLayerCompositor* compositor = frame()->contentRenderer()->composit
or(); |
| 108 ASSERT(compositor); | 100 ASSERT(compositor); |
| 109 ASSERT(compositor->scrollLayer()); | 101 ASSERT(compositor->scrollLayer()); |
| 110 | 102 |
| 111 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); | 103 WebLayer* webScrollLayer = compositor->scrollLayer()->platformLayer(); |
| 112 return webScrollLayer; | 104 return webScrollLayer; |
| 113 } | 105 } |
| 114 | 106 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 expected.scale(pinchViewport.scale(), pinchViewport.scale()); | 464 expected.scale(pinchViewport.scale(), pinchViewport.scale()); |
| 473 | 465 |
| 474 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); | 466 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); |
| 475 EXPECT_POINT_EQ(expected, IntRect(focus).location()); | 467 EXPECT_POINT_EQ(expected, IntRect(focus).location()); |
| 476 | 468 |
| 477 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text sele
ction | 469 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text sele
ction |
| 478 // as well rather than just carret. | 470 // as well rather than just carret. |
| 479 } | 471 } |
| 480 | 472 |
| 481 } // namespace | 473 } // namespace |
| OLD | NEW |