OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 18 matching lines...) Expand all Loading... | |
29 */ | 29 */ |
30 | 30 |
31 #include "core/layout/LayoutGeometryMap.h" | 31 #include "core/layout/LayoutGeometryMap.h" |
32 | 32 |
33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
34 #include "core/layout/LayoutBox.h" | 34 #include "core/layout/LayoutBox.h" |
35 #include "core/layout/LayoutView.h" | 35 #include "core/layout/LayoutView.h" |
36 #include "core/paint/PaintLayer.h" | 36 #include "core/paint/PaintLayer.h" |
37 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 37 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
38 #include "platform/testing/URLTestHelpers.h" | 38 #include "platform/testing/URLTestHelpers.h" |
39 #include "platform/testing/UnitTestHelpers.h" | |
39 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
40 #include "public/platform/WebURLLoaderMockFactory.h" | 41 #include "public/platform/WebURLLoaderMockFactory.h" |
41 #include "public/web/WebCache.h" | 42 #include "public/web/WebCache.h" |
42 #include "public/web/WebFrameClient.h" | 43 #include "public/web/WebFrameClient.h" |
43 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
44 #include "web/WebLocalFrameImpl.h" | 45 #include "web/WebLocalFrameImpl.h" |
45 #include "web/tests/FrameTestHelpers.h" | 46 #include "web/tests/FrameTestHelpers.h" |
46 | 47 |
47 namespace blink { | 48 namespace blink { |
48 | 49 |
49 typedef bool TestParamRootLayerScrolling; | 50 typedef bool TestParamRootLayerScrolling; |
50 class LayoutGeometryMapTest | 51 class LayoutGeometryMapTest |
51 : public testing::Test, | 52 : public ::testing::Test, |
52 public testing::WithParamInterface<TestParamRootLayerScrolling>, | 53 public ::testing::WithParamInterface<TestParamRootLayerScrolling>, |
53 private ScopedRootLayerScrollingForTest { | 54 private ScopedRootLayerScrollingForTest { |
54 public: | 55 public: |
55 LayoutGeometryMapTest() | 56 LayoutGeometryMapTest() |
56 : ScopedRootLayerScrollingForTest(GetParam()), | 57 : ScopedRootLayerScrollingForTest(GetParam()), |
57 m_baseURL("http://www.test.com/") {} | 58 m_baseURL("http://www.test.com/") {} |
58 | 59 |
59 void TearDown() override { | 60 void TearDown() override { |
60 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 61 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
61 WebCache::clear(); | 62 WebCache::clear(); |
62 } | 63 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 const FloatRect& rect) { | 152 const FloatRect& rect) { |
152 FloatRect result(rect); | 153 FloatRect result(rect); |
153 LocalFrame* frame = toWebViewImpl(webView)->mainFrameImpl()->frame(); | 154 LocalFrame* frame = toWebViewImpl(webView)->mainFrameImpl()->frame(); |
154 LayoutView* layoutView = frame->document()->layoutView(); | 155 LayoutView* layoutView = frame->document()->layoutView(); |
155 if (layoutView->hasOverflowClip()) | 156 if (layoutView->hasOverflowClip()) |
156 result.move(layoutView->scrolledContentOffset()); | 157 result.move(layoutView->scrolledContentOffset()); |
157 return result; | 158 return result; |
158 } | 159 } |
159 | 160 |
160 void registerMockedHttpURLLoad(const std::string& fileName) { | 161 void registerMockedHttpURLLoad(const std::string& fileName) { |
161 URLTestHelpers::registerMockedURLFromBaseURL( | 162 URLTestHelpers::registerMockedURLLoadFromBase( |
162 WebString::fromUTF8(m_baseURL.c_str()), | 163 WebString::fromUTF8(m_baseURL.c_str()), testing::webTestDataPath(), |
163 WebString::fromUTF8(fileName.c_str())); | 164 WebString::fromUTF8(fileName.c_str())); |
kinuko
2017/01/26 09:32:41
Not from your change, but no need of .c_str() (and
Takashi Toyoshima
2017/01/26 10:57:58
Done.
| |
164 } | 165 } |
165 | 166 |
166 const std::string m_baseURL; | 167 const std::string m_baseURL; |
167 FrameTestHelpers::TestWebFrameClient m_mockWebViewClient; | 168 FrameTestHelpers::TestWebFrameClient m_mockWebViewClient; |
168 }; | 169 }; |
169 | 170 |
170 INSTANTIATE_TEST_CASE_P(All, LayoutGeometryMapTest, ::testing::Bool()); | 171 INSTANTIATE_TEST_CASE_P(All, LayoutGeometryMapTest, ::testing::Bool()); |
171 | 172 |
172 TEST_P(LayoutGeometryMapTest, SimpleGeometryMapTest) { | 173 TEST_P(LayoutGeometryMapTest, SimpleGeometryMapTest) { |
173 registerMockedHttpURLLoad("rgm_test.html"); | 174 registerMockedHttpURLLoad("rgm_test.html"); |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 EXPECT_EQ(FloatRect(263.0f, 154.0f, 10.0f, 8.0f), | 528 EXPECT_EQ(FloatRect(263.0f, 154.0f, 10.0f, 8.0f), |
528 rectFromQuad(rgm.mapToAncestor(rect, nullptr))); | 529 rectFromQuad(rgm.mapToAncestor(rect, nullptr))); |
529 | 530 |
530 rgm.pushMappingsToAncestor(floating, span); | 531 rgm.pushMappingsToAncestor(floating, span); |
531 EXPECT_EQ(rect, rectFromQuad(rgm.mapToAncestor(rect, container))); | 532 EXPECT_EQ(rect, rectFromQuad(rgm.mapToAncestor(rect, container))); |
532 EXPECT_EQ(FloatRect(63.0f, 54.0f, 10.0f, 8.0f), | 533 EXPECT_EQ(FloatRect(63.0f, 54.0f, 10.0f, 8.0f), |
533 rectFromQuad(rgm.mapToAncestor(rect, nullptr))); | 534 rectFromQuad(rgm.mapToAncestor(rect, nullptr))); |
534 } | 535 } |
535 | 536 |
536 } // namespace blink | 537 } // namespace blink |
OLD | NEW |