diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 10:22:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:36:28 +0000 |
commit | 271a6c3487a14599023a9106329505597638d793 (patch) | |
tree | e040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/third_party/blink/renderer/core/layout/ng/geometry/ng_static_position_test.cc | |
parent | 7b2ffa587235a47d4094787d72f38102089f402a (diff) | |
download | qtwebengine-chromium-271a6c3487a14599023a9106329505597638d793.tar.gz |
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/layout/ng/geometry/ng_static_position_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/layout/ng/geometry/ng_static_position_test.cc | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/layout/ng/geometry/ng_static_position_test.cc b/chromium/third_party/blink/renderer/core/layout/ng/geometry/ng_static_position_test.cc new file mode 100644 index 00000000000..09b282a01ed --- /dev/null +++ b/chromium/third_party/blink/renderer/core/layout/ng/geometry/ng_static_position_test.cc @@ -0,0 +1,194 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/layout/ng/geometry/ng_static_position.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" + +namespace blink { +namespace { + +using InlineEdge = NGLogicalStaticPosition::InlineEdge; +using BlockEdge = NGLogicalStaticPosition::BlockEdge; +using HorizontalEdge = NGPhysicalStaticPosition::HorizontalEdge; +using VerticalEdge = NGPhysicalStaticPosition::VerticalEdge; + +struct NGStaticPositionTestData { + NGLogicalStaticPosition logical; + NGPhysicalStaticPosition physical; + WritingMode writing_mode; + TextDirection direction; + +} ng_static_position_test_data[] = { + // |WritingMode::kHorizontalTb|, |TextDirection::kLtr| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(20, 30), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kHorizontalTb, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(20, 30), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kHorizontalTb, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(20, 30), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kHorizontalTb, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(20, 30), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kHorizontalTb, + TextDirection::kLtr}, + // |WritingMode::kHorizontalTb|, |TextDirection::kRtl| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(80, 30), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kHorizontalTb, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(80, 30), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kHorizontalTb, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(80, 30), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kHorizontalTb, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(80, 30), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kHorizontalTb, + TextDirection::kRtl}, + // |WritingMode::kVerticalRl|, |TextDirection::kLtr| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(70, 20), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kVerticalRl, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(70, 20), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kVerticalRl, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(70, 20), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kVerticalRl, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(70, 20), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kVerticalRl, + TextDirection::kLtr}, + // |WritingMode::kVerticalRl|, |TextDirection::kRtl| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(70, 80), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kVerticalRl, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(70, 80), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kVerticalRl, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(70, 80), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kVerticalRl, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(70, 80), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kVerticalRl, + TextDirection::kRtl}, + // |WritingMode::kVerticalLr|, |TextDirection::kLtr| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 20), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kVerticalLr, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 20), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kVerticalLr, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 20), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kVerticalLr, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 20), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kVerticalLr, + TextDirection::kLtr}, + // |WritingMode::kVerticalLr|, |TextDirection::kRtl| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 80), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kVerticalLr, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 80), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kVerticalLr, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 80), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kVerticalLr, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 80), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kVerticalLr, + TextDirection::kRtl}, + // |WritingMode::kSidewaysLr|, |TextDirection::kLtr| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 80), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kSidewaysLr, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 80), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kSidewaysLr, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 80), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kSidewaysLr, + TextDirection::kLtr}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 80), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kSidewaysLr, + TextDirection::kLtr}, + // |WritingMode::kSidewaysLr|, |TextDirection::kRtl| + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 20), HorizontalEdge::kLeft, VerticalEdge::kTop}, + WritingMode::kSidewaysLr, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockStart}, + {PhysicalOffset(30, 20), HorizontalEdge::kLeft, VerticalEdge::kBottom}, + WritingMode::kSidewaysLr, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineStart, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 20), HorizontalEdge::kRight, VerticalEdge::kTop}, + WritingMode::kSidewaysLr, + TextDirection::kRtl}, + {{LogicalOffset(20, 30), InlineEdge::kInlineEnd, BlockEdge::kBlockEnd}, + {PhysicalOffset(30, 20), HorizontalEdge::kRight, VerticalEdge::kBottom}, + WritingMode::kSidewaysLr, + TextDirection::kRtl}, +}; + +class NGStaticPositionTest + : public testing::Test, + public testing::WithParamInterface<NGStaticPositionTestData> {}; + +TEST_P(NGStaticPositionTest, Convert) { + const auto& data = GetParam(); + + // These tests take the logical static-position, and convert it to a physical + // static-position with a 100x100 rect. + // + // It asserts that it is the same as the expected physical static-position, + // then performs the same operation in reverse. + + NGPhysicalStaticPosition physical_result = data.logical.ConvertToPhysical( + data.writing_mode, data.direction, PhysicalSize(100, 100)); + EXPECT_EQ(physical_result.offset, data.physical.offset); + EXPECT_EQ(physical_result.horizontal_edge, data.physical.horizontal_edge); + EXPECT_EQ(physical_result.vertical_edge, data.physical.vertical_edge); + + NGLogicalStaticPosition logical_result = data.physical.ConvertToLogical( + data.writing_mode, data.direction, PhysicalSize(100, 100)); + EXPECT_EQ(logical_result.offset, data.logical.offset); + EXPECT_EQ(logical_result.inline_edge, data.logical.inline_edge); + EXPECT_EQ(logical_result.block_edge, data.logical.block_edge); +} + +INSTANTIATE_TEST_SUITE_P(NGStaticPositionTest, + NGStaticPositionTest, + testing::ValuesIn(ng_static_position_test_data)); + +} // namespace +} // namespace blink |