| 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 24 matching lines...) Expand all Loading... |
| 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 "platform/testing/UnitTestHelpers.h" |
| 40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
| 41 #include "public/platform/WebURLLoaderMockFactory.h" | 41 #include "public/platform/WebURLLoaderMockFactory.h" |
| 42 #include "public/web/WebFrameClient.h" | 42 #include "public/web/WebFrameClient.h" |
| 43 #include "testing/gtest/include/gtest/gtest.h" | 43 #include "testing/gtest/include/gtest/gtest.h" |
| 44 #include "web/WebLocalFrameImpl.h" | 44 #include "web/WebLocalFrameImpl.h" |
| 45 #include "web/WebViewImpl.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 base_url_("http://www.test.com/") {} | 58 base_url_("http://www.test.com/") {} |
| 58 | 59 |
| 59 void TearDown() override { | 60 void TearDown() override { |
| 60 Platform::Current() | 61 Platform::Current() |
| 61 ->GetURLLoaderMockFactory() | 62 ->GetURLLoaderMockFactory() |
| 62 ->UnregisterAllURLsAndClearMemoryCache(); | 63 ->UnregisterAllURLsAndClearMemoryCache(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 protected: | 66 protected: |
| 66 static LayoutBox* GetFrameElement(const char* iframe_name, | 67 static LayoutBox* GetFrameElement(const char* iframe_name, |
| 67 WebView* web_view, | 68 WebView* web_view, |
| 68 const WTF::AtomicString& element_id) { | 69 const WTF::AtomicString& element_id) { |
| 69 WebLocalFrameImpl* iframe = ToWebLocalFrameImpl( | 70 WebFrame* iframe = |
| 70 web_view->FindFrameByName(WebString::FromUTF8(iframe_name))); | 71 static_cast<WebViewImpl*>(web_view)->MainFrameImpl()->FindFrameByName( |
| 71 if (!iframe) | 72 WebString::FromUTF8(iframe_name)); |
| 73 if (!iframe || !iframe->IsWebLocalFrame()) |
| 72 return nullptr; | 74 return nullptr; |
| 73 LocalFrame* frame = iframe->GetFrame(); | 75 LocalFrame* frame = ToWebLocalFrameImpl(iframe)->GetFrame(); |
| 74 Document* doc = frame->GetDocument(); | 76 Document* doc = frame->GetDocument(); |
| 75 Element* element = doc->getElementById(element_id); | 77 Element* element = doc->getElementById(element_id); |
| 76 if (!element) | 78 if (!element) |
| 77 return nullptr; | 79 return nullptr; |
| 78 return element->GetLayoutBox(); | 80 return element->GetLayoutBox(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 static Element* GetElement(WebView* web_view, | 83 static Element* GetElement(WebView* web_view, |
| 82 const WTF::AtomicString& element_id) { | 84 const WTF::AtomicString& element_id) { |
| 83 WebViewBase* web_view_impl = static_cast<WebViewBase*>(web_view); | 85 WebViewBase* web_view_impl = static_cast<WebViewBase*>(web_view); |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 EXPECT_EQ(FloatRect(263.0f, 154.0f, 10.0f, 8.0f), | 531 EXPECT_EQ(FloatRect(263.0f, 154.0f, 10.0f, 8.0f), |
| 530 RectFromQuad(rgm.MapToAncestor(rect, nullptr))); | 532 RectFromQuad(rgm.MapToAncestor(rect, nullptr))); |
| 531 | 533 |
| 532 rgm.PushMappingsToAncestor(floating, span); | 534 rgm.PushMappingsToAncestor(floating, span); |
| 533 EXPECT_EQ(rect, RectFromQuad(rgm.MapToAncestor(rect, container))); | 535 EXPECT_EQ(rect, RectFromQuad(rgm.MapToAncestor(rect, container))); |
| 534 EXPECT_EQ(FloatRect(63.0f, 54.0f, 10.0f, 8.0f), | 536 EXPECT_EQ(FloatRect(63.0f, 54.0f, 10.0f, 8.0f), |
| 535 RectFromQuad(rgm.MapToAncestor(rect, nullptr))); | 537 RectFromQuad(rgm.MapToAncestor(rect, nullptr))); |
| 536 } | 538 } |
| 537 | 539 |
| 538 } // namespace blink | 540 } // namespace blink |
| OLD | NEW |