[pango/more-test-coverage: 8/8] tests: Check layout properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/more-test-coverage: 8/8] tests: Check layout properties
- Date: Tue, 6 Jul 2021 05:10:16 +0000 (UTC)
commit 61e977529e667f474d38143089cf607cbd790013
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jul 6 01:07:39 2021 -0400
tests: Check layout properties
Add more layout properties, and check them in test-layout.
Also print out directions and cursor positions.
Update existing tests, and add more.
tests/layouts/valid-1.expected | 4 +
tests/layouts/valid-10.expected | 37 ++++++
tests/layouts/valid-10.markup | 2 +
tests/layouts/valid-11.expected | 53 +++++++++
tests/layouts/valid-11.markup | 2 +
tests/layouts/valid-12.expected | 35 ++++++
tests/layouts/valid-12.markup | 2 +
tests/layouts/valid-13.expected | 35 ++++++
tests/layouts/valid-13.markup | 2 +
tests/layouts/valid-14.expected | 39 +++++++
tests/layouts/valid-14.markup | 2 +
tests/layouts/valid-2.expected | 4 +
tests/layouts/valid-3.expected | 4 +
tests/layouts/valid-4.expected | 4 +
tests/layouts/valid-5.expected | 4 +
tests/layouts/valid-6.expected | 4 +
tests/layouts/valid-7.expected | 43 +++++++
tests/layouts/valid-7.markup | 2 +
tests/layouts/valid-8.expected | 34 ++++++
tests/layouts/valid-8.markup | 2 +
tests/layouts/valid-9.expected | 49 ++++++++
tests/layouts/valid-9.markup | 2 +
tests/test-layout.c | 241 +++++++++++++++++++++++++++++++++++-----
23 files changed, 576 insertions(+), 30 deletions(-)
---
diff --git a/tests/layouts/valid-1.expected b/tests/layouts/valid-1.expected
index cbd07127..411c7560 100644
--- a/tests/layouts/valid-1.expected
+++ b/tests/layouts/valid-1.expected
@@ -19,6 +19,10 @@ range 41 2147483647
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0)
19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(0) 32(0) 33(0) 34(0) 35(0) 36(0)
37(0) 38(0) 39(0) 40(0) 41(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 47(1) 49(0)
+
--- lines
i=1, index=0, paragraph-start=1, dir=ltr 'This is a test of the automatic emergency brake!
diff --git a/tests/layouts/valid-10.expected b/tests/layouts/valid-10.expected
new file mode 100644
index 00000000..8280dec9
--- /dev/null
+++ b/tests/layouts/valid-10.expected
@@ -0,0 +1,37 @@
+Hello שלום Γειά σας
+
+--- parameters
+
+wrapped: 1
+ellipsized: 0
+lines: 3
+width: 102400
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 12(0) 10(0) 8(0) 14(0) 14(1) 17(0) 19(0) 21(0) 23(0) 24(0) 26(0) 28(0)
28(1) 31(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'Hello שלום '
+i=2, index=15, paragraph-start=0, dir=ltr 'Γειά σας
+'
+i=3, index=31, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
+i=2, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
+i=3, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
+i=4, index=15, no run, line end
+i=5, index=15, chars=8, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά σας'
+i=6, index=30, no run, line end
+i=7, index=31, no run, line end
diff --git a/tests/layouts/valid-10.markup b/tests/layouts/valid-10.markup
new file mode 100644
index 00000000..b0cf2634
--- /dev/null
+++ b/tests/layouts/valid-10.markup
@@ -0,0 +1,2 @@
+width=100,justify=true
+Hello שלום Γειά σας
diff --git a/tests/layouts/valid-11.expected b/tests/layouts/valid-11.expected
new file mode 100644
index 00000000..a1fafc31
--- /dev/null
+++ b/tests/layouts/valid-11.expected
@@ -0,0 +1,53 @@
+double low error
+
+--- parameters
+
+wrapped: 0
+ellipsized: 0
+lines: 2
+width: 225280
+
+--- attributes
+
+range 0 6
+[0,6]underline=2
+[0,6]overline=1
+range 6 7
+range 7 10
+[7,10]underline=3
+[7,10]strikethrough=1
+range 10 11
+range 11 16
+[11,16]underline=4
+[11,16]rise=1024
+range 16 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 15(1) 17(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'double low error
+'
+i=2, index=17, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'double'
+[0,6]underline=2
+[0,6]overline=1
+i=2, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=3, index=7, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'low'
+[7,10]underline=3
+[7,10]strikethrough=1
+i=4, index=10, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, ' '
+i=5, index=11, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'error'
+[11,16]rise=1024
+[11,16]underline=4
+i=6, index=16, no run, line end
+i=7, index=17, no run, line end
diff --git a/tests/layouts/valid-11.markup b/tests/layouts/valid-11.markup
new file mode 100644
index 00000000..fbf1abd2
--- /dev/null
+++ b/tests/layouts/valid-11.markup
@@ -0,0 +1,2 @@
+width=220,wrap=char
+<span underline='double' overline='single'>double</span> <span underline='low'
strikethrough='true'>low</span> <span underline='error' rise='1024'>error</span>
diff --git a/tests/layouts/valid-12.expected b/tests/layouts/valid-12.expected
new file mode 100644
index 00000000..d66ae134
--- /dev/null
+++ b/tests/layouts/valid-12.expected
@@ -0,0 +1,35 @@
+a b c d
e f g h
+
+--- parameters
+
+wrapped: 1
+ellipsized: 0
+lines: 3
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0)
19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 25(1) 29(0) 30(0) 31(0) 32(0) 33(0) 34(0) 35(0) 36(0) 37(0) 38(0)
39(0) 40(0) 41(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 50(1) 52(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'a b c d
'
+i=2, index=28, paragraph-start=0, dir=ltr 'e f g h
+'
+i=3, index=52, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'a
b c d'
+i=2, index=25, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
'
+i=3, index=28, no run, line end
+i=4, index=28, chars=23, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'e
f g h'
+i=5, index=51, no run, line end
+i=6, index=52, no run, line end
diff --git a/tests/layouts/valid-12.markup b/tests/layouts/valid-12.markup
new file mode 100644
index 00000000..b7306cc6
--- /dev/null
+++ b/tests/layouts/valid-12.markup
@@ -0,0 +1,2 @@
+wrap=word,tabs=0 50 100 150 200
+a b c d
e f g h
diff --git a/tests/layouts/valid-13.expected b/tests/layouts/valid-13.expected
new file mode 100644
index 00000000..3064610d
--- /dev/null
+++ b/tests/layouts/valid-13.expected
@@ -0,0 +1,35 @@
+a b c d
e f g h
+
+--- parameters
+
+wrapped: 0
+ellipsized: 0
+lines: 1
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0)
19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 28(0) 29(0) 30(0) 31(0) 32(0) 33(0) 34(0) 35(0) 36(0) 37(0) 38(0)
39(0) 40(0) 41(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 51(1)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'a b c d
e f g h
+'
+
+--- runs
+
+i=1, index=0, chars=25, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'a
b c d'
+[0,-1]show=2
+i=2, index=25, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
'
+[0,-1]show=2
+i=3, index=28, chars=24, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'e
f g h
+'
+[0,-1]show=2
+i=4, index=52, no run, line end
diff --git a/tests/layouts/valid-13.markup b/tests/layouts/valid-13.markup
new file mode 100644
index 00000000..be2345d1
--- /dev/null
+++ b/tests/layouts/valid-13.markup
@@ -0,0 +1,2 @@
+wrap=word,tabs=0 50 100 150 200,single_paragraph=true
+a b c d
e f g h
diff --git a/tests/layouts/valid-14.expected b/tests/layouts/valid-14.expected
new file mode 100644
index 00000000..9c4d5111
--- /dev/null
+++ b/tests/layouts/valid-14.expected
@@ -0,0 +1,39 @@
+你好 Hello שלום Γειά σας
+
+--- parameters
+
+wrapped: 0
+ellipsized: 1
+lines: 2
+width: 166912
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 3(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 19(0) 17(0) 15(0) 21(0) 22(0) 24(0) 26(0) 28(0) 30(0)
31(0) 33(0) 35(0) 35(1) 38(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr '你好 Hello שלום Γειά σας
+'
+i=2, index=38, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=1, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, '你'
+[0,2147483647]fallback=1
+i=2, index=3, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, '好'
+i=3, index=6, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=han, language=xx, ' '
+i=4, index=7, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
+i=5, index=19, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
+i=6, index=21, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
+i=7, index=22, chars=8, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά σας'
+i=8, index=37, no run, line end
+i=9, index=38, no run, line end
diff --git a/tests/layouts/valid-14.markup b/tests/layouts/valid-14.markup
new file mode 100644
index 00000000..48412c04
--- /dev/null
+++ b/tests/layouts/valid-14.markup
@@ -0,0 +1,2 @@
+line_spacing=1.5,width=163,ellipsize=start
+你好 Hello שלום Γειά σας
diff --git a/tests/layouts/valid-2.expected b/tests/layouts/valid-2.expected
index 4b8e793d..b71f5da3 100644
--- a/tests/layouts/valid-2.expected
+++ b/tests/layouts/valid-2.expected
@@ -20,6 +20,10 @@ range 25 2147483647
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0)
19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(0) 31(1) 33(0)
+
--- lines
i=1, index=0, paragraph-start=1, dir=ltr 'test the blue drink after dinner
diff --git a/tests/layouts/valid-3.expected b/tests/layouts/valid-3.expected
index e8a4d095..d090bac0 100644
--- a/tests/layouts/valid-3.expected
+++ b/tests/layouts/valid-3.expected
@@ -14,6 +14,10 @@ range 0 2147483647
0 0 0 0 0 0 0
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 10(0) 10(1) 12(0)
+
--- lines
i=1, index=0, paragraph-start=1, dir=ltr 'ABC😀️D
diff --git a/tests/layouts/valid-4.expected b/tests/layouts/valid-4.expected
index 33e01d8b..49688492 100644
--- a/tests/layouts/valid-4.expected
+++ b/tests/layouts/valid-4.expected
@@ -15,6 +15,10 @@ range 0 2147483647
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0)
19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 26(0) 27(0) 28(0) 29(0) 30(0) 30(1) 33(0) 34(0) 35(0) 36(0) 37(0) 38(0)
39(0) 40(0) 41(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 52(0) 53(0) 54(0) 55(0) 56(0)
57(0) 58(0) 59(0) 60(0) 61(0) 62(0) 62(1) 64(0) 65(0) 66(0) 67(0) 68(0) 69(0) 70(0) 71(0) 72(0) 73(0) 74(0)
75(0) 76(0) 77(0) 78(0) 79(0) 80(0) 81(0) 82(0) 83(0) 84(0) 85(0) 87(0) 89(0) 91(0) 92(0) 93(0) 94(0) 94(1)
97(0) 98(0) 100(0) 101(0) 102(0) 103(0) 104(0) 105(0) 106(0) 107(0) 108(0) 109(0) 110(0) 111(0) 112(0) 113(0)
114(0) 115(0) 116(0) 117(0) 118(0) 119(0) 120(0) 121(0) 122(0) 123(0) 123(1) 125(0) 126(0) 127(0) 128(0)
129(0) 130(0) 131(0) 132(0) 133(0) 134(0) 135(0) 136(0) 137(0) 138(0) 139(0) 140(0) 141(0) 142(0) 143(0)
144(0) 145(0) 146(0) 147(0) 148(0) 149(0) 150(0) 150(1) 152(0)
+
--- lines
i=1, index=0, paragraph-start=1, dir=ltr 'This paragraph should actual'
diff --git a/tests/layouts/valid-5.expected b/tests/layouts/valid-5.expected
index 4568137f..ce4ff215 100644
--- a/tests/layouts/valid-5.expected
+++ b/tests/layouts/valid-5.expected
@@ -19,6 +19,10 @@ range 31 2147483647
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0)
19(0) 20(0) 20(1) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(0) 32(0) 33(0) 34(0) 35(0) 36(0)
37(0) 38(0) 39(0) 40(0) 41(0) 42(0) 43(0) 43(1) 45(0) 46(0) 47(0) 48(0) 49(0) 50(0) 51(0) 52(0) 53(0) 54(0)
55(0) 56(0) 57(0) 58(0) 59(0) 60(0) 61(0) 62(0) 63(0) 64(0) 65(0) 66(0) 67(0) 67(1) 69(0) 70(0) 71(0) 72(0)
73(0) 74(0) 75(0) 76(0) 77(0) 78(0) 79(0) 80(0) 81(0) 82(0) 83(0) 84(0) 85(0) 86(0) 87(0) 88(0) 89(0) 89(1)
91(0) 92(0) 93(0) 94(0) 95(0) 96(0) 97(0) 98(0) 99(0) 100(0) 101(0) 102(0) 103(0) 104(0) 105(0) 106(0) 107(0)
108(0) 109(0) 110(0) 111(0) 112(0) 113(0) 114(0) 115(0) 116(0) 116(1) 118(0) 119(0) 120(0) 121(0) 122(0)
123(0) 123(1) 125(0)
+
--- lines
i=1, index=0, paragraph-start=1, dir=ltr 'A test with multiple '
diff --git a/tests/layouts/valid-6.expected b/tests/layouts/valid-6.expected
index 0f81967f..040e0fa4 100644
--- a/tests/layouts/valid-6.expected
+++ b/tests/layouts/valid-6.expected
@@ -14,6 +14,10 @@ range 0 2147483647
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+--- cursor positions
+
+0(0) 1(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0) 19(0) 20(0) 21(0) 22(0) 23(0)
24(0) 25(0) 25(1) 27(0)
+
--- lines
i=1, index=0, paragraph-start=1, dir=ltr ' 0️⃣ Keycap Digit Zero
diff --git a/tests/layouts/valid-7.expected b/tests/layouts/valid-7.expected
new file mode 100644
index 00000000..7560a9cc
--- /dev/null
+++ b/tests/layouts/valid-7.expected
@@ -0,0 +1,43 @@
+This is a test of the automatic emergency brake!
+
+--- parameters
+
+wrapped: 0
+ellipsized: 1
+lines: 2
+width: 204800
+indent: 51200
+
+--- attributes
+
+range 0 22
+range 22 41
+[22,41]foreground=#00000000ffff
+[22,41]underline=1
+range 41 2147483647
+
+--- directions
+
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 9(0) 10(0) 11(0) 12(0) 13(0) 14(0) 15(0) 16(0) 17(0) 18(0)
19(0) 20(0) 21(0) 22(0) 23(0) 24(0) 25(0) 26(0) 27(0) 28(0) 29(0) 30(0) 31(0) 32(0) 33(0) 34(0) 35(0) 36(0)
37(0) 38(0) 39(0) 40(0) 41(0) 42(0) 43(0) 44(0) 45(0) 46(0) 47(0) 47(1) 49(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'This is a test of the automatic emergency brake!
+'
+i=2, index=49, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=12, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'This
is a te'
+i=2, index=12, chars=26, level=0, gravity=south, flags=2, font=OMITTED, script=common, language=en-us, 'st
of the automatic emerge'
+[0,2147483647]fallback=0
+i=3, index=38, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'ncy'
+[22,41]foreground=#00000000ffff
+[22,41]underline=1
+i=4, index=41, chars=7, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, '
brake!'
+i=5, index=48, no run, line end
+i=6, index=49, no run, line end
diff --git a/tests/layouts/valid-7.markup b/tests/layouts/valid-7.markup
new file mode 100644
index 00000000..d5f9821e
--- /dev/null
+++ b/tests/layouts/valid-7.markup
@@ -0,0 +1,2 @@
+width=200,indent=50,ellipsize=middle
+This is a test of the <span foreground="#0000ff" underline="single">automatic emergency</span> brake!
diff --git a/tests/layouts/valid-8.expected b/tests/layouts/valid-8.expected
new file mode 100644
index 00000000..185ba373
--- /dev/null
+++ b/tests/layouts/valid-8.expected
@@ -0,0 +1,34 @@
+Hello שלום Γειά σας
+
+--- parameters
+
+wrapped: 0
+ellipsized: 0
+lines: 2
+
+--- attributes
+
+range 0 2147483647
+
+--- directions
+
+0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 12(0) 10(0) 8(0) 14(0) 15(0) 17(0) 19(0) 21(0) 23(0) 24(0) 26(0) 28(0)
28(1) 31(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'Hello שלום Γειά σας
+'
+i=2, index=31, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
+i=2, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
+i=3, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
+i=4, index=15, chars=8, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά σας'
+i=5, index=30, no run, line end
+i=6, index=31, no run, line end
diff --git a/tests/layouts/valid-8.markup b/tests/layouts/valid-8.markup
new file mode 100644
index 00000000..3272ea2b
--- /dev/null
+++ b/tests/layouts/valid-8.markup
@@ -0,0 +1,2 @@
+spacing=50,auto_dir=false,alignment=center
+Hello שלום Γειά σας
diff --git a/tests/layouts/valid-9.expected b/tests/layouts/valid-9.expected
new file mode 100644
index 00000000..d1388f62
--- /dev/null
+++ b/tests/layouts/valid-9.expected
@@ -0,0 +1,49 @@
+Hello שלום Γειά σας
+
+--- parameters
+
+wrapped: 1
+ellipsized: 0
+lines: 5
+width: 102400
+
+--- attributes
+
+range 0 30
+[0,30]letter-spacing=8888
+range 30 2147483647
+
+--- directions
+
+0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0
+
+--- cursor positions
+
+0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 5(1) 12(0) 10(0) 8(0) 14(0) 14(1) 17(0) 19(0) 21(0) 23(0) 23(1) 26(0) 28(0)
28(1) 31(0)
+
+--- lines
+
+i=1, index=0, paragraph-start=1, dir=ltr 'Hello שלו'
+i=2, index=12, paragraph-start=0, dir=ltr 'ם '
+i=3, index=15, paragraph-start=0, dir=ltr 'Γειά '
+i=4, index=24, paragraph-start=0, dir=ltr 'σας
+'
+i=5, index=31, paragraph-start=1, dir=ltr ''
+
+--- runs
+
+i=1, index=0, chars=6, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Hello '
+[0,30]letter-spacing=8888
+i=2, index=6, no run, line end
+i=3, index=12, chars=4, level=1, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, 'שלום'
+[0,30]letter-spacing=8888
+i=4, index=14, chars=1, level=0, gravity=south, flags=0, font=OMITTED, script=hebrew, language=he, ' '
+[0,30]letter-spacing=8888
+i=5, index=15, no run, line end
+i=6, index=15, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'Γειά '
+[0,30]letter-spacing=8888
+i=7, index=24, no run, line end
+i=8, index=24, chars=3, level=0, gravity=south, flags=0, font=OMITTED, script=greek, language=el, 'σας'
+[0,30]letter-spacing=8888
+i=9, index=30, no run, line end
+i=10, index=31, no run, line end
diff --git a/tests/layouts/valid-9.markup b/tests/layouts/valid-9.markup
new file mode 100644
index 00000000..ced8f8e5
--- /dev/null
+++ b/tests/layouts/valid-9.markup
@@ -0,0 +1,2 @@
+width=100
+<span letter_spacing="8888">Hello שלום Γειά σας</span>
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 70dfc3d1..68123b5a 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -191,26 +191,81 @@ dump_directions (PangoLayout *layout, GString *string)
}
static void
-parse_params (const gchar *str,
- gint *width,
- gint *ellipsize_at,
- PangoEllipsizeMode *ellipsize,
- PangoWrapMode *wrap)
+dump_cursor_positions (PangoLayout *layout, GString *string)
{
- gchar **strings;
- gchar **str2;
- gint i;
+ int index, trailing;
+
+ index = 0;
+ trailing = 0;
+
+ while (index < G_MAXINT)
+ {
+ g_string_append_printf (string, "%d(%d) ", index, trailing);
+ pango_layout_move_cursor_visually (layout, TRUE, index, trailing, 1, &index, &trailing);
+ }
+
+ g_string_append (string, "\n");
+}
+
+typedef struct {
+ int width;
+ int indent;
+ int spacing;
+ float line_spacing;
+ PangoEllipsizeMode ellipsize;
+ PangoWrapMode wrap;
+ PangoAlignment alignment;
+ gboolean justify;
+ gboolean auto_dir;
+ gboolean single_paragraph;
+ PangoTabArray *tabs;
+} LayoutParams;
+
+static void
+init_params (LayoutParams *params)
+{
+ params->width = -1;
+ params->indent = 0;
+ params->spacing = 0;
+ params->line_spacing = 0.0;
+ params->ellipsize = PANGO_ELLIPSIZE_NONE;
+ params->wrap = PANGO_WRAP_WORD;
+ params->alignment = PANGO_ALIGN_LEFT;
+ params->justify = FALSE;
+ params->auto_dir = TRUE;
+ params->single_paragraph = FALSE;
+ params->tabs = NULL;
+}
+
+static void
+parse_params (const char *str,
+ LayoutParams *params)
+{
+ char **strings;
+ int i;
GEnumClass *eclass;
GEnumValue *ev;
strings = g_strsplit (str, ",", -1);
for (i = 0; strings[i]; i++)
{
- str2 = g_strsplit (strings[i], "=", -1);
+ char **str2 = g_strsplit (strings[i], "=", -1);
if (strcmp (str2[0], "width") == 0)
- *width = (gint) g_ascii_strtoll (str2[1], NULL, 10);
- else if (strcmp (str2[0], "ellipsize-at") == 0)
- *ellipsize_at = (gint) g_ascii_strtoll (str2[1], NULL, 10);
+ {
+ params->width = (int) g_ascii_strtoll (str2[1], NULL, 10);
+ }
+ else if (strcmp (str2[0], "indent") == 0)
+ {
+ params->indent = (int) g_ascii_strtoll (str2[1], NULL, 10);
+ }
+ else if (strcmp (str2[0], "spacing") == 0)
+ {
+ params->spacing = (int) g_ascii_strtoll (str2[1], NULL, 10);
+ }
+ else if (strcmp (str2[0], "line_spacing") == 0)
+ {
+ params->line_spacing = (float) g_ascii_strtod (str2[1], NULL);
+ }
else if (strcmp (str2[0], "ellipsize") == 0)
{
eclass = g_type_class_ref (PANGO_TYPE_ELLIPSIZE_MODE);
@@ -218,7 +273,7 @@ parse_params (const gchar *str,
if (!ev)
ev = g_enum_get_value_by_nick (eclass, str2[1]);
if (ev)
- *ellipsize = ev->value;
+ params->ellipsize = ev->value;
g_type_class_unref (eclass);
}
else if (strcmp (str2[0], "wrap") == 0)
@@ -228,28 +283,75 @@ parse_params (const gchar *str,
if (!ev)
ev = g_enum_get_value_by_nick (eclass, str2[1]);
if (ev)
- *wrap = ev->value;
+ params->wrap = ev->value;
+ g_type_class_unref (eclass);
+ }
+ else if (strcmp (str2[0], "alignment") == 0)
+ {
+ eclass = g_type_class_ref (PANGO_TYPE_ALIGNMENT);
+ ev = g_enum_get_value_by_name (eclass, str2[1]);
+ if (!ev)
+ ev = g_enum_get_value_by_nick (eclass, str2[1]);
+ if (ev)
+ params->alignment = ev->value;
g_type_class_unref (eclass);
}
+ else if (strcmp (str2[0], "justify") == 0)
+ {
+ params->justify = g_str_equal (str2[1], "true");
+ }
+ else if (strcmp (str2[0], "auto_dir") == 0)
+ {
+ params->auto_dir = g_str_equal (str2[1], "true");
+ }
+ else if (strcmp (str2[0], "single_paragraph") == 0)
+ {
+ params->single_paragraph = g_str_equal (str2[1], "true");
+ }
+ else if (strcmp (str2[0], "tabs") == 0)
+ {
+ char **str3 = g_strsplit (strings[i], " ", -1);
+ params->tabs = pango_tab_array_new (g_strv_length (str3), TRUE);
+ for (int j = 0; str3[j]; j++)
+ {
+ int tab = (int) g_ascii_strtoll (str3[j], NULL, 10);
+ pango_tab_array_set_tab (params->tabs, j, PANGO_TAB_LEFT, tab);
+ }
+ g_strfreev (str3);
+ }
+
g_strfreev (str2);
}
g_strfreev (strings);
}
+#define assert_layout_changed(layout) \
+ g_assert_cmpuint (pango_layout_get_serial (layout), !=, serial); \
+ serial = pango_layout_get_serial (layout);
+
+#define assert_rectangle_equal(r1, r2) \
+ g_assert_true((r1)->x == (r2)->x && \
+ (r1)->y == (r2)->y && \
+ (r1)->width == (r2)->width && \
+ (r1)->height == (r2)->height);
+
static void
-test_file (const gchar *filename, GString *string)
+test_file (const char *filename, GString *string)
{
- gchar *contents;
- gchar *markup;
+ char *contents;
+ char *markup;
gsize length;
GError *error = NULL;
PangoLayout *layout;
- gchar *p;
- gint width = 0;
- gint ellipsize_at = 0;
- PangoEllipsizeMode ellipsize = PANGO_ELLIPSIZE_NONE;
- PangoWrapMode wrap = PANGO_WRAP_WORD;
+ char *p;
+ LayoutParams params;
PangoFontDescription *desc;
+ PangoFontDescription *desc2;
+ guint serial;
+ PangoRectangle ink_rect, logical_rect;
+ PangoRectangle ink_rect1, logical_rect1;
+ int width, height;
+ int width1, height1;
if (context == NULL)
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
@@ -263,36 +365,111 @@ test_file (const gchar *filename, GString *string)
*p = '\0';
length = strlen (markup);
- parse_params (contents, &width, &ellipsize_at, &ellipsize, &wrap);
+ init_params (¶ms);
layout = pango_layout_new (context);
+
+ serial = pango_layout_get_serial (layout);
+ g_assert_cmpuint (serial, !=, 0);
+
+ /* check initial values */
+ g_assert_cmpint (pango_layout_get_width (layout), ==, params.width);
+ g_assert_cmpint (pango_layout_get_height (layout), ==, -1);
+ g_assert_cmpint (pango_layout_get_indent (layout), ==, params.indent);
+ g_assert_cmpint (pango_layout_get_spacing (layout), ==, params.spacing);
+ g_assert_cmpfloat (pango_layout_get_line_spacing (layout), ==, params.line_spacing);
+ g_assert_cmpint (pango_layout_get_ellipsize (layout), ==, params.ellipsize);
+ g_assert_cmpint (pango_layout_get_wrap (layout), ==, params.wrap);
+ g_assert_cmpint (pango_layout_get_alignment (layout), ==, params.alignment);
+ g_assert_cmpint (pango_layout_get_justify (layout), ==, params.justify);
+ g_assert_cmpint (pango_layout_get_auto_dir (layout), ==, params.auto_dir);
+ g_assert_cmpint (pango_layout_get_single_paragraph_mode (layout), ==, params.single_paragraph);
+
+ g_assert_cmpstr (pango_layout_get_text (layout), ==, "");
+ g_assert_null (pango_layout_get_attributes (layout));
+ g_assert_null (pango_layout_get_tabs (layout));
+ g_assert_null (pango_layout_get_font_description (layout));
+ g_assert_cmpint (pango_layout_is_ellipsized (layout), ==, FALSE);
+ g_assert_cmpint (pango_layout_is_wrapped (layout), ==, FALSE);
+
desc = pango_font_description_from_string ("Cantarell 11");
pango_layout_set_font_description (layout, desc);
+ desc2 = pango_layout_get_font_description (layout);
+ g_assert_true (pango_font_description_equal (desc, desc2));
pango_font_description_free (desc);
+ assert_layout_changed (layout);
pango_layout_set_markup (layout, markup, length);
- g_free (contents);
-
- if (width != 0)
- pango_layout_set_width (layout, width * PANGO_SCALE);
- pango_layout_set_ellipsize (layout, ellipsize);
- pango_layout_set_wrap (layout, wrap);
+ assert_layout_changed (layout);
+
+ parse_params (contents, ¶ms);
+
+ pango_layout_set_width (layout, params.width > 0 ? params.width * PANGO_SCALE : -1);
+ pango_layout_set_indent (layout, params.indent * PANGO_SCALE);
+ pango_layout_set_spacing (layout, params.spacing * PANGO_SCALE);
+ pango_layout_set_line_spacing (layout, params.line_spacing);
+ pango_layout_set_ellipsize (layout, params.ellipsize);
+ pango_layout_set_wrap (layout, params.wrap);
+ pango_layout_set_alignment (layout, params.alignment);
+ pango_layout_set_justify (layout, params.justify);
+ pango_layout_set_auto_dir (layout, params.auto_dir);
+ pango_layout_set_single_paragraph_mode (layout, params.single_paragraph);
+ pango_layout_set_tabs (layout, params.tabs);
+
+ /* check the values we set */
+ g_assert_cmpint (pango_layout_get_width (layout), ==, params.width > 0 ? params.width * PANGO_SCALE : -1);
+ g_assert_cmpint (pango_layout_get_indent (layout), ==, params.indent * PANGO_SCALE);
+ g_assert_cmpint (pango_layout_get_spacing (layout), ==, params.spacing * PANGO_SCALE);
+ g_assert_cmpfloat (pango_layout_get_line_spacing (layout), ==, params.line_spacing);
+ g_assert_cmpint (pango_layout_get_ellipsize (layout), ==, params.ellipsize);
+ g_assert_cmpint (pango_layout_get_wrap (layout), ==, params.wrap);
+ g_assert_cmpint (pango_layout_get_alignment (layout), ==, params.alignment);
+ g_assert_cmpint (pango_layout_get_justify (layout), ==, params.justify);
+ g_assert_cmpint (pango_layout_get_auto_dir (layout), ==, params.auto_dir);
+ g_assert_cmpint (pango_layout_get_single_paragraph_mode (layout), ==, params.single_paragraph);
+
+ g_assert_true ((pango_layout_get_tabs (layout) == NULL) == (params.tabs == NULL));
+
+
+ g_assert_cmpint (pango_layout_get_character_count (layout), ==, g_utf8_strlen (pango_layout_get_text
(layout), -1));
+
+ pango_layout_get_extents (layout, &ink_rect, &logical_rect);
+ pango_extents_to_pixels (&ink_rect, NULL);
+ pango_extents_to_pixels (&logical_rect, NULL);
+ pango_layout_get_pixel_extents (layout, &ink_rect1, &logical_rect1);
+ pango_layout_get_size (layout, &width, &height);
+ pango_layout_get_pixel_size (layout, &width1, &height1);
+
+ assert_rectangle_equal (&ink_rect, &ink_rect1);
+ assert_rectangle_equal (&logical_rect, &logical_rect1);
+ g_assert_cmpint (PANGO_PIXELS (width), ==, logical_rect.width);
+ g_assert_cmpint (PANGO_PIXELS (height), ==, logical_rect.height);
+ g_assert_cmpint (width1, ==, logical_rect1.width);
+ g_assert_cmpint (height1, ==, logical_rect1.height);
g_string_append (string, pango_layout_get_text (layout));
g_string_append (string, "\n--- parameters\n\n");
+
g_string_append_printf (string, "wrapped: %d\n", pango_layout_is_wrapped (layout));
g_string_append_printf (string, "ellipsized: %d\n", pango_layout_is_ellipsized (layout));
g_string_append_printf (string, "lines: %d\n", pango_layout_get_line_count (layout));
- if (width != 0)
+ if (params.width > 0)
g_string_append_printf (string, "width: %d\n", pango_layout_get_width (layout));
+ if (params.indent != 0)
+ g_string_append_printf (string, "indent: %d\n", pango_layout_get_indent (layout));
+
+
g_string_append (string, "\n--- attributes\n\n");
print_attr_list (pango_layout_get_attributes (layout), string);
g_string_append (string, "\n--- directions\n\n");
dump_directions (layout, string);
+ g_string_append (string, "\n--- cursor positions\n\n");
+ dump_cursor_positions (layout, string);
+
g_string_append (string, "\n--- lines\n\n");
dump_lines (layout, string);
@@ -300,6 +477,10 @@ test_file (const gchar *filename, GString *string)
dump_runs (layout, string);
g_object_unref (layout);
+ g_free (contents);
+
+ if (params.tabs)
+ pango_tab_array_free (params.tabs);
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]