Skip to content

Commit

Permalink
Some tests for max-height on footnote area.
Browse files Browse the repository at this point in the history
Related to #1674.
  • Loading branch information
grewn0uille committed Jul 13, 2022
1 parent 91a2474 commit 8f5bee1
Show file tree
Hide file tree
Showing 2 changed files with 253 additions and 0 deletions.
199 changes: 199 additions & 0 deletions tests/draw/test_footnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,202 @@ def test_footnote_with_absolute(assert_pixels):
}
</style>
<div>a<span><mark>d</mark></span></div>''')


@assert_no_logs
def test_footnote_max_height_1(assert_pixels):
assert_pixels('''
RRRRRRRR_
RRRRRRRR_
RRRR_____
RRRR_____
_BBBBBB__
_BBBBBB__
_________
_________
_________
_________
_BBBBBB__
_BBBBBB__
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 6px;
@footnote {
margin-left: 1px;
max-height: 3px;
}
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div.footnote {
float: footnote;
color: blue;
}
</style>
<div>ab<div class="footnote">c</div><div class="footnote">d</div></div>
<div>ef</div>''')


@assert_no_logs
def test_footnote_max_height_2(assert_pixels):
assert_pixels('''
RRRRRRRR_
RRRRRRRR_
_________
_________
_BBBBBB__
_BBBBBB__
_________
_________
_________
_________
_BBBBBB__
_BBBBBB__
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 6px;
@footnote {
margin-left: 1px;
max-height: 3px;
}
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div.footnote {
float: footnote;
color: blue;
}
</style>
<div>ab<div class="footnote">c</div><div class="footnote">d</div></div>''')


@assert_no_logs
def test_footnote_max_height_3(assert_pixels):
assert_pixels('''
RRRRRRRR_
RRRRRRRR_
_________
_________
_________
_________
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 6px;
@footnote {
margin-left: 1px;
max-height: 0px;
}
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div.footnote {
float: footnote;
color: blue;
}
</style>
<div>ab<div class="footnote">c</div><div class="footnote">d</div></div>''')


@assert_no_logs
def test_footnote_max_height_4(assert_pixels):
assert_pixels('''
RRRRRRRR_
RRRRRRRR_
RRRR_____
RRRR_____
_BBBBBB__
_BBBBBB__
RRRR_____
RRRR_____
_________
_________
_BBBBBB__
_BBBBBB__
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 6px;
@footnote {
margin-left: 1px;
max-height: 3px;
}
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div.footnote {
float: footnote;
color: blue;
}
</style>
<div>ab<div class="footnote">c</div><div class="footnote">d</div></div>
<div>ef</div>
<div>gh</div>''')


@assert_no_logs
def test_footnote_max_height_5(assert_pixels):
assert_pixels('''
RRRRRRRRRR
RRRRRRRRRR
_BBBBBB___
_BBBBBB___
_BBBBBB___
_BBBBBB___
RRRR______
RRRR______
__________
__________
_BBBBBB___
_BBBBBB___
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 10px 6px;
@footnote {
margin-left: 1px;
max-height: 4px;
}
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div.footnote {
float: footnote;
color: blue;
}
</style>
<div>ab<div class="footnote">c</div><div class="footnote">d</div>
<div class="footnote">e</div></div>
<div>fg</div>''')
54 changes: 54 additions & 0 deletions tests/layout/test_footnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,57 @@ def test_footnote_repagination():
assert footnote_marker.children[0].text == '1.'
assert footnote_textbox.text == 'de'
assert footnote_area.position_y == 5


@assert_no_logs
def test_footnote_max_height():
page1, page2 = render_pages('''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 10px 6px;
@footnote {
margin-left: 1px;
max-height: 4px;
}
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div.footnote {
float: footnote;
color: blue;
}
</style>
<div>ab<div class="footnote">c</div><div class="footnote">d</div>
<div class="footnote">e</div></div>
<div>fg</div>''')
html1, footnote_area1= page1.children
body1, = html1.children
div, = body1.children
div_textbox, footnote_call1, footnote_call2, footnote_call3 = div.children[0].children
assert div_textbox.text == 'ab'
assert footnote_call1.children[0].text == '1'
assert footnote_call2.children[0].text == '2'
assert footnote_call3.children[0].text == '3'
footnote_line1, footnote_line2 = footnote_area1.children[0].children
footnote_marker1, footnote_content1 = footnote_line1[0].children
assert footnote_marker1.children[0].text == '1.'
assert footnote_content1.text == 'c'
footnote_marker2, footnote_content2 = footnote_line2[0].children
assert footnote_marker2.children[0].text == '2.'
assert footnote_content2.text == 'd'

html2, footnote_area2 = page2.children
body2, = html2.children
div2, = body2.children
div_textbox2 = div2.children[0].children
assert div_textbox2.text == 'fg'
footnote_line3 = footnote_area2.children[0].children
footnote_marker3, footnote_content3 = footnote_line3[0].children
assert footnote_marker2.children[0].text == '3.'
assert footnote_content2.text == 'e'

0 comments on commit 8f5bee1

Please sign in to comment.