This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/openoffice-devtools.git
commit 9d2c293efb1c671890e3aab225c6d48ba127c161 Author: Jim Jagielski <[email protected]> AuthorDate: Mon Nov 2 09:14:01 2026 -0500 test: port nine more fixture builders; add -m crash and --start-timeout --- test/USAGE.md | 2 + test/conftest.py | 8 +- test/data/checks/alien-attrs/calc.json | 16 + test/data/checks/alien-attrs/draw.json | 16 + test/data/checks/alien-attrs/writer-cell.json | 16 + test/data/checks/alien-attrs/writer-foreign.json | 20 ++ test/data/checks/alien-attrs/writer.json | 25 ++ test/data/checks/chart-shapes/checks.json | 29 ++ test/data/checks/connector-viewbox/checks.json | 348 ++++++++++++++++++ test/data/checks/grid-snap/checks.json | 26 ++ test/data/checks/normal-values5b/checks-image.json | 82 +++++ test/data/checks/ole-text-edge/checks.json | 77 ++++ test/data/checks/ole-text/checks.json | 18 + .../checks/para-fill-foreign/checks-aoo-form.json | 378 ++++++++++++++++++++ test/data/checks/para-fill/bitmap.json | 28 ++ test/data/checks/para-fill/checks.json | 224 ++++++++++++ test/data/checks/row-split/checks.json | 11 + test/data/expect/crash.tsv | 2 + test/data/expect/odf14.tsv | 2 + test/data/expect/reload.tsv | 49 +++ test/data/expect/schema.tsv | 4 + test/pyproject.toml | 3 +- test/src/aootest/documents.py | 60 +++- test/src/aootest_worker/ops/generate.py | 394 ++++++++++++++++++++- test/tests/odf/test_known_crashes.py | 32 ++ 25 files changed, 1850 insertions(+), 20 deletions(-) diff --git a/test/USAGE.md b/test/USAGE.md index 04ba5b0..11c2cd8 100644 --- a/test/USAGE.md +++ b/test/USAGE.md @@ -32,6 +32,7 @@ Each download is checked against its pinned sha256 before it is used. The cache python3 -m pytest -m smoke # quick office checks python3 -m pytest -m "not slow" # all of the above python3 -m pytest tests/odf # save modes and the other families, slow + python3 -m pytest -m crash # known crashes of the office, kept out of the default run python3 -m pytest -k convert # any pytest selection works ## Options @@ -42,6 +43,7 @@ Each download is checked against its pinned sha256 before it is used. The cache | `--uno-python PATH` | `AOO_UNO_PYTHON` | A Python that can import `uno`. Skips the search; if it fails the probe, that is an error. | | `--connect socket\|pipe` | | How the worker reaches the office. Default `socket`. | | `--max-restarts N` | | Office restarts allowed per save mode before the session aborts. Default 5. | +| `--start-timeout S` | | Seconds an office may take to start and accept a connection. Default 240; starts have taken from 5 to 90 seconds on a busy desktop. | | `--require-office` | | Fail instead of skip when there is no usable office. | | `--require-odf13` | | Fail instead of skip the ODF 1.3 save modes when the build cannot write 1.3. | | `--documents DIR` | | Extra ODF documents to run through every save mode. | diff --git a/test/conftest.py b/test/conftest.py index 4ca6781..dd877ef 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -34,6 +34,7 @@ def pytest_addoption(parser): g.addoption("--office", default=None, help="an AOO 5+ install: .app, install root, program dir or soffice (default: $AOO_OFFICE)") g.addoption("--uno-python", default=None, help="Python that can import uno (default: $AOO_UNO_PYTHON, else probed)") g.addoption("--connect", choices=("socket", "pipe"), default="socket", help="how the worker reaches the office") + g.addoption("--start-timeout", type=float, default=240.0, help="seconds an office may take to start and accept a connection (default %(default)s)") g.addoption("--max-restarts", type=int, default=5, help="office restarts allowed per mode before the session aborts") g.addoption("--require-office", action="store_true", help="fail instead of skipping when no usable office is found") g.addoption("--documents", default=None, help="a directory of ODF documents to run through every save mode, in addition to the ones the office ships") @@ -73,8 +74,9 @@ def aoo_python(pytestconfig, aoo_layout, tmp_path_factory): class Offices: """One lazily started office and worker per ODF mode (None = product default, or a Save/ODF/DefaultVersion number).""" - def __init__(self, layout, python, workdir, connect, max_restarts): + def __init__(self, layout, python, workdir, connect, max_restarts, start_timeout=240.0): self.layout, self.python, self.workdir, self.connect, self.max_restarts = layout, python, workdir, connect, max_restarts + self.start_timeout = start_timeout self.sessions = {} def get(self, mode=None, extra=None, tag=None): @@ -82,7 +84,7 @@ class Offices: key = (mode, tag) if key not in self.sessions: self.sessions[key] = session.ModeSession(self.layout, self.python, mode, self.workdir, self.connect, self.max_restarts, - extra=extra, tag=tag) + connect_timeout=self.start_timeout, extra=extra, tag=tag) return self.sessions[key] def close(self): @@ -95,7 +97,7 @@ class Offices: @pytest.fixture(scope="session") def aoo_offices(pytestconfig, aoo_layout, aoo_python, tmp_path_factory): offices = Offices(aoo_layout, aoo_python, tmp_path_factory.mktemp("aoo"), pytestconfig.getoption("--connect"), - pytestconfig.getoption("--max-restarts")) + pytestconfig.getoption("--max-restarts"), pytestconfig.getoption("--start-timeout")) yield offices offices.close() diff --git a/test/data/checks/alien-attrs/calc.json b/test/data/checks/alien-attrs/calc.json new file mode 100644 index 0000000..b204c9b --- /dev/null +++ b/test/data/checks/alien-attrs/calc.json @@ -0,0 +1,16 @@ +[ + { + "name": "calc_aliens", + "expr": "sorted(doc.Sheets.getByIndex(0).getCellByPosition(0, 0).UserDefinedAttributes.ElementNames)", + "expect": [ + "ex:alien-foreign" + ] + }, + { + "name": "calc_aliens_foreign", + "expr": "[n for n in sorted(doc.Sheets.getByIndex(0).getCellByPosition(0, 0).UserDefinedAttributes.ElementNames) if n.startswith('ex:')]", + "expect": [ + "ex:alien-foreign" + ] + } +] diff --git a/test/data/checks/alien-attrs/draw.json b/test/data/checks/alien-attrs/draw.json new file mode 100644 index 0000000..e53a831 --- /dev/null +++ b/test/data/checks/alien-attrs/draw.json @@ -0,0 +1,16 @@ +[ + { + "name": "draw_aliens", + "expr": "sorted(doc.DrawPages.getByIndex(0).getByIndex(0).UserDefinedAttributes.ElementNames)", + "expect": [ + "ex:alien-foreign" + ] + }, + { + "name": "draw_aliens_foreign", + "expr": "[n for n in sorted(doc.DrawPages.getByIndex(0).getByIndex(0).UserDefinedAttributes.ElementNames) if n.startswith('ex:')]", + "expect": [ + "ex:alien-foreign" + ] + } +] diff --git a/test/data/checks/alien-attrs/writer-cell.json b/test/data/checks/alien-attrs/writer-cell.json new file mode 100644 index 0000000..4e72fde --- /dev/null +++ b/test/data/checks/alien-attrs/writer-cell.json @@ -0,0 +1,16 @@ +[ + { + "name": "writer_aliens_cell", + "expr": "sorted(doc.TextTables.getByIndex(0).getCellByName('A1').UserDefinedAttributes.ElementNames)", + "expect": [ + "draw:alien-draw", + "ex:alien-foreign", + "fo:alien-fo", + "office:alien-office", + "style:alien-style", + "svg:alien-svg", + "table:alien-table", + "text:enable-numbering" + ] + } +] diff --git a/test/data/checks/alien-attrs/writer-foreign.json b/test/data/checks/alien-attrs/writer-foreign.json new file mode 100644 index 0000000..23d180d --- /dev/null +++ b/test/data/checks/alien-attrs/writer-foreign.json @@ -0,0 +1,20 @@ +[ + { + "name": "writer_aliens_foreign", + "expr": "[[n for n in sorted(x.ElementNames) if n.startswith('ex:')] for x in (doc.Text.createTextCursor().ParaUserDefinedAttributes, doc.TextTables.getByIndex(0).UserDefinedAttributes, doc.TextTables.getByIndex(0).getCellByName('A1').UserDefinedAttributes, doc.TextSections.getByIndex(0).UserDefinedAttributes)]", + "expect": [ + [ + "ex:alien-foreign" + ], + [ + "ex:alien-foreign" + ], + [ + "ex:alien-foreign" + ], + [ + "ex:alien-foreign" + ] + ] + } +] diff --git a/test/data/checks/alien-attrs/writer.json b/test/data/checks/alien-attrs/writer.json new file mode 100644 index 0000000..9192048 --- /dev/null +++ b/test/data/checks/alien-attrs/writer.json @@ -0,0 +1,25 @@ +[ + { + "name": "writer_aliens", + "expr": "[sorted(doc.Text.createTextCursor().ParaUserDefinedAttributes.ElementNames), sorted(doc.TextTables.getByIndex(0).UserDefinedAttributes.ElementNames), sorted(doc.TextSections.getByIndex(0).UserDefinedAttributes.ElementNames)]", + "expect": [ + [ + "ex:alien-foreign", + "text:enable-numbering" + ], + [ + "draw:alien-draw", + "ex:alien-foreign", + "fo:alien-fo", + "office:alien-office", + "style:alien-style", + "svg:alien-svg", + "table:alien-table", + "text:enable-numbering" + ], + [ + "ex:alien-foreign" + ] + ] + } +] \ No newline at end of file diff --git a/test/data/checks/chart-shapes/checks.json b/test/data/checks/chart-shapes/checks.json new file mode 100644 index 0000000..ea35f87 --- /dev/null +++ b/test/data/checks/chart-shapes/checks.json @@ -0,0 +1,29 @@ +[ + { + "name": "chart_shapes", + "expr": "[[s.ShapeType, getattr(s, 'String', None)] for s in [doc.Sheets.getByIndex(0).Charts.getByIndex(0).EmbeddedObject.DrawPage.getByIndex(i) for i in range(doc.Sheets.getByIndex(0).Charts.getByIndex(0).EmbeddedObject.DrawPage.Count)]]", + "expect": [ + [ + "com.sun.star.drawing.GroupShape", + null + ], + [ + "com.sun.star.drawing.PolyLineShape", + "" + ], + [ + "com.sun.star.drawing.RectangleShape", + "rect" + ], + [ + "com.sun.star.drawing.TextShape", + "note" + ] + ] + }, + { + "name": "chart_type", + "expr": "doc.Sheets.getByIndex(0).Charts.getByIndex(0).EmbeddedObject.getDiagram().getDiagramType()", + "expect": "com.sun.star.chart.BarDiagram" + } +] \ No newline at end of file diff --git a/test/data/checks/connector-viewbox/checks.json b/test/data/checks/connector-viewbox/checks.json new file mode 100644 index 0000000..cf49ec8 --- /dev/null +++ b/test/data/checks/connector-viewbox/checks.json @@ -0,0 +1,348 @@ +[ + { + "name": "connectors", + "expr": "[[s.Name, s.StartPosition.X, s.StartPosition.Y, s.EndPosition.X, s.EndPosition.Y, s.EdgeKind.value, [[[p.X, p.Y] for p in seg] for seg in s.PolyPolygonBezier.Coordinates], [[f.value for f in seg] for seg in s.PolyPolygonBezier.Flags], (s.StartShape.Position.X if s.StartShape else None), (s.EndShape.Position.X if s.EndShape else None), s.StartGluePointIndex, s.EndGluePointIndex] for s in [doc.DrawPages.getByIndex(0).getByIndex(i) for i in range(doc.DrawPages.getByIndex(0).Count [...] + "expect": [ + [ + "std_free", + 2000, + 2000, + 8000, + 6000, + "STANDARD", + [ + [ + [ + 2000, + 2000 + ], + [ + 5000, + 2000 + ], + [ + 5000, + 6000 + ], + [ + 8000, + 6000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL", + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "curve_free", + 10000, + 2000, + 16000, + 6000, + "CURVE", + [ + [ + [ + 10000, + 2000 + ], + [ + 14500, + 2000 + ], + [ + 11500, + 6000 + ], + [ + 16000, + 6000 + ] + ] + ], + [ + [ + "NORMAL", + "CONTROL", + "CONTROL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "line_h", + 2000, + 8000, + 8000, + 8000, + "LINE", + [ + [ + [ + 2000, + 8000 + ], + [ + 8000, + 8000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "line_v", + 10000, + 8000, + 10000, + 11000, + "LINE", + [ + [ + [ + 10000, + 8000 + ], + [ + 10000, + 11000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "line_rev", + 18000, + 9000, + 14000, + 5000, + "LINE", + [ + [ + [ + 18000, + 9000 + ], + [ + 14000, + 5000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "std_h", + 2000, + 28000, + 8000, + 28000, + "STANDARD", + [ + [ + [ + 2000, + 28000 + ], + [ + 8000, + 28000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "std_v", + 16000, + 28000, + 16000, + 32000, + "STANDARD", + [ + [ + [ + 16000, + 28000 + ], + [ + 16000, + 32000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ], + [ + "std_conn", + 4000, + 13000, + 12000, + 17000, + "STANDARD", + [ + [ + [ + 4000, + 13000 + ], + [ + 8000, + 13000 + ], + [ + 8000, + 17000 + ], + [ + 12000, + 17000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL", + "NORMAL", + "NORMAL" + ] + ], + 1000, + 12000, + -1, + -1 + ], + [ + "curve_conn", + 4000, + 21000, + 9000, + 25000, + "CURVE", + [ + [ + [ + 4000, + 21000 + ], + [ + 7750, + 21000 + ], + [ + 5250, + 25000 + ], + [ + 9000, + 25000 + ] + ] + ], + [ + [ + "NORMAL", + "CONTROL", + "CONTROL", + "NORMAL" + ] + ], + 1000, + 9000, + -1, + -1 + ], + [ + "lines_free", + 2000, + 34000, + 9000, + 38000, + "LINES", + [ + [ + [ + 2000, + 34000 + ], + [ + 9000, + 38000 + ] + ] + ], + [ + [ + "NORMAL", + "NORMAL" + ] + ], + null, + null, + -1, + -1 + ] + ] + } +] \ No newline at end of file diff --git a/test/data/checks/grid-snap/checks.json b/test/data/checks/grid-snap/checks.json new file mode 100644 index 0000000..3d42a4e --- /dev/null +++ b/test/data/checks/grid-snap/checks.json @@ -0,0 +1,26 @@ +[ + { + "name": "page_grid", + "expr": "[(n, ps.GridMode, ps.GridBaseWidth, ps.GridSnapToChars) for n in ('G_snap_on','G_snap_off','G_lines_off') for ps in [doc.StyleFamilies.getByName('PageStyles').getByName(n)]]", + "expect": [ + [ + "G_snap_on", + 2, + 706, + true + ], + [ + "G_snap_off", + 2, + 706, + false + ], + [ + "G_lines_off", + 1, + 706, + false + ] + ] + } +] diff --git a/test/data/checks/normal-values5b/checks-image.json b/test/data/checks/normal-values5b/checks-image.json new file mode 100644 index 0000000..a3e9231 --- /dev/null +++ b/test/data/checks/normal-values5b/checks-image.json @@ -0,0 +1,82 @@ +[ + { + "name": "symbol_image", + "expr": "[(n, [(str(s.Symbol.Style.value), s.Symbol.Graphic is not None, s.Symbol.Graphic.Type if s.Symbol.Graphic is not None else None, s.Symbol.Size.Width, s.Symbol.Size.Height) for s in sh.Charts.getByName(n).EmbeddedObject.getFirstDiagram().getCoordinateSystems()[0].getChartTypes()[0].getDataSeries()]) for sh in [doc.Sheets.getByIndex(0)] for n in sh.Charts.ElementNames]", + "expect": [ + [ + "c1", + [ + [ + "GRAPHIC", + true, + 1, + 250, + 250 + ], + [ + "AUTO", + false, + null, + 175, + 175 + ] + ] + ], + [ + "c2", + [ + [ + "NONE", + false, + null, + 250, + 250 + ], + [ + "NONE", + false, + null, + 250, + 250 + ] + ] + ] + ] + }, + { + "name": "series_data", + "expr": "[(n, [[list(q.Values.getData()) for q in s.getDataSequences()] for s in sh.Charts.getByName(n).EmbeddedObject.getFirstDiagram().getCoordinateSystems()[0].getChartTypes()[0].getDataSeries()]) for sh in [doc.Sheets.getByIndex(0)] for n in sh.Charts.ElementNames]", + "expect": [ + [ + "c1", + [ + [ + [ + 1.0, + 3.0, + 4.0 + ] + ], + [ + [] + ] + ] + ], + [ + "c2", + [ + [ + [ + 1.0, + 3.0, + 4.0 + ] + ], + [ + [] + ] + ] + ] + ] + } +] diff --git a/test/data/checks/ole-text-edge/checks.json b/test/data/checks/ole-text-edge/checks.json new file mode 100644 index 0000000..394072d --- /dev/null +++ b/test/data/checks/ole-text-edge/checks.json @@ -0,0 +1,77 @@ +[ + { + "name": "ole_text", + "expr": "[[s.ShapeType.split('.')[-1], s.String, s.CLSID] for s in [doc.DrawPages.getByIndex(0).getByIndex(i) for i in range(doc.DrawPages.getByIndex(0).Count)]]", + "expect": [ + [ + "OLE2Shape", + "", + "078B7ABA-54FC-457F-8551-6147e776a997" + ], + [ + "OLE2Shape", + "OLE label", + "078B7ABA-54FC-457F-8551-6147e776a997" + ], + [ + "OLE2Shape", + " ", + "078B7ABA-54FC-457F-8551-6147e776a997" + ], + [ + "OLE2Shape", + "\n", + "078B7ABA-54FC-457F-8551-6147e776a997" + ], + [ + "OLE2Shape", + "1/3/1", + "078B7ABA-54FC-457F-8551-6147e776a997" + ] + ] + }, + { + "name": "ole_paragraphs", + "expr": "[[(lambda en: [p.String for p in [en.nextElement() for _ in iter(en.hasMoreElements, False)]])(s.createEnumeration())] for s in [doc.DrawPages.getByIndex(0).getByIndex(i) for i in range(doc.DrawPages.getByIndex(0).Count)]]", + "expect": [ + [ + [ + "" + ] + ], + [ + [ + "OLE label" + ] + ], + [ + [ + " " + ] + ], + [ + [ + "", + "" + ] + ], + [ + [ + "1/3/1" + ] + ] + ] + }, + { + "name": "ole_has_field", + "expr": "[any(pt.TextPortionType == 'TextField' for pt in (lambda en: [en.nextElement() for _ in iter(en.hasMoreElements, False)])(par.createEnumeration())) for s in [doc.DrawPages.getByIndex(0).getByIndex(i) for i in range(doc.DrawPages.getByIndex(0).Count)] for par in (lambda en: [en.nextElement() for _ in iter(en.hasMoreElements, False)])(s.createEnumeration())]", + "expect": [ + false, + false, + false, + false, + false, + true + ] + } +] diff --git a/test/data/checks/ole-text/checks.json b/test/data/checks/ole-text/checks.json new file mode 100644 index 0000000..b14519c --- /dev/null +++ b/test/data/checks/ole-text/checks.json @@ -0,0 +1,18 @@ +[ + { + "name": "ole", + "expr": "[[s.ShapeType, s.String, s.CLSID] for s in [doc.DrawPages.getByIndex(0).getByIndex(i) for i in range(doc.DrawPages.getByIndex(0).Count)]]", + "expect": [ + [ + "com.sun.star.drawing.OLE2Shape", + "", + "078B7ABA-54FC-457F-8551-6147e776a997" + ], + [ + "com.sun.star.drawing.OLE2Shape", + "OLE label", + "078B7ABA-54FC-457F-8551-6147e776a997" + ] + ] + } +] \ No newline at end of file diff --git a/test/data/checks/para-fill-foreign/checks-aoo-form.json b/test/data/checks/para-fill-foreign/checks-aoo-form.json new file mode 100644 index 0000000..c3ad268 --- /dev/null +++ b/test/data/checks/para-fill-foreign/checks-aoo-form.json @@ -0,0 +1,378 @@ +[ + { + "name": "styled_paragraphs", + "expr": "[(p.String,)+(lambda o:(o.FillStyle.value,(o.FillColor if o.FillStyle.value=='SOLID' or (o.FillStyle.value=='HATCH' and o.FillBackground) else None),o.FillTransparence,bool(o.FillGradientName),(lambda g:(g.Style.value,g.StartColor,g.EndColor,g.Angle,g.Border))(o.FillGradient) if o.FillStyle.value=='GRADIENT' else None,bool(o.FillHatchName),(lambda h:(h.Style.value,h.Color,h.Distance,h.Angle))(o.FillHatch) if o.FillStyle.value=='HATCH' else None,o.FillBackground if o.FillStyle. [...] + "expect": [ + [ + "styled solid", + "SOLID", + 3385941, + 0, + false, + null, + false, + null, + null, + false, + null, + false, + 3385941, + false + ], + [ + "styled solid_transp", + "SOLID", + 3364266, + 40, + false, + null, + false, + null, + null, + false, + null, + false, + 1697863082, + false + ], + [ + "styled gradient", + "GRADIENT", + null, + 0, + true, + [ + "LINEAR", + 16711680, + 255, + 300, + 10 + ], + false, + null, + null, + false, + null, + false, + 8388736, + false + ], + [ + "styled gradient_transp", + "GRADIENT", + null, + 30, + true, + [ + "LINEAR", + 16711680, + 255, + 300, + 10 + ], + false, + null, + null, + false, + null, + false, + 1283457152, + false + ], + [ + "styled hatch", + "HATCH", + 16777164, + 0, + false, + null, + true, + [ + "SINGLE", + 16755200, + 200, + 450 + ], + true, + false, + null, + false, + 16777164, + false + ], + [ + "styled hatch_nobg", + "HATCH", + null, + 0, + false, + null, + true, + [ + "SINGLE", + 16755200, + 200, + 450 + ], + false, + false, + null, + false, + 2147461632, + false + ], + [ + "styled bitmap_tile", + "BITMAP", + null, + 0, + false, + null, + false, + null, + null, + true, + "REPEAT", + true, + -1, + true + ], + [ + "styled bitmap_stretch", + "BITMAP", + null, + 0, + false, + null, + false, + null, + null, + true, + "STRETCH", + true, + -1, + true + ], + [ + "styled bitmap_once", + "BITMAP", + null, + 0, + false, + null, + false, + null, + null, + true, + "NO_REPEAT", + true, + -1, + true + ], + [ + "styled bitmap_transp", + "BITMAP", + null, + 50, + false, + null, + false, + null, + null, + true, + "REPEAT", + true, + -1, + true + ] + ] + }, + { + "name": "para_styles", + "expr": "[(n,)+(lambda o:(o.FillStyle.value,(o.FillColor if o.FillStyle.value=='SOLID' or (o.FillStyle.value=='HATCH' and o.FillBackground) else None),o.FillTransparence,bool(o.FillGradientName),(lambda g:(g.Style.value,g.StartColor,g.EndColor,g.Angle,g.Border))(o.FillGradient) if o.FillStyle.value=='GRADIENT' else None,bool(o.FillHatchName),(lambda h:(h.Style.value,h.Color,h.Distance,h.Angle))(o.FillHatch) if o.FillStyle.value=='HATCH' else None,o.FillBackground if o.FillStyle.value== [...] + "expect": [ + [ + "S_bitmap_once", + "BITMAP", + null, + 0, + false, + null, + false, + null, + null, + true, + "NO_REPEAT", + true, + -1, + true + ], + [ + "S_bitmap_stretch", + "BITMAP", + null, + 0, + false, + null, + false, + null, + null, + true, + "STRETCH", + true, + -1, + true + ], + [ + "S_bitmap_tile", + "BITMAP", + null, + 0, + false, + null, + false, + null, + null, + true, + "REPEAT", + true, + -1, + true + ], + [ + "S_bitmap_transp", + "BITMAP", + null, + 50, + false, + null, + false, + null, + null, + true, + "REPEAT", + true, + -1, + true + ], + [ + "S_gradient", + "GRADIENT", + null, + 0, + true, + [ + "LINEAR", + 16711680, + 255, + 300, + 10 + ], + false, + null, + null, + false, + null, + false, + 8388736, + false + ], + [ + "S_gradient_transp", + "GRADIENT", + null, + 30, + true, + [ + "LINEAR", + 16711680, + 255, + 300, + 10 + ], + false, + null, + null, + false, + null, + false, + 1283457152, + false + ], + [ + "S_hatch", + "HATCH", + 16777164, + 0, + false, + null, + true, + [ + "SINGLE", + 16755200, + 200, + 450 + ], + true, + false, + null, + false, + 16777164, + false + ], + [ + "S_hatch_nobg", + "HATCH", + null, + 0, + false, + null, + true, + [ + "SINGLE", + 16755200, + 200, + 450 + ], + false, + false, + null, + false, + 2147461632, + false + ], + [ + "S_solid", + "SOLID", + 3385941, + 0, + false, + null, + false, + null, + null, + false, + null, + false, + 3385941, + false + ], + [ + "S_solid_transp", + "SOLID", + 3364266, + 40, + false, + null, + false, + null, + null, + false, + null, + false, + 1697863082, + false + ] + ] + } +] diff --git a/test/data/checks/para-fill/bitmap.json b/test/data/checks/para-fill/bitmap.json new file mode 100644 index 0000000..d8e7653 --- /dev/null +++ b/test/data/checks/para-fill/bitmap.json @@ -0,0 +1,28 @@ +[ + { + "name": "para_bitmap", + "expr": "[(p.String, ('GraphicObject:0000' not in u and 'GraphicObject:' in u), p.FillStyle.value) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None) if p.String.endswith('bitmap') for u in [p.ParaBackGraphicURL]]", + "expect": [ + [ + "direct bitmap", + false, + "BITMAP" + ], + [ + "styled bitmap", + true, + "BITMAP" + ] + ] + }, + { + "name": "parastyle_bitmap", + "expr": "[(('GraphicObject:0000' not in u and 'GraphicObject:' in u), s.FillStyle.value) for s in [doc.StyleFamilies.getByName('ParagraphStyles').getByName('S_bitmap')] for u in [s.ParaBackGraphicURL]]", + "expect": [ + [ + true, + "BITMAP" + ] + ] + } +] \ No newline at end of file diff --git a/test/data/checks/para-fill/checks.json b/test/data/checks/para-fill/checks.json new file mode 100644 index 0000000..3e81cba --- /dev/null +++ b/test/data/checks/para-fill/checks.json @@ -0,0 +1,224 @@ +[ + { + "name": "paragraphs", + "expr": "[(p.String, p.ParaBackColor, p.ParaBackTransparent, p.FillStyle.value, p.FillColor, p.FillTransparence) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None)]", + "expect": [ + [ + "direct solid", + -3151883, + true, + "NONE", + 13625333, + 0 + ], + [ + "styled solid", + 16763904, + false, + "SOLID", + 16763904, + 0 + ], + [ + "direct solid_fill", + 3385941, + false, + "SOLID", + 3385941, + 0 + ], + [ + "styled solid_fill", + 3385941, + false, + "SOLID", + 3385941, + 0 + ], + [ + "direct solid_transp", + 1697863082, + false, + "SOLID", + 3364266, + 40 + ], + [ + "styled solid_transp", + 1697863082, + false, + "SOLID", + 3364266, + 40 + ], + [ + "direct gradient", + 8421504, + false, + "GRADIENT", + 13625333, + 0 + ], + [ + "styled gradient", + 8388736, + false, + "GRADIENT", + 13625333, + 0 + ], + [ + "direct hatch", + 16777164, + false, + "HATCH", + 16777164, + 0 + ], + [ + "styled hatch", + 16777164, + false, + "HATCH", + 16777164, + 0 + ], + [ + "direct bitmap", + -1, + true, + "BITMAP", + 13625333, + 0 + ], + [ + "styled bitmap", + -1, + true, + "BITMAP", + 13625333, + 0 + ], + [ + "", + -3151883, + true, + "NONE", + 13625333, + 0 + ] + ] + }, + { + "name": "para_styles", + "expr": "[(n, p.ParaBackColor, p.ParaBackTransparent, p.FillStyle.value, p.FillColor, p.FillTransparence) for n in doc.StyleFamilies.getByName('ParagraphStyles').ElementNames if n.startswith('S_') for p in [doc.StyleFamilies.getByName('ParagraphStyles').getByName(n)]]", + "expect": [ + [ + "S_solid", + 16763904, + false, + "SOLID", + 16763904, + 0 + ], + [ + "S_solid_fill", + 3385941, + false, + "SOLID", + 3385941, + 0 + ], + [ + "S_solid_transp", + 1697863082, + false, + "SOLID", + 3364266, + 40 + ], + [ + "S_gradient", + 8388736, + false, + "GRADIENT", + 13625333, + 0 + ], + [ + "S_hatch", + 16777164, + false, + "HATCH", + 16777164, + 0 + ], + [ + "S_bitmap", + -1, + true, + "BITMAP", + 13625333, + 0 + ] + ] + }, + { + "name": "styled_para_style_names", + "expr": "[(p.String, p.ParaStyleName) for e in [doc.Text.createEnumeration()] for p in iter(lambda: e.nextElement() if e.hasMoreElements() else None, None)]", + "expect": [ + [ + "direct solid", + "Standard" + ], + [ + "styled solid", + "S_solid" + ], + [ + "direct solid_fill", + "Standard" + ], + [ + "styled solid_fill", + "S_solid_fill" + ], + [ + "direct solid_transp", + "Standard" + ], + [ + "styled solid_transp", + "S_solid_transp" + ], + [ + "direct gradient", + "Standard" + ], + [ + "styled gradient", + "S_gradient" + ], + [ + "direct hatch", + "Standard" + ], + [ + "styled hatch", + "S_hatch" + ], + [ + "direct bitmap", + "Standard" + ], + [ + "styled bitmap", + "S_bitmap" + ], + [ + "", + "Standard" + ] + ] + } +] \ No newline at end of file diff --git a/test/data/checks/row-split/checks.json b/test/data/checks/row-split/checks.json new file mode 100644 index 0000000..d907ae0 --- /dev/null +++ b/test/data/checks/row-split/checks.json @@ -0,0 +1,11 @@ +[ + { + "name": "row_split", + "expr": "[doc.TextTables.getByIndex(0).Rows.getByIndex(i).IsSplitAllowed for i in range(doc.TextTables.getByIndex(0).Rows.Count)]", + "expect": [ + true, + false, + true + ] + } +] \ No newline at end of file diff --git a/test/data/expect/crash.tsv b/test/data/expect/crash.tsv new file mode 100644 index 0000000..fbaca99 --- /dev/null +++ b/test/data/expect/crash.tsv @@ -0,0 +1,2 @@ +# test_name<TAB>kind<TAB>reason. See aootest/expect.py. +test_paragraph_bitmap_fill_mode_does_not_kill_the_office xfail setting FillBitmapMode on a Writer paragraph kills the trunk dev app (SIGSEGV in SwXParagraph::setPropertyValue); the installed 5.1.0 does not crash diff --git a/test/data/expect/odf14.tsv b/test/data/expect/odf14.tsv index 7f1a0e6..134063d 100644 --- a/test/data/expect/odf14.tsv +++ b/test/data/expect/odf14.tsv @@ -1,2 +1,4 @@ # test_name<TAB>kind<TAB>reason. See aootest/expect.py. test_valid_against_odf_schema[built/t13/chart.ods-strict-14] xfail the ODF 1.4 schema rejects table:cell-range-address in the chart content (C1/content.xml); the ODF 1.2 and 1.3 schemas accept it +test_valid_against_odf_schema[built/chart-shapes/chart-shapes.ods-strict-14] xfail the ODF 1.4 schema rejects table:cell-range-address in the chart content (c1/content.xml); the ODF 1.2 and 1.3 schemas accept it +test_valid_against_odf_schema[built/normal-values5b/normal5b.ods-strict-14] xfail the saved chart content has style:chart-properties for a graphic symbol but no chart:symbol-image element, which the schema requires; the symbol-image reload check for the same document also fails and the original fixture file passes it; not analysed diff --git a/test/data/expect/reload.tsv b/test/data/expect/reload.tsv index 307987f..ff89cd2 100644 --- a/test/data/expect/reload.tsv +++ b/test/data/expect/reload.tsv @@ -33,3 +33,52 @@ test_reload_check[v13|built/page-fill-1_3/aoo-src.odt|page_transparence_gradient test_reload_check[v13|built/page-fill-1_3/aoo-src.odt|page_hatch] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check test_reload_check[v13|built/page-fill-1_3/aoo-src.odt|page_bitmap] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check test_reload_check[v13|built/page-fill-1_3/aoo-src.odt|header_fill] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/ole-text/ole-text.odg|ole] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/ole-text-edge/ole-text-edge.odg|ole_text] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[strict|built/ole-text-edge/ole-text-edge.odg|ole_paragraphs] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[strict|built/ole-text-edge/ole-text-edge.odg|ole_has_field] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[strict|built/chart-shapes/chart-shapes.ods|chart_shapes] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/normal-values5b/normal5b.ods|symbol_image] xfail a fixture built now reads back no symbol graphic where the check expects one; the original fixture file passes in the extended mode; not analysed +test_reload_check[strict|built/para-fill/para-fill.odt|paragraphs] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/para-fill/para-fill.odt|para_styles] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/para-fill/para-fill.odt|para_bitmap] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/alien-attrs/alien-writer.odt|writer_aliens] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[strict|built/alien-attrs/alien-writer.odt|writer_aliens_cell] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[strict|built/alien-attrs/alien-writer.odt|writer_aliens_foreign] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/alien-attrs/alien-draw.odg|draw_aliens] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/alien-attrs/alien-draw.odg|draw_aliens_foreign] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/alien-attrs/alien-calc.ods|calc_aliens] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[strict|built/alien-attrs/alien-calc.ods|calc_aliens_foreign] xfail the value read back from the strict copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[ext|built/ole-text-edge/ole-text-edge.odg|ole_text] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[ext|built/ole-text-edge/ole-text-edge.odg|ole_paragraphs] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[ext|built/ole-text-edge/ole-text-edge.odg|ole_has_field] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[ext|built/normal-values5b/normal5b.ods|symbol_image] xfail a fixture built now reads back no symbol graphic where the check expects one; the original fixture file passes in the extended mode; not analysed +test_reload_check[ext|built/alien-attrs/alien-writer.odt|writer_aliens] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[ext|built/alien-attrs/alien-writer.odt|writer_aliens_cell] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[v13|built/ole-text/ole-text.odg|ole] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/ole-text-edge/ole-text-edge.odg|ole_text] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[v13|built/ole-text-edge/ole-text-edge.odg|ole_paragraphs] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[v13|built/ole-text-edge/ole-text-edge.odg|ole_has_field] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[v13|built/normal-values5b/normal5b.ods|symbol_image] xfail a fixture built now reads back no symbol graphic where the check expects one; the original fixture file passes in the extended mode; not analysed +test_reload_check[v13|built/para-fill/para-fill.odt|paragraphs] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/para-fill/para-fill.odt|para_styles] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/para-fill/para-fill.odt|para_bitmap] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/alien-attrs/alien-writer.odt|writer_aliens] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[v13|built/alien-attrs/alien-writer.odt|writer_aliens_cell] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[v13|built/alien-attrs/alien-writer.odt|writer_aliens_foreign] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/alien-attrs/alien-draw.odg|draw_aliens] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/alien-attrs/alien-draw.odg|draw_aliens_foreign] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/alien-attrs/alien-calc.ods|calc_aliens] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[v13|built/alien-attrs/alien-calc.ods|calc_aliens_foreign] xfail the value read back from the v13 copy differs from the one recorded from the extended-mode copy; recorded on the trunk dev app, not analysed per check +test_reload_check[x13|built/ole-text-edge/ole-text-edge.odg|ole_text] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[x13|built/ole-text-edge/ole-text-edge.odg|ole_paragraphs] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[x13|built/ole-text-edge/ole-text-edge.odg|ole_has_field] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[x13|built/normal-values5b/normal5b.ods|symbol_image] xfail a fixture built now reads back no symbol graphic where the check expects one; the original fixture file passes in the extended mode; not analysed +test_reload_check[x13|built/alien-attrs/alien-writer.odt|writer_aliens] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[x13|built/alien-attrs/alien-writer.odt|writer_aliens_cell] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[default|built/ole-text-edge/ole-text-edge.odg|ole_text] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[default|built/ole-text-edge/ole-text-edge.odg|ole_paragraphs] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[default|built/ole-text-edge/ole-text-edge.odg|ole_has_field] xfail a fixture built now reads back no date-field shape where the check expects one; the original fixture file, made on an earlier build, passes in the extended mode; not analysed +test_reload_check[default|built/normal-values5b/normal5b.ods|symbol_image] xfail a fixture built now reads back no symbol graphic where the check expects one; the original fixture file passes in the extended mode; not analysed +test_reload_check[default|built/alien-attrs/alien-writer.odt|writer_aliens] xfail fails in the extended mode with the original fixture file as well; not analysed +test_reload_check[default|built/alien-attrs/alien-writer.odt|writer_aliens_cell] xfail fails in the extended mode with the original fixture file as well; not analysed diff --git a/test/data/expect/schema.tsv b/test/data/expect/schema.tsv new file mode 100644 index 0000000..c8bcabc --- /dev/null +++ b/test/data/expect/schema.tsv @@ -0,0 +1,4 @@ +# test_name<TAB>kind<TAB>reason. See aootest/expect.py. +test_valid_against_odf_schema[built/normal-values5b/normal5b.ods-strict-12] xfail the saved chart content has style:chart-properties for a graphic symbol but no chart:symbol-image element, which the schema requires; the symbol-image reload check for the same document also fails and the original fixture file passes it; not analysed +test_valid_against_odf_schema[built/normal-values5b/normal5b.ods-strict-13] xfail the saved chart content has style:chart-properties for a graphic symbol but no chart:symbol-image element, which the schema requires; the symbol-image reload check for the same document also fails and the original fixture file passes it; not analysed +test_valid_against_odf_schema[built/normal-values5b/normal5b.ods-v13-13] xfail the saved chart content has style:chart-properties for a graphic symbol but no chart:symbol-image element, which the schema requires; the symbol-image reload check for the same document also fails and the original fixture file passes it; not analysed diff --git a/test/pyproject.toml b/test/pyproject.toml index c6fe097..bd280d8 100644 --- a/test/pyproject.toml +++ b/test/pyproject.toml @@ -20,7 +20,7 @@ minversion = "8.0" testpaths = ["tests"] python_files = ["test_*.py"] pythonpath = ["src"] -addopts = "--import-mode=importlib -m 'not corpus and not render and not gui'" +addopts = "--import-mode=importlib -m 'not corpus and not render and not gui and not crash'" markers = [ "selftest: negative controls proving the checkers can fail", "smoke: quick checks against an installed office", @@ -29,4 +29,5 @@ markers = [ "render: PDF rasterize and compare", "gui: needs a display or a desktop session", "needs_java: needs a Java runtime", + "crash: triggers a known crash of the office under test; run on request with -m crash", ] diff --git a/test/src/aootest/documents.py b/test/src/aootest/documents.py index a865447..dae9962 100644 --- a/test/src/aootest/documents.py +++ b/test/src/aootest/documents.py @@ -26,6 +26,7 @@ from collections import namedtuple from pathlib import Path from aootest import install +from aootest.client import WorkerFailure from aootest.paths import DATA # Source: id is the stable name used in test ids; path is None for a document the office creates (`app` names a new empty one, @@ -34,7 +35,8 @@ from aootest.paths import DATA Source = namedtuple("Source", "id path kind app builder checks", defaults=(None, None, ())) SHIPPED_KIND = {"odt": "odt", "ott": "odt", "ods": "ods", "ots": "ods", "odp": "odp", "otp": "odp", "odg": "odg", "otg": "odg"} GENERATED = (("writer", "odt"), ("calc", "ods"), ("impress", "odp"), ("draw", "odg")) -# builder, file it makes, kind, checks +# builder, file it makes, kind, checks. The para-fill-foreign builder is not here: it crashes the trunk dev app +# (tests/odf/test_known_crashes.py), and a crash slows the office starts that follow. BUILT = (("page-fill", "page-fill.odt", "odt", ("page-fill/checks.json", "page-fill/bitmap.json")), ("fill-others", "others-writer.odt", "odt", ("fill-others/writer.json",)), ("fill-others", "others-calc.ods", "ods", ("fill-others/calc.json",)), @@ -47,7 +49,19 @@ BUILT = (("page-fill", "page-fill.odt", "odt", ("page-fill/checks.json", "page-f ("t13", "chart.ods", "ods", ("t13/checks-chart.json",)), ("page-fill-1_3", "aoo-src.odt", "odt", ("page-fill-1_3/checks.json",)), ("page-fill-1_3", "calc-src.ods", "ods", ("page-fill-1_3/checks-calc.json",)), - ("page-fill-1_3", "calc-drawing-page.ods", "ods", ("page-fill-1_3/checks-calc.json",))) + ("page-fill-1_3", "calc-drawing-page.ods", "ods", ("page-fill-1_3/checks-calc.json",)), + ("row-split", "row-split.odt", "odt", ("row-split/checks.json",)), + ("grid-snap", "grid-snap.odt", "odt", ("grid-snap/checks.json",)), + ("ole-text", "ole-text.odg", "odg", ("ole-text/checks.json",)), + ("ole-text-edge", "ole-text-edge.odg", "odg", ("ole-text-edge/checks.json",)), + ("chart-shapes", "chart-shapes.ods", "ods", ("chart-shapes/checks.json",)), + ("normal-values5b", "normal5b.ods", "ods", ("normal-values5b/checks-image.json",)), + ("connector-viewbox", "conn.odg", "odg", ("connector-viewbox/checks.json",)), + ("connector-viewbox", "conn.odp", "odp", ("connector-viewbox/checks.json",)), + ("para-fill", "para-fill.odt", "odt", ("para-fill/checks.json", "para-fill/bitmap.json")), + ("alien-attrs", "alien-writer.odt", "odt", ("alien-attrs/writer.json", "alien-attrs/writer-cell.json", "alien-attrs/writer-foreign.json")), + ("alien-attrs", "alien-draw.odg", "odg", ("alien-attrs/draw.json",)), + ("alien-attrs", "alien-calc.ods", "ods", ("alien-attrs/calc.json",))) DEFAULT_LIMIT = 40 SHIPPED_DIRS = ("template", "samples") @@ -145,25 +159,41 @@ class Prepared: in `directory`.""" def __init__(self, session, directory): - self.session, self.dir, self._made, self._built = session, Path(directory), {}, set() + self.session, self.dir, self._made, self._built, self._failed = session, Path(directory), {}, set(), {} def file(self, source): + """The file of `source`. A source that could not be made raises the same error every time, without trying again.""" if source.path is not None: return str(source.path) + if source.id in self._failed: + raise self._failed[source.id] if source.id not in self._made: - if source.builder: - name, filename = source.builder - if name not in self._built: - self.session.call("generate", {"builder": name, "outdir": str(self.dir / name)}, timeout=300) - self._built.add(name) - self._made[source.id] = str(self.dir / name / filename) - else: - path = self.dir / ("%s.%s" % (source.app, source.kind)) - self.dir.mkdir(parents=True, exist_ok=True) - self.session.call("new_and_store", {"app": source.app, "dst": str(path), "filter": FILTERS[source.kind], - "text": "Hello %s" % source.app}, timeout=180) - self._made[source.id] = str(path) + try: + self._make(source) + except WorkerFailure as e: + self._failed[source.id] = e + raise return self._made[source.id] + def _make(self, source): + if source.builder: + name, filename = source.builder + if name in self._failed: + raise self._failed[name] + if name not in self._built: + try: + self.session.call("generate", {"builder": name, "outdir": str(self.dir / name)}, timeout=300) + except WorkerFailure as e: + self._failed[name] = e + raise + self._built.add(name) + self._made[source.id] = str(self.dir / name / filename) + else: + path = self.dir / ("%s.%s" % (source.app, source.kind)) + self.dir.mkdir(parents=True, exist_ok=True) + self.session.call("new_and_store", {"app": source.app, "dst": str(path), "filter": FILTERS[source.kind], + "text": "Hello %s" % source.app}, timeout=180) + self._made[source.id] = str(path) + FILTERS = {"odt": "writer8", "ods": "calc8", "odp": "impress8", "odg": "draw8"} diff --git a/test/src/aootest_worker/ops/generate.py b/test/src/aootest_worker/ops/generate.py index 4c1cf8a..a50f9b3 100644 --- a/test/src/aootest_worker/ops/generate.py +++ b/test/src/aootest_worker/ops/generate.py @@ -393,7 +393,399 @@ def page_fill_13(outdir): return done -BUILDERS = {"page-fill": page_fill, "fill-others": fill_others, "t13": t13, "page-fill-1_3": page_fill_13} +def row_split(outdir): + doc = _new("swriter") + tbl = doc.createInstance("com.sun.star.text.TextTable") + tbl.initialize(3, 2) + doc.Text.insertTextContent(doc.Text.End, tbl, False) + rows = tbl.Rows + rows.getByIndex(0).IsSplitAllowed = True + rows.getByIndex(1).IsSplitAllowed = False + rows.getByIndex(2).IsSplitAllowed = True + rows.getByIndex(2).Height = 1000 + return [_save(doc, outdir, "row-split.odt", "writer8")] + + +def grid_snap(outdir): + doc = _new("swriter") + ps = doc.StyleFamilies.getByName("PageStyles") + specs = [("G_snap_on", True, 2), ("G_snap_off", False, 2), ("G_lines_off", False, 1)] + for name, snap, mode in specs: + s = doc.createInstance("com.sun.star.style.PageStyle") + ps.insertByName(name, s) + s.GridMode = mode + s.StandardPageMode = True + s.GridSnapToChars = snap + text = doc.Text + cur = text.createTextCursor() + pb = uno.getConstantByName("com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK") + for name, *_ in specs: + text.insertString(cur, "grid " + name, False) + text.insertControlCharacter(cur, pb, False) + en = text.createEnumeration() + for name, *_ in specs: + en.nextElement().PageDescName = name + out = os.path.join(outdir, "grid-snap.odt") + _save(doc, outdir, "grid-snap.odt", "writer8") + # older builds did not write standard-mode next to base-width and the importer does not infer it, so add it where it is missing + tmp = out + ".tmp" + tag = re.compile(rb"<[^<>]*style:layout-grid-base-width=[^<>]*>") + with zipfile.ZipFile(out) as zi, zipfile.ZipFile(tmp, "w") as zo: + for it in zi.infolist(): + data = zi.read(it.filename) + if it.filename == "styles.xml": + data = tag.sub(lambda m: m.group(0) if b"style:layout-grid-standard-mode=" in m.group(0) + else m.group(0).replace(b"style:layout-grid-base-width=", b'style:layout-grid-standard-mode="true" style:layout-grid-base-width=', 1), data) + zo.writestr(it, data, compress_type=it.compress_type) + os.replace(tmp, out) + return ["grid-snap.odt"] + + +def ole_text(outdir): + """A Draw page with an OLE object without text and one with text.""" + doc = _new("sdraw") + page = doc.DrawPages.getByIndex(0) + for i, text in enumerate(("", "OLE label")): + s = doc.createInstance("com.sun.star.drawing.OLE2Shape") + s.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997" + page.add(s) + s.Position = Point(2000 + i * 8000, 2000) + s.Size = Size(5000, 3000) + if text: + s.String = text + return [_save(doc, outdir, "ole-text.odg", "draw8")] + + +def ole_text_edge(outdir): + """OLE shapes whose text is: none, a label, one space, a line break only, a date field only.""" + doc = _new("sdraw") + page = doc.DrawPages.getByIndex(0) + for i, text in enumerate(("", "OLE label", " ", "\n", None)): + s = doc.createInstance("com.sun.star.drawing.OLE2Shape") + s.CLSID = "078B7ABA-54FC-457F-8551-6147e776a997" + page.add(s) + s.Position = Point(1000 + i * 5000, 2000) + s.Size = Size(4000, 3000) + if text is None: + f = doc.createInstance("com.sun.star.text.TextField.DateTime") + f.IsFixed = True + f.IsDate = True + s.insertTextContent(s.createTextCursor(), f, False) + elif text: + s.String = text + return [_save(doc, outdir, "ole-text-edge.odg", "draw8")] + + +def chart_shapes(outdir): + """A Calc chart with additional shapes (polyline, rectangle, text) in the chart draw page.""" + from com.sun.star.awt import Rectangle + from com.sun.star.table import CellRangeAddress + doc = _new("scalc") + sh = doc.Sheets.getByIndex(0) + for r, (a, b) in enumerate(((1, 2), (2, 4), (3, 3))): + sh.getCellByPosition(0, r).Value = a + sh.getCellByPosition(1, r).Value = b + rng = CellRangeAddress() + rng.Sheet, rng.StartColumn, rng.StartRow, rng.EndColumn, rng.EndRow = 0, 0, 0, 1, 2 + r = Rectangle() + r.X, r.Y, r.Width, r.Height = 1000, 4000, 10000, 7000 + sh.Charts.addNewByName("c1", r, (rng,), False, False) + ch = sh.Charts.getByName("c1").EmbeddedObject + page = ch.DrawPage + + def mk(kind, x, y, w, h): + s = ch.createInstance(kind) + page.add(s) + s.Position = Point(x, y) + s.Size = Size(w, h) + return s + pl = mk("com.sun.star.drawing.PolyLineShape", 500, 500, 3000, 1500) + pl.PolyPolygon = ((Point(0, 1500), Point(1000, 500), Point(3000, 0)),) + mk("com.sun.star.drawing.RectangleShape", 4000, 500, 2000, 1000).String = "rect" + mk("com.sun.star.drawing.TextShape", 6500, 500, 2000, 800).String = "note" + return [_save(doc, outdir, "chart-shapes.ods", "calc8")] + + +def normal_values_5b(outdir): + """Two charts, one with a graphic as the series symbol, and a hidden column.""" + from com.sun.star.awt import Rectangle + png = os.path.join(outdir, "symbol.png") + _png(png) + doc = _new("scalc") + sh = doc.Sheets.getByIndex(0) + for r, row in enumerate([["", "a", "b"], ["x", 1, 2], ["y", 3, 5], ["z", 4, 8]]): + for c, v in enumerate(row): + cell = sh.getCellByPosition(c, r) + if isinstance(v, str): + cell.String = v + else: + cell.Value = v + rng = sh.getCellRangeByName("A1:C4").getRangeAddress() + r = Rectangle() + r.X, r.Y, r.Width, r.Height = 8000, 1000, 9000, 7000 + sh.Charts.addNewByName("c1", r, (rng,), True, True) + m = sh.Charts.getByName("c1").EmbeddedObject + gp = core._create("com.sun.star.graphic.GraphicProvider") + g = gp.queryGraphic((pv("URL", uno.systemPathToFileUrl(png)),)) + s = m.getFirstDiagram().getCoordinateSystems()[0].getChartTypes()[0].getDataSeries()[0] + sym = s.Symbol + sym.Style = uno.Enum("com.sun.star.chart2.SymbolStyle", "GRAPHIC") + sym.Graphic = g + s.Symbol = sym + sh.getColumns().getByIndex(2).IsVisible = False + r2 = Rectangle() + r2.X, r2.Y, r2.Width, r2.Height = 8000, 9000, 9000, 7000 + sh.Charts.addNewByName("c2", r2, (sh.getCellRangeByName("A1:C4").getRangeAddress(),), True, True) + return [_save(doc, outdir, "normal5b.ods", "calc8")] + + +def connector_viewbox(outdir): + """Connectors of every kind, connected and free, axis-aligned and diagonal, in Draw and Impress.""" + from com.sun.star.drawing.ConnectorType import CURVE, LINE, LINES, STANDARD + + def build(doc, page): + def rect(x, y, w, h): + s = doc.createInstance("com.sun.star.drawing.RectangleShape") + page.add(s) + s.Position = Point(x, y) + s.Size = Size(w, h) + return s + + def conn(kind, a, b, name): + c = doc.createInstance("com.sun.star.drawing.ConnectorShape") + page.add(c) + c.EdgeKind = kind + c.StartPosition = Point(*a) + c.EndPosition = Point(*b) + c.Name = name + return c + r1, r2 = rect(1000, 12000, 3000, 2000), rect(12000, 16000, 3000, 2000) + r3, r4 = rect(1000, 20000, 3000, 2000), rect(9000, 24000, 3000, 2000) + conn(STANDARD, (2000, 2000), (8000, 6000), "std_free") + conn(CURVE, (10000, 2000), (16000, 6000), "curve_free") + conn(LINE, (2000, 8000), (8000, 8000), "line_h") + conn(LINE, (10000, 8000), (10000, 11000), "line_v") + conn(LINE, (18000, 9000), (14000, 5000), "line_rev") + conn(STANDARD, (2000, 28000), (8000, 28000), "std_h") + conn(STANDARD, (16000, 28000), (16000, 32000), "std_v") + c = conn(STANDARD, (0, 0), (0, 0), "std_conn") + c.StartShape, c.EndShape = r1, r2 + c = conn(CURVE, (0, 0), (0, 0), "curve_conn") + c.StartShape, c.EndShape = r3, r4 + conn(LINES, (2000, 34000), (9000, 38000), "lines_free") + + done = [] + for kind, name, flt in (("sdraw", "conn.odg", "draw8"), ("simpress", "conn.odp", "impress8")): + doc = _new(kind) + build(doc, doc.DrawPages.getByIndex(0)) + done.append(_save(doc, outdir, name, flt)) + return done + + +def para_fill(outdir): + """Paragraphs and paragraph styles with each kind of fill, direct and through a style (fixtures/para-fill/make.py).""" + png = os.path.join(outdir, "tile.png") + _png(png) + png_url = uno.systemPathToFileUrl(png) + doc = _new("swriter") + text = doc.Text + + def hatch(): + h = Hatch() + h.Style, h.Color, h.Distance, h.Angle = SINGLE, 0x00AA00, 200, 450 + return h + + def fill(o, kind): + if kind == "solid": + o.ParaBackColor = 0xFFCC00 + o.ParaBackTransparent = False + elif kind == "solid_fill": + o.FillStyle = SOLID + o.FillColor = 0x33AA55 + elif kind == "solid_transp": + o.FillStyle = SOLID + o.FillColor = 0x3355AA + o.FillTransparence = 40 + elif kind == "gradient": + o.FillStyle = GRADIENT + o.FillGradient = _grad() + elif kind == "hatch": + o.FillStyle = HATCH + o.FillHatch = hatch() + o.FillColor = 0xFFFFCC + o.FillBackground = True + elif kind == "bitmap": + o.FillStyle = BITMAP + o.FillBitmapURL = png_url + + kinds = ["solid", "solid_fill", "solid_transp", "gradient", "hatch", "bitmap"] + styles = doc.StyleFamilies.getByName("ParagraphStyles") + for k in kinds: + s = doc.createInstance("com.sun.star.style.ParagraphStyle") + s.ParentStyle = "Standard" + styles.insertByName("S_" + k, s) + fill(s, k) + pb = uno.getConstantByName("com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK") + cur = text.createTextCursor() + labels = [] + for k in kinds: + for kind in ("direct", "styled"): + text.insertString(cur, kind + " " + k, False) + text.insertControlCharacter(cur, pb, False) + labels.append((kind, k)) + paras = doc.Text.createEnumeration() + for kind, k in labels: + p = paras.nextElement() + if kind == "direct": + fill(p, k) + else: + p.ParaStyleName = "S_" + k + return [_save(doc, outdir, "para-fill.odt", "writer8")] + + +def alien_attrs(outdir): + """Preserved alien attributes in ODF namespaces and in a foreign namespace on the carriers that keep them: Writer paragraph, + character, section, table and table cell, a Draw shape, a Calc cell.""" + ns = {"text": "urn:oasis:names:tc:opendocument:xmlns:text:1.0", "style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0", + "draw": "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0", "table": "urn:oasis:names:tc:opendocument:xmlns:table:1.0", + "office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "svg": "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0", + "fo": "http://www.w3.org/1999/XSL/Format", "ex": "urn:example:foreign"} + attrs = (("text", "enable-numbering"), ("style", "alien-style"), ("draw", "alien-draw"), ("table", "alien-table"), + ("office", "alien-office"), ("svg", "alien-svg"), ("fo", "alien-fo"), ("ex", "alien-foreign")) + + def put(container): + for p, n in attrs: + a = uno.createUnoStruct("com.sun.star.xml.AttributeData") + a.Namespace, a.Type, a.Value = ns[p], "CDATA", "v-" + p + container.insertByName(p + ":" + n, a) + + done = [] + doc = _new("swriter") + text = doc.Text + cur = text.createTextCursor() + text.insertString(cur, "para text", False) + text.insertControlCharacter(cur, 0, False) + cur.gotoStart(False) + cur.goRight(4, True) + cont = cur.ParaUserDefinedAttributes + put(cont) + cur.ParaUserDefinedAttributes = cont + cont = cur.TextUserDefinedAttributes + put(cont) + cur.TextUserDefinedAttributes = cont + cur.gotoEnd(False) + tbl = doc.createInstance("com.sun.star.text.TextTable") + tbl.initialize(2, 2) + text.insertTextContent(cur, tbl, False) + for tgt in (tbl, tbl.getCellByName("A1")): + cont = tgt.UserDefinedAttributes + put(cont) + tgt.UserDefinedAttributes = cont + sec = doc.createInstance("com.sun.star.text.TextSection") + text.insertTextContent(text.End, sec, False) + cont = sec.UserDefinedAttributes + put(cont) + sec.UserDefinedAttributes = cont + done.append(_save(doc, outdir, "alien-writer.odt", "writer8")) + + doc = _new("sdraw") + page = doc.DrawPages.getByIndex(0) + s = doc.createInstance("com.sun.star.drawing.RectangleShape") + page.add(s) + s.Position = Point(2000, 2000) + s.Size = Size(4000, 2000) + s.String = "alien" + cont = s.UserDefinedAttributes + put(cont) + s.UserDefinedAttributes = cont + done.append(_save(doc, outdir, "alien-draw.odg", "draw8")) + + doc = _new("scalc") + c = doc.Sheets.getByIndex(0).getCellByPosition(0, 0) + c.Value = 1 + cont = c.UserDefinedAttributes + put(cont) + c.UserDefinedAttributes = cont + done.append(_save(doc, outdir, "alien-calc.ods", "calc8")) + return done + + +def para_fill_foreign(outdir): + """The paragraphs and paragraph styles another producer writes with fill properties, built with AOO's own (aoo-form.odt).""" + png = os.path.join(outdir, "tile.png") + _png(png) + png_url = uno.systemPathToFileUrl(png) + doc = _new("swriter") + + def grad(c1, c2): + g = Gradient() + g.Style, g.StartColor, g.EndColor = LINEAR, c1, c2 + g.Angle, g.Border, g.XOffset, g.YOffset = 300, 10, 50, 50 + g.StartIntensity = g.EndIntensity = 100 + g.StepCount = 0 + return g + + def hatch(): + h = Hatch() + h.Style, h.Color, h.Distance, h.Angle = SINGLE, 0xFFAA00, 200, 450 + return h + + def fill(o, kind): + if kind == "solid": + o.FillStyle = SOLID + o.FillColor = 0x33AA55 + elif kind == "solid_transp": + o.FillStyle = SOLID + o.FillColor = 0x3355AA + o.FillTransparence = 40 + elif kind == "gradient": + o.FillStyle = GRADIENT + o.FillGradient = grad(0xFF0000, 0x0000FF) + elif kind == "gradient_transp": + o.FillStyle = GRADIENT + o.FillGradient = grad(0xFF0000, 0x0000FF) + o.FillTransparence = 30 + elif kind == "hatch": + o.FillStyle = HATCH + o.FillHatch = hatch() + o.FillColor = 0xFFFFCC + o.FillBackground = True + elif kind == "hatch_nobg": + o.FillStyle = HATCH + o.FillHatch = hatch() + o.FillBackground = False + elif kind.startswith("bitmap"): + o.FillStyle = BITMAP + o.FillBitmapURL = png_url + o.FillBitmapMode = {"bitmap_stretch": STRETCH, "bitmap_once": NO_REPEAT}.get(kind, REPEAT) + if kind == "bitmap_transp": + o.FillTransparence = 50 + + kinds = ["solid", "solid_transp", "gradient", "gradient_transp", "hatch", "hatch_nobg", "bitmap_tile", "bitmap_stretch", "bitmap_once", + "bitmap_transp"] + styles = doc.StyleFamilies.getByName("ParagraphStyles") + for k in kinds: + s = doc.createInstance("com.sun.star.style.ParagraphStyle") + s.ParentStyle = "Standard" + styles.insertByName("S_" + k, s) + fill(s, k) + pb = uno.getConstantByName("com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK") + cur = doc.Text.createTextCursor() + for k in kinds: + for kind in ("direct", "styled"): + doc.Text.insertString(cur, kind + " " + k, False) + doc.Text.insertControlCharacter(cur, pb, False) + paras = doc.Text.createEnumeration() + for k in kinds: + fill(paras.nextElement(), k) + paras.nextElement().ParaStyleName = "S_" + k + return [_save(doc, outdir, "aoo-form.odt", "writer8")] + + +BUILDERS = {"page-fill": page_fill, "fill-others": fill_others, "t13": t13, "page-fill-1_3": page_fill_13, "row-split": row_split, + "grid-snap": grid_snap, "ole-text": ole_text, "ole-text-edge": ole_text_edge, "chart-shapes": chart_shapes, + "normal-values5b": normal_values_5b, "connector-viewbox": connector_viewbox, "para-fill": para_fill, + "alien-attrs": alien_attrs, "para-fill-foreign": para_fill_foreign} def generate(builder, outdir): diff --git a/test/tests/odf/test_known_crashes.py b/test/tests/odf/test_known_crashes.py new file mode 100644 index 0000000..43e9b09 --- /dev/null +++ b/test/tests/odf/test_known_crashes.py @@ -0,0 +1,32 @@ +################################################################ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +"""Known crashes of the office under test, kept out of the default run: a crash makes macOS write a report and slows every +office start that follows, so these run on request (python3 -m pytest -m crash). A row in data/expect/crash.tsv records each +one; with --strict-expect the item fails when the crash is gone, which is the cue to delete the row.""" +import pytest + +pytestmark = [pytest.mark.slow, pytest.mark.crash] + + +def test_paragraph_bitmap_fill_mode_does_not_kill_the_office(aoo_offices, tmp_path): + """Building para-fill-foreign sets FillBitmapMode on Writer paragraphs; the worker's generate op must come back.""" + session = aoo_offices.get(3) + res = session.call("generate", {"builder": "para-fill-foreign", "outdir": str(tmp_path)}, timeout=300) + assert res["files"] == ["aoo-form.odt"]
