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