2011-07-12 19:53:15 +04:00
|
|
|
|
# coding: utf8
|
2012-03-22 02:19:27 +04:00
|
|
|
|
"""
|
|
|
|
|
weasyprint.tests.test_draw
|
|
|
|
|
--------------------------
|
2011-07-12 19:53:15 +04:00
|
|
|
|
|
2012-03-22 02:19:27 +04:00
|
|
|
|
Test the final, drawn results and compare PNG images pixel per pixel.
|
2011-07-12 19:53:15 +04:00
|
|
|
|
|
2012-03-22 02:19:27 +04:00
|
|
|
|
:copyright: Copyright 2011-2012 Simon Sapin and contributors, see AUTHORS.
|
|
|
|
|
:license: BSD, see LICENSE for details.
|
2011-08-24 14:08:35 +04:00
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
2012-02-17 21:49:58 +04:00
|
|
|
|
from __future__ import division, unicode_literals
|
|
|
|
|
|
2012-12-29 04:00:30 +04:00
|
|
|
|
import io
|
|
|
|
|
import sys
|
2011-07-29 03:14:05 +04:00
|
|
|
|
import os.path
|
2012-01-16 16:12:27 +04:00
|
|
|
|
import tempfile
|
|
|
|
|
import shutil
|
2012-02-17 21:49:58 +04:00
|
|
|
|
import itertools
|
2012-07-18 17:37:37 +04:00
|
|
|
|
import functools
|
2011-07-12 19:53:15 +04:00
|
|
|
|
|
2012-12-29 04:00:30 +04:00
|
|
|
|
import cairocffi as cairo
|
2012-06-05 15:52:57 +04:00
|
|
|
|
import pytest
|
2011-07-12 19:53:15 +04:00
|
|
|
|
|
2012-07-31 20:13:25 +04:00
|
|
|
|
from ..compat import xrange, izip, ints_from_bytes
|
2012-05-22 19:44:16 +04:00
|
|
|
|
from ..urls import ensure_url
|
2012-10-02 20:59:02 +04:00
|
|
|
|
from .. import HTML
|
2011-12-16 14:19:56 +04:00
|
|
|
|
from .testing_utils import (
|
2012-09-25 18:01:47 +04:00
|
|
|
|
resource_filename, TestHTML, FONTS, assert_no_logs, capture_logs)
|
2011-08-10 18:54:26 +04:00
|
|
|
|
|
2012-01-16 14:39:02 +04:00
|
|
|
|
|
2012-12-29 04:00:30 +04:00
|
|
|
|
as_pixel = (
|
2012-12-29 17:20:38 +04:00
|
|
|
|
lambda x: x[:-1][::-1] + x[-1:]
|
2012-12-29 04:00:30 +04:00
|
|
|
|
if sys.byteorder == 'little' else
|
2012-12-29 17:20:38 +04:00
|
|
|
|
lambda x: x[-1:] + x[:-1])
|
2012-12-29 04:00:30 +04:00
|
|
|
|
|
2011-08-24 14:29:54 +04:00
|
|
|
|
# Short variable names are OK here
|
2011-08-24 14:08:35 +04:00
|
|
|
|
# pylint: disable=C0103
|
2011-08-10 18:54:26 +04:00
|
|
|
|
|
2012-12-29 04:00:30 +04:00
|
|
|
|
_ = as_pixel(b'\xff\xff\xff\xff') # white
|
|
|
|
|
r = as_pixel(b'\xff\x00\x00\xff') # red
|
|
|
|
|
B = as_pixel(b'\x00\x00\xff\xff') # blue
|
2011-08-10 21:33:16 +04:00
|
|
|
|
|
|
|
|
|
|
2012-12-29 02:17:04 +04:00
|
|
|
|
def save_pixels_to_png(pixels, width, height, filename):
|
2013-02-26 18:04:52 +04:00
|
|
|
|
"""Save raw pixels to a PNG file."""
|
2012-12-29 04:00:30 +04:00
|
|
|
|
cairo.ImageSurface(
|
|
|
|
|
str('ARGB32'), width, height, data=bytearray(pixels), stride=width * 4
|
|
|
|
|
).write_to_png(filename)
|
2012-10-07 11:49:07 +04:00
|
|
|
|
|
|
|
|
|
|
2012-07-18 17:37:37 +04:00
|
|
|
|
def requires_cairo_1_12(test):
|
|
|
|
|
@functools.wraps(test)
|
|
|
|
|
def decorated_test():
|
|
|
|
|
if cairo.cairo_version() < 11200:
|
|
|
|
|
print('Running cairo %s but this test requires 1.12+'
|
|
|
|
|
% cairo.cairo_version_string())
|
|
|
|
|
pytest.xfail()
|
|
|
|
|
test()
|
|
|
|
|
return decorated_test
|
|
|
|
|
|
|
|
|
|
|
2012-08-03 18:21:47 +04:00
|
|
|
|
def assert_pixels(name, expected_width, expected_height, expected_pixels,
|
2012-08-03 14:38:17 +04:00
|
|
|
|
html):
|
2011-08-24 14:08:35 +04:00
|
|
|
|
"""Helper testing the size of the image and the pixels values."""
|
2012-08-03 18:21:47 +04:00
|
|
|
|
assert len(expected_pixels) == expected_height
|
|
|
|
|
assert len(expected_pixels[0]) == expected_width * 4
|
|
|
|
|
expected_raw = b''.join(expected_pixels)
|
|
|
|
|
_doc, pixels = html_to_pixels(name, expected_width, expected_height, html)
|
|
|
|
|
assert_pixels_equal(name, expected_width, expected_height, pixels,
|
2012-02-22 17:13:14 +04:00
|
|
|
|
expected_raw)
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
|
|
|
|
|
2012-07-29 01:02:36 +04:00
|
|
|
|
def assert_same_rendering(expected_width, expected_height, documents,
|
|
|
|
|
tolerance=0):
|
2011-08-25 19:29:16 +04:00
|
|
|
|
"""
|
2011-12-13 18:42:35 +04:00
|
|
|
|
Render HTML documents to PNG and check that they render the same,
|
|
|
|
|
pixel-per-pixel.
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
Each document is passed as a (name, html_source) tuple.
|
2011-08-25 19:29:16 +04:00
|
|
|
|
"""
|
2012-08-03 18:21:47 +04:00
|
|
|
|
pixels_list = []
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
|
|
|
|
for name, html in documents:
|
2012-08-03 18:21:47 +04:00
|
|
|
|
_doc, pixels = html_to_pixels(
|
2012-02-22 17:13:14 +04:00
|
|
|
|
name, expected_width, expected_height, html)
|
2012-08-03 18:21:47 +04:00
|
|
|
|
pixels_list.append((name, pixels))
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
2012-08-03 18:21:47 +04:00
|
|
|
|
_name, reference = pixels_list[0]
|
|
|
|
|
for name, pixels in pixels_list[1:]:
|
2011-08-25 19:29:16 +04:00
|
|
|
|
assert_pixels_equal(name, expected_width, expected_height,
|
2012-08-03 18:21:47 +04:00
|
|
|
|
reference, pixels, tolerance)
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
def assert_different_renderings(expected_width, expected_height, documents):
|
|
|
|
|
"""
|
|
|
|
|
Render HTML documents to PNG and check that no two documents render
|
|
|
|
|
the same.
|
|
|
|
|
|
|
|
|
|
Each document is passed as a (name, html_source) tuple.
|
|
|
|
|
"""
|
2012-08-03 18:21:47 +04:00
|
|
|
|
pixels_list = []
|
2011-12-13 18:42:35 +04:00
|
|
|
|
|
|
|
|
|
for name, html in documents:
|
2012-08-03 18:21:47 +04:00
|
|
|
|
_doc, pixels = html_to_pixels(
|
2012-02-22 17:13:14 +04:00
|
|
|
|
name, expected_width, expected_height, html)
|
2012-08-03 18:21:47 +04:00
|
|
|
|
pixels_list.append((name, pixels))
|
2011-12-13 18:42:35 +04:00
|
|
|
|
|
2012-08-03 18:21:47 +04:00
|
|
|
|
for i, (name_1, pixels_1) in enumerate(pixels_list):
|
|
|
|
|
for name_2, pixels_2 in pixels_list[i + 1:]:
|
|
|
|
|
if pixels_1 == pixels_2: # pragma: no cover
|
|
|
|
|
write_png(name_1, pixels_1, expected_width, expected_height)
|
|
|
|
|
# Same as "assert pixels_1 != pixels_2" but the output of
|
2011-12-13 18:42:35 +04:00
|
|
|
|
# the assert hook would be gigantic and useless.
|
|
|
|
|
assert False, '%s and %s are the same' % (name_1, name_2)
|
|
|
|
|
|
2012-07-29 00:11:28 +04:00
|
|
|
|
def write_png(basename, pixels, width, height): # pragma: no cover
|
2012-01-02 18:28:51 +04:00
|
|
|
|
"""Take a pixel matrix and write a PNG file."""
|
|
|
|
|
directory = os.path.join(os.path.dirname(__file__), 'test_results')
|
|
|
|
|
if not os.path.isdir(directory):
|
|
|
|
|
os.mkdir(directory)
|
|
|
|
|
filename = os.path.join(directory, basename + '.png')
|
2012-07-29 00:11:28 +04:00
|
|
|
|
save_pixels_to_png(pixels, width, height, filename)
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
2012-02-22 17:13:14 +04:00
|
|
|
|
|
2012-08-03 14:38:17 +04:00
|
|
|
|
def html_to_pixels(name, expected_width, expected_height, html):
|
2011-08-25 19:29:16 +04:00
|
|
|
|
"""
|
|
|
|
|
Render an HTML document to PNG, checks its size and return pixel data.
|
2011-10-21 13:15:06 +04:00
|
|
|
|
|
|
|
|
|
Also return the document to aid debugging.
|
2011-08-25 19:29:16 +04:00
|
|
|
|
"""
|
2012-09-25 18:01:47 +04:00
|
|
|
|
document = TestHTML(string=html,
|
2012-02-15 21:49:37 +04:00
|
|
|
|
# Dummy filename, but in the right directory.
|
|
|
|
|
base_url=resource_filename('<test>'))
|
2012-08-03 18:21:47 +04:00
|
|
|
|
pixels = document_to_pixels(document, name, expected_width,
|
2012-08-03 14:38:17 +04:00
|
|
|
|
expected_height)
|
2012-08-03 18:21:47 +04:00
|
|
|
|
return document, pixels
|
2012-01-16 16:12:27 +04:00
|
|
|
|
|
|
|
|
|
|
2012-08-03 14:38:17 +04:00
|
|
|
|
def document_to_pixels(document, name, expected_width, expected_height):
|
2012-01-16 16:12:27 +04:00
|
|
|
|
"""
|
|
|
|
|
Render an HTML document to PNG, checks its size and return pixel data.
|
|
|
|
|
"""
|
2012-12-29 04:00:30 +04:00
|
|
|
|
surface = document.write_image_surface()
|
|
|
|
|
return image_to_pixels(surface, expected_width, expected_height)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def image_to_pixels(surface, width, height):
|
|
|
|
|
assert (surface.get_width(), surface.get_height()) == (width, height)
|
|
|
|
|
# RGB24 is actually the same as ARGB32, with A unused.
|
|
|
|
|
assert surface.get_format() in ('ARGB32', 'RGB24')
|
2012-12-29 14:50:11 +04:00
|
|
|
|
pixels = surface.get_data()[:]
|
2012-12-29 04:00:30 +04:00
|
|
|
|
stride = surface.get_stride()
|
2012-07-31 19:30:23 +04:00
|
|
|
|
row_bytes = width * 4
|
2012-07-29 00:11:28 +04:00
|
|
|
|
if stride != row_bytes:
|
|
|
|
|
assert stride > row_bytes
|
|
|
|
|
pixels = b''.join(pixels[i:i + row_bytes]
|
2012-07-31 19:30:23 +04:00
|
|
|
|
for i in xrange(0, height * stride, stride))
|
|
|
|
|
assert len(pixels) == width * height * 4
|
2012-07-29 00:11:28 +04:00
|
|
|
|
return pixels
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
|
|
|
|
|
2012-06-05 15:52:57 +04:00
|
|
|
|
def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0):
|
2011-08-25 19:29:16 +04:00
|
|
|
|
"""
|
|
|
|
|
Take 2 matrices of height by width pixels and assert that they
|
|
|
|
|
are the same.
|
|
|
|
|
"""
|
2012-06-05 15:52:57 +04:00
|
|
|
|
if raw != expected_raw: # pragma: no cover
|
2012-07-31 20:13:25 +04:00
|
|
|
|
for i, (value, expected) in enumerate(izip(
|
2012-06-05 15:52:57 +04:00
|
|
|
|
ints_from_bytes(raw),
|
|
|
|
|
ints_from_bytes(expected_raw)
|
|
|
|
|
)):
|
|
|
|
|
if abs(value - expected) > tolerance:
|
|
|
|
|
write_png(name, raw, width, height)
|
|
|
|
|
write_png(name + '.expected', expected_raw,
|
|
|
|
|
width, height)
|
2012-07-31 19:30:23 +04:00
|
|
|
|
pixel_n = i // 4
|
2012-06-05 15:52:57 +04:00
|
|
|
|
x = pixel_n // width
|
|
|
|
|
y = pixel_n % width
|
2012-07-31 19:30:23 +04:00
|
|
|
|
i % 4
|
|
|
|
|
pixel = tuple(ints_from_bytes(raw[i:i + 4]))
|
2012-06-05 15:52:57 +04:00
|
|
|
|
expected_pixel = tuple(ints_from_bytes(
|
2012-07-31 19:30:23 +04:00
|
|
|
|
expected_raw[i:i + 4]))
|
2012-06-05 15:52:57 +04:00
|
|
|
|
assert 0, (
|
2012-12-29 04:00:30 +04:00
|
|
|
|
'Pixel (%i, %i) in %s: expected rgba%s, got rgba%s'
|
2012-06-05 15:52:57 +04:00
|
|
|
|
% (x, y, name, expected_pixel, pixel))
|
2011-07-29 03:14:05 +04:00
|
|
|
|
|
2011-11-05 04:01:00 +04:00
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2011-08-10 18:19:32 +04:00
|
|
|
|
def test_canvas_background():
|
2011-08-24 14:08:35 +04:00
|
|
|
|
"""Test the background applied on ``<html>`` and/or ``<body>`` tags."""
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('all_blue', 10, 10, (10 * [10 * B]), '''
|
2011-08-08 23:20:43 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 10px }
|
2011-08-08 23:20:43 +04:00
|
|
|
|
/* body’s background propagates to the whole canvas */
|
|
|
|
|
body { margin: 2px; background: #00f; height: 5px }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
2011-08-20 20:20:59 +04:00
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('blocks', 10, 10, [
|
2011-08-20 20:20:59 +04:00
|
|
|
|
r+r+r+r+r+r+r+r+r+r,
|
|
|
|
|
r+r+r+r+r+r+r+r+r+r,
|
|
|
|
|
r+r+B+B+B+B+B+B+r+r,
|
|
|
|
|
r+r+B+B+B+B+B+B+r+r,
|
|
|
|
|
r+r+B+B+B+B+B+B+r+r,
|
|
|
|
|
r+r+B+B+B+B+B+B+r+r,
|
|
|
|
|
r+r+B+B+B+B+B+B+r+r,
|
|
|
|
|
r+r+r+r+r+r+r+r+r+r,
|
|
|
|
|
r+r+r+r+r+r+r+r+r+r,
|
|
|
|
|
r+r+r+r+r+r+r+r+r+r,
|
|
|
|
|
], '''
|
2011-07-29 03:14:05 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 10px }
|
2011-08-08 23:20:43 +04:00
|
|
|
|
/* html’s background propagates to the whole canvas */
|
2012-02-23 22:30:31 +04:00
|
|
|
|
html { padding: 1px; background: #f00 }
|
2011-08-08 23:20:43 +04:00
|
|
|
|
/* html has a background, so body’s does not propagate */
|
|
|
|
|
body { margin: 1px; background: #00f; height: 5px }
|
2011-07-29 03:14:05 +04:00
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
2011-08-10 18:19:32 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2011-08-10 18:52:34 +04:00
|
|
|
|
def test_background_image():
|
2011-08-24 14:08:35 +04:00
|
|
|
|
"""Test background images."""
|
2011-08-20 20:20:59 +04:00
|
|
|
|
# pattern.png looks like this:
|
|
|
|
|
|
|
|
|
|
# r+B+B+B,
|
|
|
|
|
# B+B+B+B,
|
|
|
|
|
# B+B+B+B,
|
|
|
|
|
# B+B+B+B,
|
2011-08-11 14:44:37 +04:00
|
|
|
|
|
2011-08-20 20:20:59 +04:00
|
|
|
|
for name, css, pixels in [
|
2013-03-19 21:29:58 +04:00
|
|
|
|
('repeat', 'url(pattern.png)', [
|
2011-08-20 20:20:59 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+r+B+B+B+r+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+B+B+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+B+B+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+B+B+B+B+B+B+_+_,
|
|
|
|
|
_+_+r+B+B+B+r+B+B+B+r+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+B+B+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+B+B+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+B+B+B+B+B+B+_+_,
|
|
|
|
|
_+_+r+B+B+B+r+B+B+B+r+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+B+B+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+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|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
]),
|
2013-03-19 21:29:58 +04:00
|
|
|
|
('center_bottom', 'url(pattern.png) no-repeat center 6px', [
|
2011-08-20 20:20:59 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
2012-01-16 17:00:30 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+r+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
]),
|
2013-03-19 21:29:58 +04:00
|
|
|
|
('bottom_center', 'url(pattern.png) no-repeat bottom center', [
|
2012-01-16 17:00:30 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_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_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
]),
|
2013-03-19 21:29:58 +04:00
|
|
|
|
('fixed_center_center', 'url(pattern.png) no-repeat fixed 50% center', [
|
2011-10-07 13:36:08 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+r+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
]),
|
2013-03-20 16:06:42 +04:00
|
|
|
|
('multi_under', 'url(pattern.png) no-repeat, '
|
|
|
|
|
'url(pattern.png) no-repeat 2px 1px', [
|
2013-03-19 21:29:58 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_+_+_+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|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
]),
|
2011-08-11 14:44:37 +04:00
|
|
|
|
]:
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('background_' + name, 14, 16, pixels, '''
|
2011-08-10 21:33:16 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 14px 16px }
|
2011-08-10 21:33:16 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 2px; height: 10px;
|
2013-03-19 21:29:58 +04:00
|
|
|
|
background: %s }
|
2012-04-03 21:02:14 +04:00
|
|
|
|
p { background: none }
|
2011-08-10 21:33:16 +04:00
|
|
|
|
</style>
|
|
|
|
|
<body>
|
2012-04-03 21:02:14 +04:00
|
|
|
|
<p>
|
2011-08-10 21:33:16 +04:00
|
|
|
|
''' % (css,))
|
2011-08-20 20:02:04 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-01-30 20:23:25 +04:00
|
|
|
|
def test_background_origin():
|
2012-01-31 14:45:24 +04:00
|
|
|
|
"""Test the background-origin property."""
|
2012-01-30 20:23:25 +04:00
|
|
|
|
def test_value(value, pixels, css=None):
|
|
|
|
|
assert_pixels('background_origin_' + value, 12, 12, pixels, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 12px }
|
2012-01-30 20:23:25 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; padding: 1px; height: 6px;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
background: url(pattern.png) bottom right no-repeat;
|
|
|
|
|
background-origin: %s }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''' % (css or value,))
|
|
|
|
|
|
|
|
|
|
test_value('border-box', [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+r+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
test_value('padding-box', [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
test_value('content-box', [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+r+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
test_value('border-box_clip', [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+r+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], css='border-box; background-clip: content-box')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-01-30 20:23:25 +04:00
|
|
|
|
def test_background_clip():
|
2012-01-31 14:45:24 +04:00
|
|
|
|
"""Test the background-clip property."""
|
2012-01-30 20:23:25 +04:00
|
|
|
|
def test_value(value, pixels):
|
|
|
|
|
assert_pixels('background_clip_' + value, 8, 8, pixels, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-01-30 20:23:25 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; padding: 1px; height: 2px;
|
|
|
|
|
border: 1px solid transparent;
|
|
|
|
|
background: #00f; background-clip : %s }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''' % (value,))
|
|
|
|
|
|
|
|
|
|
test_value('border-box', [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
test_value('padding-box', [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
test_value('content-box', [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+B+B+_+_+_,
|
|
|
|
|
_+_+_+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-01-31 14:45:24 +04:00
|
|
|
|
def test_background_size():
|
|
|
|
|
"""Test the background-size property."""
|
|
|
|
|
assert_pixels('background_size', 12, 12, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+r+r+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+r+r+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 12px }
|
2012-01-31 14:45:24 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; height: 10px;
|
|
|
|
|
/* Use nearest neighbor algorithm for image resizing: */
|
2012-07-04 13:27:20 +04:00
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-01-31 14:45:24 +04:00
|
|
|
|
background: url(pattern.png) bottom right no-repeat;
|
|
|
|
|
background-size: 8px }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-04-03 21:02:14 +04:00
|
|
|
|
assert_pixels('background_size_auto', 12, 12, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+r+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 12px }
|
2012-04-03 21:02:14 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; height: 10px;
|
|
|
|
|
/* Use nearest neighbor algorithm for image resizing: */
|
2012-07-04 13:27:20 +04:00
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-04-03 21:02:14 +04:00
|
|
|
|
background: url(pattern.png) bottom right no-repeat;
|
|
|
|
|
background-size: auto }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-01-31 14:45:24 +04:00
|
|
|
|
assert_pixels('background_size_contain', 14, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 14px 10px }
|
2012-01-31 14:45:24 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; height: 8px;
|
|
|
|
|
/* Use nearest neighbor algorithm for image resizing: */
|
2012-07-04 13:27:20 +04:00
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-01-31 14:45:24 +04:00
|
|
|
|
background: url(pattern.png) no-repeat;
|
|
|
|
|
background-size: contain }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-04-03 21:02:14 +04:00
|
|
|
|
assert_pixels('background_size_mixed', 14, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 14px 10px }
|
2012-04-03 21:02:14 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; height: 8px;
|
|
|
|
|
/* Use nearest neighbor algorithm for image resizing: */
|
2012-07-04 13:27:20 +04:00
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-04-03 21:02:14 +04:00
|
|
|
|
background: url(pattern.png) no-repeat;
|
|
|
|
|
background-size: auto 8px;
|
|
|
|
|
clip: auto; /* no-op to cover more validation */ }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-04-04 15:57:20 +04:00
|
|
|
|
assert_pixels('background_size_double', 14, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 14px 10px }
|
2012-04-04 15:57:20 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; height: 8px;
|
|
|
|
|
/* Use nearest neighbor algorithm for image resizing: */
|
2012-07-04 13:27:20 +04:00
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-04-04 15:57:20 +04:00
|
|
|
|
background: url(pattern.png) no-repeat;
|
|
|
|
|
background-size: 8px 4px;
|
|
|
|
|
clip: auto; /* no-op to cover more validation */ }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-01-31 14:45:24 +04:00
|
|
|
|
assert_pixels('background_size_cover', 14, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+r+r+r+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+r+r+r+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+r+r+r+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 14px 10px }
|
2012-01-31 14:45:24 +04:00
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 1px; height: 8px;
|
|
|
|
|
/* Use nearest neighbor algorithm for image resizing: */
|
2012-07-04 13:27:20 +04:00
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-01-31 14:45:24 +04:00
|
|
|
|
background: url(pattern.png) no-repeat;
|
|
|
|
|
background-size: cover }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2011-08-20 20:02:04 +04:00
|
|
|
|
def test_list_style_image():
|
2011-08-24 14:08:35 +04:00
|
|
|
|
"""Test images as list markers."""
|
2011-08-20 20:20:59 +04:00
|
|
|
|
for position, pixels in [
|
|
|
|
|
('outside', [
|
|
|
|
|
# ++++++++++++++ ++++ <li> horizontal margins: 7px 2px
|
|
|
|
|
# ###### <li> width: 12 - 7 - 2 = 3px
|
2011-08-22 20:14:37 +04:00
|
|
|
|
# -- list marker margin: 0.5em = 2px
|
|
|
|
|
# ******** list marker image is 4px wide
|
2011-08-20 20:20:59 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
2011-08-22 20:14:37 +04:00
|
|
|
|
_+_+r+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
2011-08-20 20:20:59 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
]),
|
|
|
|
|
('inside', [
|
|
|
|
|
# ++++++++++++++ ++++ <li> horizontal margins: 7px 2px
|
|
|
|
|
# ###### <li> width: 12 - 7 - 2 = 3px
|
2011-08-24 14:08:35 +04:00
|
|
|
|
# ******** list marker image is 4px wide: overflow
|
2011-08-20 20:20:59 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+r+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
]:
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('list_style_image_' + position, 12, 10, pixels, '''
|
2011-08-20 20:02:04 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 12px 10px }
|
2011-10-04 16:49:13 +04:00
|
|
|
|
body { margin: 0; background: white; font-family: %s }
|
2011-08-22 20:14:37 +04:00
|
|
|
|
ul { margin: 2px 2px 0 7px; list-style: url(pattern.png) %s;
|
|
|
|
|
font-size: 2px }
|
2011-08-20 20:02:04 +04:00
|
|
|
|
</style>
|
2011-08-22 20:14:37 +04:00
|
|
|
|
<ul><li></li></ul>
|
2011-10-04 16:49:13 +04:00
|
|
|
|
''' % (FONTS, position))
|
2011-08-21 00:59:27 +04:00
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('list_style_none', 10, 10, [
|
2011-08-22 20:14:37 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
2011-08-21 00:59:27 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 10px }
|
2011-10-04 16:49:13 +04:00
|
|
|
|
body { margin: 0; background: white; font-family: %s }
|
2011-08-21 00:59:27 +04:00
|
|
|
|
ul { margin: 0 0 0 5px; list-style: none; font-size: 2px; }
|
|
|
|
|
</style>
|
|
|
|
|
<ul><li>
|
2011-10-04 16:49:13 +04:00
|
|
|
|
''' % (FONTS,))
|
2011-08-25 19:29:16 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2011-08-25 19:29:16 +04:00
|
|
|
|
def test_images():
|
2011-09-02 20:54:24 +04:00
|
|
|
|
"""Test images sizes, positions and pixels."""
|
2011-08-25 19:29:16 +04:00
|
|
|
|
centered_image = [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
]
|
2012-02-22 15:11:44 +04:00
|
|
|
|
# JPG is lossy...
|
2012-12-29 04:00:30 +04:00
|
|
|
|
b = as_pixel(b'\x00\x00\xfe\xff')
|
2012-02-22 15:11:44 +04:00
|
|
|
|
blue_image = [
|
2011-12-09 13:15:55 +04:00
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
2012-02-22 15:11:44 +04:00
|
|
|
|
_+_+b+b+b+b+_+_,
|
|
|
|
|
_+_+b+b+b+b+_+_,
|
|
|
|
|
_+_+b+b+b+b+_+_,
|
|
|
|
|
_+_+b+b+b+b+_+_,
|
2011-12-09 13:15:55 +04:00
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
]
|
2011-08-25 19:29:16 +04:00
|
|
|
|
no_image = [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
]
|
2012-02-22 15:11:44 +04:00
|
|
|
|
for filename, image in [
|
|
|
|
|
('pattern.svg', centered_image),
|
|
|
|
|
('pattern.png', centered_image),
|
|
|
|
|
('pattern.palette.png', centered_image),
|
|
|
|
|
('pattern.gif', centered_image),
|
|
|
|
|
('blue.jpg', blue_image)]:
|
|
|
|
|
assert_pixels('inline_image_' + filename, 8, 8, image, '''
|
2012-01-16 14:39:02 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 2px 0 0 2px; background: #fff; font-size: 0 }
|
2012-01-16 14:39:02 +04:00
|
|
|
|
</style>
|
2012-02-22 15:11:44 +04:00
|
|
|
|
<div><img src="%s"></div>
|
|
|
|
|
''' % filename)
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('block_image', 8, 8, centered_image, '''
|
2011-08-25 19:32:23 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 0; background: #fff; font-size: 0 }
|
2011-08-25 19:32:23 +04:00
|
|
|
|
img { display: block; margin: 2px auto 0 }
|
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
2011-12-16 15:19:10 +04:00
|
|
|
|
with capture_logs() as logs:
|
|
|
|
|
assert_pixels('image_not_found', 8, 8, no_image, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 0; background: #fff; font-size: 0 }
|
2011-12-16 15:19:10 +04:00
|
|
|
|
img { display: block; margin: 2px auto 0 }
|
|
|
|
|
</style>
|
|
|
|
|
<div><img src="inexistent1.png" alt=""></div>
|
|
|
|
|
''')
|
|
|
|
|
assert len(logs) == 1
|
2012-03-21 17:34:27 +04:00
|
|
|
|
assert 'WARNING: Error for image' in logs[0]
|
2011-12-16 15:19:10 +04:00
|
|
|
|
assert 'inexistent1.png' in logs[0]
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('image_no_src', 8, 8, no_image, '''
|
2011-08-25 19:29:16 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 0; background: #fff; font-size: 0 }
|
2011-08-25 19:29:16 +04:00
|
|
|
|
img { display: block; margin: 2px auto 0 }
|
|
|
|
|
</style>
|
|
|
|
|
<div><img alt=""></div>
|
|
|
|
|
''')
|
2011-12-16 15:19:10 +04:00
|
|
|
|
with capture_logs() as logs:
|
|
|
|
|
assert_same_rendering(200, 30, [
|
2012-06-04 11:02:47 +04:00
|
|
|
|
(name, '''
|
2011-12-16 15:19:10 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 200px 30px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 0; background: #fff; font-size: 0 }
|
2011-12-16 15:19:10 +04:00
|
|
|
|
</style>
|
2012-06-04 11:02:47 +04:00
|
|
|
|
<div>%s</div>
|
|
|
|
|
''' % html)
|
|
|
|
|
for name, html in [
|
|
|
|
|
('image_alt_text_reference', 'Hello, world!'),
|
|
|
|
|
('image_alt_text_not_found',
|
|
|
|
|
'<img src="inexistent2.png" alt="Hello, world!">'),
|
|
|
|
|
('image_alt_text_no_src',
|
|
|
|
|
'<img alt="Hello, world!">'),
|
|
|
|
|
('image_svg_no_intrinsic_size',
|
|
|
|
|
'''<img src="data:image/svg+xml,<svg></svg>"
|
|
|
|
|
alt="Hello, world!">'''),
|
|
|
|
|
]
|
2011-12-16 15:19:10 +04:00
|
|
|
|
])
|
2012-06-04 11:02:47 +04:00
|
|
|
|
assert len(logs) == 2
|
2012-03-21 17:34:27 +04:00
|
|
|
|
assert 'WARNING: Error for image' in logs[0]
|
2011-12-16 15:19:10 +04:00
|
|
|
|
assert 'inexistent2.png' in logs[0]
|
2012-06-04 11:02:47 +04:00
|
|
|
|
assert 'WARNING: Error for image at data:image/svg+xml' in logs[1]
|
|
|
|
|
assert 'intrinsic size' in logs[1]
|
2011-10-21 13:15:06 +04:00
|
|
|
|
|
2012-06-01 12:02:48 +04:00
|
|
|
|
assert_pixels('image_0x1', 8, 8, no_image, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 2px; background: #fff; font-size: 0 }
|
2012-06-01 12:02:48 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png" alt="not shown"
|
|
|
|
|
style="width: 0; height: 1px"></div>
|
|
|
|
|
''')
|
|
|
|
|
assert_pixels('image_1x0', 8, 8, no_image, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 2px; background: #fff; font-size: 0 }
|
2012-06-01 12:02:48 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png" alt="not shown"
|
|
|
|
|
style="width: 1px; height: 0"></div>
|
|
|
|
|
''')
|
|
|
|
|
assert_pixels('image_0x0', 8, 8, no_image, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 2px; background: #fff; font-size: 0 }
|
2012-06-01 12:02:48 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png" alt="not shown"
|
|
|
|
|
style="width: 0; height: 0"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
2011-10-21 13:15:06 +04:00
|
|
|
|
|
2012-06-01 12:30:06 +04:00
|
|
|
|
page_break = [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
]
|
|
|
|
|
assert_pixels('image_page_break', 8, 3 * 8, page_break, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; margin: 2px; background: #fff }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { font-size: 0 }
|
2012-06-01 12:30:06 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
<div style="page-break-before: right"><img src="pattern.png"></div>
|
2012-08-03 14:38:17 +04:00
|
|
|
|
''')
|
2012-06-01 12:30:06 +04:00
|
|
|
|
|
2012-06-04 20:50:12 +04:00
|
|
|
|
# Regression test: padding used to be ignored on images
|
|
|
|
|
assert_pixels('image_with_padding', 8, 8, centered_image, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; background: #fff }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { font-size: 0 }
|
2012-06-04 20:50:12 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div style="line-height: 1px">
|
|
|
|
|
<img src=pattern.png style="padding: 2px 0 0 2px">
|
|
|
|
|
</div>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-06-04 16:37:00 +04:00
|
|
|
|
# Regression test: this used to cause an exception
|
|
|
|
|
assert_pixels('image_in_inline_block', 8, 8, centered_image, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 2px 0 0 2px; background: #fff; font-size: 0 }
|
2012-06-04 16:37:00 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div style="display: inline-block">
|
|
|
|
|
<p><img src=pattern.png></p>
|
|
|
|
|
</div>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-12-12 12:25:28 +04:00
|
|
|
|
# The same image is used in a repeating background,
|
|
|
|
|
# then in a non-repating <img>.
|
|
|
|
|
# If Pattern objects are shared carelessly, the image will be repeated.
|
|
|
|
|
assert_pixels('image_shared_pattern', 12, 12, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+b+b+b+b+b+b+b+b+_+_,
|
|
|
|
|
_+_+b+b+b+b+b+b+b+b+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+b+b+b+b+_+_+_+_+_+_,
|
|
|
|
|
_+_+b+b+b+b+_+_+_+_+_+_,
|
|
|
|
|
_+_+b+b+b+b+_+_+_+_+_+_,
|
|
|
|
|
_+_+b+b+b+b+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 12px }
|
|
|
|
|
body { margin: 2px; background: #fff; font-size: 0 }
|
|
|
|
|
</style>
|
|
|
|
|
<div style="background: url(blue.jpg);
|
|
|
|
|
height: 2px; margin-bottom: 1px"></div>
|
|
|
|
|
<img src=blue.jpg>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-06-01 12:30:06 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2011-10-21 13:15:06 +04:00
|
|
|
|
def test_visibility():
|
|
|
|
|
source = '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 12px 7px }
|
2011-10-21 13:15:06 +04:00
|
|
|
|
body { background: #fff; font: 1px/1 serif }
|
|
|
|
|
img { margin: 1px 0 0 1px; }
|
|
|
|
|
%(extra_css)s
|
|
|
|
|
</style>
|
|
|
|
|
<div>
|
|
|
|
|
<img src="pattern.png">
|
|
|
|
|
<span><img src="pattern.png"></span>
|
|
|
|
|
</div>
|
|
|
|
|
'''
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('visibility_reference', 12, 7, [
|
2011-10-21 13:15:06 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+r+B+B+B+_+r+B+B+B+_+_,
|
|
|
|
|
_+B+B+B+B+_+B+B+B+B+_+_,
|
|
|
|
|
_+B+B+B+B+_+B+B+B+B+_+_,
|
|
|
|
|
_+B+B+B+B+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': ''})
|
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('visibility_hidden', 12, 7, [
|
2011-10-21 13:15:06 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': 'div { visibility: hidden }'})
|
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('visibility_mixed', 12, 7, [
|
2011-10-21 13:15:06 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': '''div { visibility: hidden }
|
|
|
|
|
span { visibility: visible } '''})
|
2011-11-29 15:43:42 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-07-18 17:37:37 +04:00
|
|
|
|
@requires_cairo_1_12
|
2011-11-29 15:43:42 +04:00
|
|
|
|
def test_tables():
|
|
|
|
|
source = '''
|
|
|
|
|
<style>
|
2012-07-11 21:19:13 +04:00
|
|
|
|
@page { size: 28px; background: #fff }
|
2011-11-29 15:43:42 +04:00
|
|
|
|
table { margin: 1px; padding: 1px; border-spacing: 1px;
|
|
|
|
|
border: 1px solid transparent }
|
|
|
|
|
td { width: 2px; height: 2px; padding: 1px;
|
|
|
|
|
border: 1px solid transparent }
|
|
|
|
|
%(extra_css)s
|
|
|
|
|
</style>
|
|
|
|
|
<table>
|
|
|
|
|
<colgroup>
|
|
|
|
|
<col>
|
|
|
|
|
<col>
|
|
|
|
|
</colgroup>
|
|
|
|
|
<col>
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
2011-12-01 17:46:23 +04:00
|
|
|
|
<td></td>
|
|
|
|
|
<td rowspan=2></td>
|
|
|
|
|
<td></td>
|
2011-11-29 15:43:42 +04:00
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2011-12-01 17:46:23 +04:00
|
|
|
|
<td colspan=2></td>
|
|
|
|
|
<td></td>
|
2011-11-29 15:43:42 +04:00
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tr>
|
2011-12-01 17:46:23 +04:00
|
|
|
|
<td></td>
|
|
|
|
|
<td></td>
|
2011-11-29 15:43:42 +04:00
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
'''
|
2012-12-29 04:00:30 +04:00
|
|
|
|
r = as_pixel(b'\xff\x7f\x7f\xff') # rgba(255, 0, 0, 0.5) above #fff
|
|
|
|
|
R = as_pixel(b'\xff\x3f\x3f\xff') # r above r above #fff
|
|
|
|
|
g = as_pixel(b'\x7f\xff\x7f\xff') # rgba(0, 255, 0, 0.5) above #fff
|
|
|
|
|
G = as_pixel(b'\x7f\xbf\x3f\xff') # g above r above #fff
|
|
|
|
|
# Not the same as r above g above #fff
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('table_borders', 28, 28, [
|
2011-11-29 15:43:42 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+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|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+_+_+_+_+r+_+r+_+_+_+_+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+_+_+_+_+r+_+r+_+_+_+_+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+_+_+_+_+r+_+r+_+_+_+_+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+_+_+_+_+r+_+r+_+_+_+_+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': '''
|
2012-03-23 22:31:54 +04:00
|
|
|
|
table { border-color: #00f; table-layout: fixed }
|
2011-11-29 15:43:42 +04:00
|
|
|
|
td { border-color: rgba(255, 0, 0, 0.5) }
|
|
|
|
|
'''})
|
|
|
|
|
|
2012-07-11 20:21:20 +04:00
|
|
|
|
assert_pixels('table_collapsed_borders', 28, 28, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B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_+_+_+B+B+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': '''
|
|
|
|
|
table { border: 2px solid #00f; table-layout: fixed;
|
|
|
|
|
border-collapse: collapse }
|
|
|
|
|
td { border-color: #ff7f7f }
|
|
|
|
|
'''})
|
|
|
|
|
|
2012-07-11 21:33:11 +04:00
|
|
|
|
assert_pixels('table_collapsed_borders_paged', 28, 52, [
|
2012-07-11 21:19:13 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+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+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+g+_,
|
|
|
|
|
_+g+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+g+_,
|
|
|
|
|
_+g+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+g+_,
|
|
|
|
|
_+g+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+g+_,
|
|
|
|
|
_+g+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+g+_,
|
|
|
|
|
_+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': '''
|
2012-07-11 21:33:11 +04:00
|
|
|
|
table { border: solid #00f; border-width: 8px 2px;
|
|
|
|
|
table-layout: fixed; border-collapse: collapse }
|
2012-07-11 21:19:13 +04:00
|
|
|
|
td { border-color: #ff7f7f }
|
2012-07-11 21:33:11 +04:00
|
|
|
|
@page { size: 28px 26px; margin: 1px;
|
2012-07-11 21:19:13 +04:00
|
|
|
|
border: 1px solid rgba(0, 255, 0, 0.5); }
|
2012-08-03 14:38:17 +04:00
|
|
|
|
'''})
|
2012-07-11 21:19:13 +04:00
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('table_td_backgrounds', 28, 28, [
|
2011-11-29 15:43:42 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
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+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+r+r+r+r+r+r+_+r+r+r+r+r+r+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': '''
|
2012-03-23 22:31:54 +04:00
|
|
|
|
table { border-color: #00f; table-layout: fixed }
|
2011-11-29 15:43:42 +04:00
|
|
|
|
td { background: rgba(255, 0, 0, 0.5) }
|
|
|
|
|
'''})
|
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('table_column_backgrounds', 28, 28, [
|
2011-11-29 15:43:42 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+_+_+_+_+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+G+_+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+G+G+G+G+G+G+r+G+G+G+G+G+G+_+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+G+G+G+G+G+G+r+G+G+G+G+G+G+_+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+G+G+G+G+G+G+r+G+G+G+G+G+G+_+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+G+G+G+G+G+G+r+G+G+G+G+G+G+_+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+G+G+G+G+G+G+r+G+G+G+G+G+G+_+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+G+G+G+G+G+G+r+G+G+G+G+G+G+_+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': '''
|
2012-03-23 22:31:54 +04:00
|
|
|
|
table { border-color: #00f; table-layout: fixed }
|
2011-11-29 15:43:42 +04:00
|
|
|
|
colgroup { background: rgba(255, 0, 0, 0.5) }
|
|
|
|
|
col { background: rgba(0, 255, 0, 0.5) }
|
|
|
|
|
'''})
|
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels('table_row_backgrounds', 28, 28, [
|
2011-11-29 15:43:42 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
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+G+G+G+G+G+G+G+G+G+G+G+G+G+G+G+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+g+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], source % {'extra_css': '''
|
2012-03-23 22:31:54 +04:00
|
|
|
|
table { border-color: #00f; table-layout: fixed }
|
2011-11-29 15:43:42 +04:00
|
|
|
|
thead { background: rgba(255, 0, 0, 0.5) }
|
|
|
|
|
tr { background: rgba(0, 255, 0, 0.5) }
|
|
|
|
|
'''})
|
2011-12-02 19:51:41 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2011-12-02 19:51:41 +04:00
|
|
|
|
def test_before_after():
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_same_rendering(300, 30, [
|
2011-12-02 19:51:41 +04:00
|
|
|
|
('pseudo_before', '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 300px 30px }
|
2011-12-02 19:51:41 +04:00
|
|
|
|
body { margin: 0; background: #fff }
|
2012-07-29 17:13:16 +04:00
|
|
|
|
a[href]:before { content: '[' attr(href) '] ' }
|
2011-12-02 19:51:41 +04:00
|
|
|
|
</style>
|
|
|
|
|
<p><a href="some url">some content</p>
|
|
|
|
|
'''),
|
|
|
|
|
('pseudo_before_reference', '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 300px 30px }
|
2011-12-02 19:51:41 +04:00
|
|
|
|
body { margin: 0; background: #fff }
|
|
|
|
|
</style>
|
2012-07-29 17:13:16 +04:00
|
|
|
|
<p><a href="another url"><span>[some url] </span>some content</p>
|
2011-12-02 19:51:41 +04:00
|
|
|
|
''')
|
2012-07-29 01:02:36 +04:00
|
|
|
|
], tolerance=10)
|
2011-12-02 21:02:58 +04:00
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_same_rendering(500, 30, [
|
2012-02-17 21:49:58 +04:00
|
|
|
|
('pseudo_quotes', '''
|
2011-12-02 21:02:58 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 500px 30px }
|
2011-12-02 21:02:58 +04:00
|
|
|
|
body { margin: 0; background: #fff; quotes: '«' '»' '“' '”' }
|
|
|
|
|
q:before { content: open-quote ' '}
|
|
|
|
|
q:after { content: ' ' close-quote }
|
|
|
|
|
</style>
|
|
|
|
|
<p><q>Lorem ipsum <q>dolor</q> sit amet</q></p>
|
|
|
|
|
'''),
|
2012-02-17 21:49:58 +04:00
|
|
|
|
('pseudo_quotes_reference', '''
|
2011-12-02 21:02:58 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 500px 30px }
|
2011-12-02 21:02:58 +04:00
|
|
|
|
body { margin: 0; background: #fff }
|
2012-07-29 17:13:16 +04:00
|
|
|
|
q:before, q:after { content: none }
|
2011-12-02 21:02:58 +04:00
|
|
|
|
</style>
|
2012-07-29 17:13:16 +04:00
|
|
|
|
<p><span><span>« </span>Lorem ipsum
|
|
|
|
|
<span><span>“ </span>dolor<span> ”</span></span>
|
|
|
|
|
sit amet<span> »</span></span></p>
|
2011-12-02 21:02:58 +04:00
|
|
|
|
''')
|
2012-07-29 01:02:36 +04:00
|
|
|
|
], tolerance=10)
|
2011-12-02 21:19:34 +04:00
|
|
|
|
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_same_rendering(100, 30, [
|
2012-02-17 21:49:58 +04:00
|
|
|
|
('pseudo_url', '''
|
2011-12-02 21:19:34 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 100px 30px }
|
2011-12-02 21:19:34 +04:00
|
|
|
|
body { margin: 0; background: #fff; }
|
|
|
|
|
p:before { content: 'a' url(pattern.png) 'b'}
|
|
|
|
|
</style>
|
|
|
|
|
<p>c</p>
|
|
|
|
|
'''),
|
2012-02-17 21:49:58 +04:00
|
|
|
|
('pseudo_url_reference', '''
|
2011-12-02 21:19:34 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 100px 30px }
|
2011-12-02 21:19:34 +04:00
|
|
|
|
body { margin: 0; background: #fff }
|
|
|
|
|
</style>
|
2012-07-29 17:13:16 +04:00
|
|
|
|
<p><span>a<img src="pattern.png" alt="Missing image">b</span>c</p>
|
2011-12-02 21:19:34 +04:00
|
|
|
|
''')
|
2012-07-29 01:02:36 +04:00
|
|
|
|
], tolerance=10)
|
2011-12-13 18:42:35 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-08-03 18:21:47 +04:00
|
|
|
|
def test_borders(margin='10px', prop='border'):
|
2011-12-13 18:42:35 +04:00
|
|
|
|
"""Test the rendering of borders"""
|
2012-02-17 21:49:58 +04:00
|
|
|
|
source = '''
|
2011-12-13 18:42:35 +04:00
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 140px 110px }
|
2011-12-13 18:42:35 +04:00
|
|
|
|
html { background: #fff }
|
2012-08-03 18:21:47 +04:00
|
|
|
|
body { width: 100px; height: 70px;
|
|
|
|
|
margin: %s; %s: 10px %s blue }
|
2011-12-13 18:42:35 +04:00
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
'''
|
|
|
|
|
|
2011-12-13 19:40:27 +04:00
|
|
|
|
# Do not test the exact rendering of earch border style but at least
|
|
|
|
|
# check that they do not do the same.
|
|
|
|
|
assert_different_renderings(140, 110, [
|
2012-08-03 18:21:47 +04:00
|
|
|
|
('%s_%s' % (prop, border_style), source % (margin, prop, border_style))
|
2011-12-13 19:40:27 +04:00
|
|
|
|
for border_style in [
|
|
|
|
|
'none', 'solid', 'dashed', 'dotted', 'double',
|
|
|
|
|
'inset', 'outset', 'groove', 'ridge',
|
|
|
|
|
]
|
|
|
|
|
])
|
|
|
|
|
|
2012-08-03 18:21:47 +04:00
|
|
|
|
css_margin = margin
|
2011-12-13 18:42:35 +04:00
|
|
|
|
width = 140
|
|
|
|
|
height = 110
|
|
|
|
|
margin = 10
|
|
|
|
|
border = 10
|
2012-02-22 17:13:14 +04:00
|
|
|
|
solid_pixels = [[_] * width for y in xrange(height)]
|
2011-12-13 18:42:35 +04:00
|
|
|
|
for x in xrange(margin, width - margin):
|
2012-02-17 21:49:58 +04:00
|
|
|
|
for y in itertools.chain(
|
|
|
|
|
range(margin, margin + border),
|
|
|
|
|
range(height - margin - border, height - margin)):
|
2012-02-22 17:13:14 +04:00
|
|
|
|
solid_pixels[y][x] = B
|
2011-12-13 18:42:35 +04:00
|
|
|
|
for y in xrange(margin, height - margin):
|
2012-02-17 21:49:58 +04:00
|
|
|
|
for x in itertools.chain(
|
|
|
|
|
range(margin, margin + border),
|
|
|
|
|
range(width - margin - border, width - margin)):
|
2012-02-22 17:13:14 +04:00
|
|
|
|
solid_pixels[y][x] = B
|
|
|
|
|
solid_pixels = [b''.join(line) for line in solid_pixels]
|
2011-12-13 18:42:35 +04:00
|
|
|
|
assert_pixels(
|
2012-08-03 18:21:47 +04:00
|
|
|
|
prop + '_solid', 140, 110, solid_pixels,
|
|
|
|
|
source % (css_margin, prop, 'solid')
|
2011-12-02 21:19:34 +04:00
|
|
|
|
)
|
2011-12-28 21:20:55 +04:00
|
|
|
|
|
|
|
|
|
|
2012-08-03 18:21:47 +04:00
|
|
|
|
def test_outlines():
|
|
|
|
|
return test_borders(margin='20px', prop='outline')
|
|
|
|
|
|
|
|
|
|
|
2013-03-18 16:44:12 +04:00
|
|
|
|
@assert_no_logs
|
|
|
|
|
def test_small_borders():
|
|
|
|
|
# Regression test for ZeroDivisionError on dashed or dotted borders
|
|
|
|
|
# smaller than a dash/dot.
|
|
|
|
|
# https://github.com/Kozea/WeasyPrint/issues/49
|
|
|
|
|
|
|
|
|
|
# Do not test the exact rendering of earch border style but at least
|
|
|
|
|
# check that they do not do the same.
|
|
|
|
|
assert_different_renderings(50, 50, [('small_border_%s' % border_style, '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 50px 50px }
|
|
|
|
|
html { background: #fff }
|
|
|
|
|
body { margin: 5px; height: 0; border: 10px %s blue }
|
|
|
|
|
</style>
|
|
|
|
|
<body>''' % border_style)
|
|
|
|
|
for border_style in ['none', 'solid', 'dashed', 'dotted']
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2011-12-28 21:20:55 +04:00
|
|
|
|
def test_margin_boxes():
|
|
|
|
|
"""Test the rendering of margin boxes"""
|
2012-12-29 04:00:30 +04:00
|
|
|
|
_ = as_pixel(b'\xff\xff\xff\xff') # white
|
|
|
|
|
R = as_pixel(b'\xff\x00\x00\xff') # red
|
|
|
|
|
G = as_pixel(b'\x00\xff\x00\xff') # green
|
|
|
|
|
B = as_pixel(b'\x00\x00\xff\xff') # blue
|
|
|
|
|
g = as_pixel(b'\x00\x80\x00\xff') # half green
|
|
|
|
|
b = as_pixel(b'\x00\x00\x80\xff') # half blue
|
2011-12-28 21:20:55 +04:00
|
|
|
|
assert_pixels('margin_boxes', 15, 15, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+G+G+G+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+G+G+G+_+_+_+_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+R+R+R+R+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+R+R+R+R+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+R+R+R+R+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+R+R+R+R+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+b+b+b+_+_+_+_+_+_+g+g+g+g+_,
|
|
|
|
|
_+b+b+b+_+_+_+_+_+_+g+g+g+g+_,
|
|
|
|
|
_+b+b+b+_+_+_+_+_+_+g+g+g+g+_,
|
|
|
|
|
_+b+b+b+_+_+_+_+_+_+g+g+g+g+_,
|
|
|
|
|
_+b+b+b+_+_+_+_+_+_+g+g+g+g+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-01-27 19:53:16 +04:00
|
|
|
|
html { height: 100% }
|
2011-12-28 21:20:55 +04:00
|
|
|
|
body { background: #f00; height: 100% }
|
|
|
|
|
@page {
|
2012-07-04 13:27:20 +04:00
|
|
|
|
size: 15px;
|
2011-12-28 21:20:55 +04:00
|
|
|
|
margin: 4px 6px 7px 5px;
|
2012-01-27 19:53:16 +04:00
|
|
|
|
background: white;
|
2011-12-28 21:20:55 +04:00
|
|
|
|
|
|
|
|
|
@top-left-corner {
|
|
|
|
|
margin: 1px;
|
|
|
|
|
content: " ";
|
|
|
|
|
background: #0f0;
|
|
|
|
|
}
|
|
|
|
|
@top-right-corner {
|
|
|
|
|
margin: 1px;
|
|
|
|
|
content: " ";
|
|
|
|
|
background: #00f;
|
|
|
|
|
}
|
|
|
|
|
@bottom-right-corner {
|
|
|
|
|
margin: 1px;
|
|
|
|
|
content: " ";
|
|
|
|
|
background: #008000;
|
|
|
|
|
}
|
|
|
|
|
@bottom-left-corner {
|
|
|
|
|
margin: 1px;
|
|
|
|
|
content: " ";
|
|
|
|
|
background: #000080;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
2012-01-16 16:12:27 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-01-16 16:12:27 +04:00
|
|
|
|
def test_unicode():
|
|
|
|
|
"""Test non-ASCII filenames (URLs)"""
|
2012-02-17 21:49:58 +04:00
|
|
|
|
text = 'I løvë Unicode'
|
2012-01-16 16:12:27 +04:00
|
|
|
|
style = '''
|
|
|
|
|
@page {
|
2012-07-29 00:11:28 +04:00
|
|
|
|
background: #fff;
|
2012-07-04 13:27:20 +04:00
|
|
|
|
size: 200px 50px;
|
2012-01-16 16:12:27 +04:00
|
|
|
|
}
|
|
|
|
|
p { color: blue }
|
|
|
|
|
'''
|
2012-02-22 17:13:14 +04:00
|
|
|
|
_doc, expected_lines = html_to_pixels('unicode_reference', 200, 50, '''
|
2012-02-21 17:13:34 +04:00
|
|
|
|
<style>{0}</style>
|
|
|
|
|
<p><img src="pattern.png"> {1}</p>
|
2012-01-16 16:12:27 +04:00
|
|
|
|
'''.format(style, text))
|
|
|
|
|
|
|
|
|
|
temp = tempfile.mkdtemp(prefix=text + '-')
|
|
|
|
|
try:
|
|
|
|
|
stylesheet = os.path.join(temp, 'style.css')
|
|
|
|
|
image = os.path.join(temp, 'pattern.png')
|
|
|
|
|
html = os.path.join(temp, 'doc.html')
|
|
|
|
|
with open(stylesheet, 'wb') as fd:
|
2012-02-17 21:49:58 +04:00
|
|
|
|
fd.write(style.encode('utf8'))
|
2012-01-16 16:12:27 +04:00
|
|
|
|
with open(resource_filename('pattern.png'), 'rb') as fd:
|
|
|
|
|
image_content = fd.read()
|
|
|
|
|
with open(image, 'wb') as fd:
|
|
|
|
|
fd.write(image_content)
|
|
|
|
|
with open(html, 'wb') as fd:
|
2012-02-17 21:49:58 +04:00
|
|
|
|
html_content = '''
|
2012-02-21 17:13:34 +04:00
|
|
|
|
<link rel=stylesheet href="{0}">
|
|
|
|
|
<p><img src="{1}"> {2}</p>
|
2012-01-16 16:12:27 +04:00
|
|
|
|
'''.format(
|
|
|
|
|
ensure_url(stylesheet), ensure_url(image), text
|
2012-02-15 21:49:37 +04:00
|
|
|
|
)
|
|
|
|
|
fd.write(html_content.encode('utf8'))
|
2012-01-16 16:12:27 +04:00
|
|
|
|
|
2012-02-15 21:49:37 +04:00
|
|
|
|
# TODO: change this back to actually read from a file
|
2012-09-25 18:01:47 +04:00
|
|
|
|
document = TestHTML(html, encoding='utf8')
|
2012-02-22 17:13:14 +04:00
|
|
|
|
lines = document_to_pixels(document, 'unicode', 200, 50)
|
2012-01-16 16:12:27 +04:00
|
|
|
|
assert_pixels_equal('unicode', 200, 50, lines, expected_lines)
|
|
|
|
|
finally:
|
|
|
|
|
shutil.rmtree(temp)
|
2012-02-07 19:59:22 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-02-07 19:59:22 +04:00
|
|
|
|
def test_overflow():
|
|
|
|
|
"""Test the overflow property."""
|
2012-02-07 21:06:59 +04:00
|
|
|
|
# See test_images
|
2012-02-07 19:59:22 +04:00
|
|
|
|
assert_pixels('inline_image_overflow', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { margin: 2px 0 0 2px; background: #fff; font-size:0 }
|
2012-02-07 19:59:22 +04:00
|
|
|
|
div { height: 2px; overflow: hidden }
|
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
# <body> is only 1px high, but its overflow is propageted to the viewport
|
|
|
|
|
# ie. the padding edge of the page box.
|
|
|
|
|
assert_pixels('inline_image_viewport_overflow', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; background: #fff;
|
2012-02-07 19:59:22 +04:00
|
|
|
|
margin: 2px;
|
|
|
|
|
padding-bottom: 2px;
|
|
|
|
|
border-bottom: 1px transparent solid; }
|
2012-06-08 18:10:35 +04:00
|
|
|
|
body { height: 1px; overflow: hidden; font-size:0 }
|
2012-02-07 19:59:22 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
2012-02-07 21:06:59 +04:00
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-07-18 17:37:37 +04:00
|
|
|
|
@requires_cairo_1_12
|
2012-02-07 21:06:59 +04:00
|
|
|
|
def test_clip():
|
|
|
|
|
"""Test the clip property."""
|
2012-04-04 15:57:20 +04:00
|
|
|
|
num = [0]
|
|
|
|
|
def clip(css, pixels):
|
|
|
|
|
num[0] += 1
|
|
|
|
|
name = 'background_repeat_clipped_%s' % num[0]
|
|
|
|
|
assert_pixels(name, 14, 16, pixels, '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 14px 16px; background: #fff }
|
2012-08-03 19:19:04 +04:00
|
|
|
|
div { margin: 1px; border: 1px green solid;
|
2012-04-04 15:57:20 +04:00
|
|
|
|
background: url(pattern.png);
|
2012-08-03 19:19:04 +04:00
|
|
|
|
position: absolute; /* clip only applies on abspos */
|
|
|
|
|
top: 0; bottom: 2px; left: 0; right: 0;
|
2012-04-04 15:57:20 +04:00
|
|
|
|
clip: rect(%s); }
|
|
|
|
|
</style>
|
|
|
|
|
<div>
|
|
|
|
|
''' % (css,))
|
|
|
|
|
|
2012-12-29 04:00:30 +04:00
|
|
|
|
g = as_pixel(b'\x00\x80\x00\xff') # green
|
2012-04-04 15:57:20 +04:00
|
|
|
|
clip('5px, 5px, 9px, auto', [
|
2012-02-07 21:06:59 +04:00
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+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_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+r+B+B+B+r+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+B+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
])
|
|
|
|
|
|
2012-02-07 21:26:23 +04:00
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-02-07 21:26:23 +04:00
|
|
|
|
def test_opacity():
|
|
|
|
|
"""Test the opacity property."""
|
|
|
|
|
template = '''
|
|
|
|
|
<style>
|
2012-07-29 01:02:36 +04:00
|
|
|
|
@page { size: 60px 60px }
|
2012-02-07 21:26:23 +04:00
|
|
|
|
body { margin: 0; background: #fff }
|
2012-07-29 01:02:36 +04:00
|
|
|
|
div { background: #000; width: 20px; height: 20px }
|
2012-02-07 21:26:23 +04:00
|
|
|
|
</style>
|
|
|
|
|
%s
|
|
|
|
|
'''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
assert_same_rendering(60, 60, [
|
2012-02-07 21:26:23 +04:00
|
|
|
|
('opacity_0_reference', template % '''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
<div></div>
|
2012-02-07 21:26:23 +04:00
|
|
|
|
'''),
|
2012-02-07 21:47:52 +04:00
|
|
|
|
('opacity_0', template % '''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
<div></div>
|
|
|
|
|
<div style="opacity: 0"></div>
|
2012-02-07 21:47:52 +04:00
|
|
|
|
'''),
|
2012-02-07 21:26:23 +04:00
|
|
|
|
])
|
2012-07-29 01:02:36 +04:00
|
|
|
|
assert_same_rendering(60, 60, [
|
2012-02-07 21:47:52 +04:00
|
|
|
|
('opacity_color_reference', template % '''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
<div style="background: rgb(102, 102, 102)"></div>
|
2012-02-07 21:47:52 +04:00
|
|
|
|
'''),
|
2012-02-07 21:26:23 +04:00
|
|
|
|
('opacity_color', template % '''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
<div style="opacity: 0.6"></div>
|
2012-02-07 21:26:23 +04:00
|
|
|
|
'''),
|
2012-02-07 21:47:52 +04:00
|
|
|
|
])
|
2012-07-29 01:02:36 +04:00
|
|
|
|
assert_same_rendering(60, 60, [
|
2012-02-07 21:47:52 +04:00
|
|
|
|
('opacity_multiplied_reference', template % '''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
<div style="background: rgb(102, 102, 102)"></div>
|
2012-02-07 21:47:52 +04:00
|
|
|
|
'''),
|
|
|
|
|
('opacity_multiplied', template % '''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
<div style="opacity: 0.6"></div>
|
2012-02-07 21:26:23 +04:00
|
|
|
|
'''),
|
2012-02-07 21:47:52 +04:00
|
|
|
|
('opacity_multiplied_2', template % '''
|
2012-07-29 01:02:36 +04:00
|
|
|
|
<div style="background: none; opacity: 0.666666">
|
|
|
|
|
<div style="opacity: 0.9"></div>
|
|
|
|
|
</div>
|
2012-02-07 21:47:52 +04:00
|
|
|
|
'''), # 0.9 * 0.666666 == 0.6
|
2012-02-07 21:26:23 +04:00
|
|
|
|
])
|
2012-02-08 18:44:03 +04:00
|
|
|
|
|
|
|
|
|
|
2013-01-23 19:52:47 +04:00
|
|
|
|
@assert_no_logs
|
|
|
|
|
def test_current_color():
|
|
|
|
|
"""Test inheritance of the currentColor keyword."""
|
|
|
|
|
G = b'\x00\xff\x00\xff' # lime (light green)
|
|
|
|
|
assert_pixels('background_current_color', 2, 2, [G+G, G+G], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 2px }
|
|
|
|
|
html, body { height: 100%; margin: 0 }
|
|
|
|
|
html { color: red; background: currentColor }
|
|
|
|
|
body { color: lime; background: inherit }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
assert_pixels('border_current_color', 2, 2, [G+G, G+G], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 2px }
|
|
|
|
|
html { color: red; border-color: currentColor }
|
|
|
|
|
body { color: lime; border: 1px solid; border-color: inherit;
|
|
|
|
|
margin: 0 }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
assert_pixels('outline_current_color', 2, 2, [G+G, G+G], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 2px }
|
|
|
|
|
html { color: red; outline-color: currentColor }
|
|
|
|
|
body { color: lime; outline: 1px solid; outline-color: inherit;
|
|
|
|
|
margin: 1px }
|
|
|
|
|
</style>
|
|
|
|
|
<body>
|
|
|
|
|
''')
|
|
|
|
|
assert_pixels('border_collapse_current_color', 2, 2, [G+G, G+G], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 2px }
|
|
|
|
|
html { color: red; border-color: currentColor; }
|
|
|
|
|
body { margin: 0 }
|
|
|
|
|
table { border-collapse: collapse;
|
|
|
|
|
color: lime; border: 1px solid; border-color: inherit }
|
|
|
|
|
</style>
|
|
|
|
|
<table><td>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
|
2012-02-20 16:04:35 +04:00
|
|
|
|
@assert_no_logs
|
2012-02-08 18:44:03 +04:00
|
|
|
|
def test_2d_transform():
|
|
|
|
|
"""Test 2D transformations."""
|
|
|
|
|
assert_pixels('image_rotate90', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+r+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: rotate(90deg); font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
2012-10-06 13:26:55 +04:00
|
|
|
|
assert_pixels('image_translateX_rotate90', 12, 12, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+r+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+B+B+B+B+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 12px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: translateX(3px) rotate(90deg);
|
|
|
|
|
font-size: 0; width: 4px }
|
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
# A translateX after the rotation is actually a translateY
|
|
|
|
|
assert_pixels('image_rotate90_translateX', 12, 12, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+r+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 12px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: rotate(90deg) translateX(3px);
|
|
|
|
|
font-size: 0; width: 4px }
|
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
2012-10-07 00:09:17 +04:00
|
|
|
|
assert_pixels('nested_rotate90_translateX', 12, 12, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+r+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
|
|
|
|
@page { size: 12px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: rotate(90deg); font-size: 0; width: 4px }
|
|
|
|
|
img { transform: translateX(3px) }
|
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
2012-10-06 13:26:55 +04:00
|
|
|
|
|
2012-02-08 18:44:03 +04:00
|
|
|
|
assert_pixels('image_reflection', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+r+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: matrix(-1, 0, 0, 1, 0, 0); font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_translate', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+r+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: translate(1px, 2px); font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_translate_percentage', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+r+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: translate(25%, 0); font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_translateX', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+r+B+B,
|
|
|
|
|
_+_+_+_+_+B+B+B,
|
|
|
|
|
_+_+_+_+_+B+B+B,
|
|
|
|
|
_+_+_+_+_+B+B+B,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: translateX(0.25em); font-size: 12px }
|
2012-06-21 17:10:17 +04:00
|
|
|
|
div div { font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
2012-06-21 17:10:17 +04:00
|
|
|
|
<div><div><img src="pattern.png"></div></div>
|
2012-02-08 18:44:03 +04:00
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_translateY', 8, 8, [
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 8px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: translateY(-1px); font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_scale', 10, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 10px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: scale(2, 2);
|
|
|
|
|
transform-origin: 1px 1px;
|
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-06-08 18:10:35 +04:00
|
|
|
|
font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_scale12', 10, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 10px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: scale(1, 2);
|
|
|
|
|
transform-origin: 1px 1px;
|
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-06-08 18:10:35 +04:00
|
|
|
|
font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_scaleY', 10, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+r+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+B+B+B+B+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 10px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: scaleY(2);
|
|
|
|
|
transform-origin: 1px 1px;
|
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-06-08 18:10:35 +04:00
|
|
|
|
font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
assert_pixels('image_scaleX', 10, 10, [
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+r+r+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+B+B+B+B+B+B+B+B+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
_+_+_+_+_+_+_+_+_+_,
|
|
|
|
|
], '''
|
|
|
|
|
<style>
|
2012-07-04 13:27:20 +04:00
|
|
|
|
@page { size: 10px; margin: 2px; background: #fff; }
|
|
|
|
|
div { transform: scaleX(2);
|
|
|
|
|
transform-origin: 1px 1px;
|
|
|
|
|
image-rendering: optimizeSpeed;
|
2012-06-08 18:10:35 +04:00
|
|
|
|
font-size: 0 }
|
2012-02-08 18:44:03 +04:00
|
|
|
|
</style>
|
|
|
|
|
<div><img src="pattern.png"></div>
|
|
|
|
|
''')
|
2012-06-05 15:52:57 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@assert_no_logs
|
2012-07-18 17:37:37 +04:00
|
|
|
|
@requires_cairo_1_12
|
2012-06-05 15:52:57 +04:00
|
|
|
|
def test_acid2():
|
|
|
|
|
"""A local version of http://acid2.acidtests.org/"""
|
2012-10-02 20:59:02 +04:00
|
|
|
|
def render(filename):
|
|
|
|
|
return HTML(resource_filename(filename)).render(enable_hinting=True)
|
2012-06-05 15:52:57 +04:00
|
|
|
|
|
|
|
|
|
with capture_logs():
|
2012-06-28 19:41:42 +04:00
|
|
|
|
# This is a copy of http://www.webstandards.org/files/acid2/test.html
|
2012-10-02 20:59:02 +04:00
|
|
|
|
document = render('acid2-test.html')
|
|
|
|
|
intro_page, test_page = document.pages
|
2012-06-28 19:41:42 +04:00
|
|
|
|
# Ignore the intro page: it is not in the reference
|
2012-12-29 04:00:30 +04:00
|
|
|
|
test_image, width, height = document.copy(
|
|
|
|
|
[test_page]).write_image_surface()
|
2012-06-28 19:41:42 +04:00
|
|
|
|
|
|
|
|
|
# This is a copy of http://www.webstandards.org/files/acid2/reference.html
|
2012-12-29 04:00:30 +04:00
|
|
|
|
ref_image, ref_width, ref_height = render(
|
|
|
|
|
'acid2-reference.html').write_image_surface()
|
2012-06-28 19:41:42 +04:00
|
|
|
|
|
|
|
|
|
assert (width, height) == (ref_width, ref_height)
|
|
|
|
|
assert_pixels_equal(
|
2012-12-29 04:00:30 +04:00
|
|
|
|
'acid2', width, height, image_to_pixels(test_image, width, height),
|
|
|
|
|
image_to_pixels(ref_image, width, height), tolerance=2)
|