Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / qa / unit / a11y / layout.cxx
blob342590b31fba356592a02eed93a67213a8a70a7f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <com/sun/star/drawing/XDrawView.hpp>
11 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
12 #include <com/sun/star/frame/XModel.hpp>
14 #include <vcl/scheduler.hxx>
16 #include <test/a11y/accessibletestbase.hxx>
17 #include <test/a11y/swaccessibletestbase.hxx>
19 using namespace css;
21 CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, TestImpressDefaultStructure)
23 load(u"private:factory/simpress");
24 Scheduler::ProcessEventsToIdle();
26 CPPUNIT_ASSERT_EQUAL(rtl::OUString("<SHAPE name=\"PageShape: Slide 1\" description=\" \"/>"
27 "<SHAPE name=\"PresentationTitle \" description=\" \">"
28 "<PARAGRAPH description=\"Paragraph: 0 Click to add Title\">"
29 "Click to add Title"
30 "</PARAGRAPH>"
31 "</SHAPE>"
32 "<SHAPE name=\"PresentationSubtitle \" description=\" \">"
33 "<PARAGRAPH description=\"Paragraph: 0 Click to add Text\">"
34 "Click to add Text"
35 "</PARAGRAPH>"
36 "</SHAPE>"),
37 collectText());
40 // a basic check of the content order for https://bugs.documentfoundation.org/show_bug.cgi?id=150064
41 CPPUNIT_TEST_FIXTURE(test::AccessibleTestBase, TestImpressDefaultLayout)
43 load(u"private:factory/simpress");
44 Scheduler::ProcessEventsToIdle();
46 auto xDocumentContext = getDocumentAccessibleContext();
48 /* The tree inside the document is a bit awkward, as the page is not the parent of the other
49 * shapes, but well. It looks like this:
50 * document_presentation
51 * shape (page)
52 * shape (title)
53 * paragraph
54 * shape (subtitle)
55 * paragraph
57 CPPUNIT_ASSERT_EQUAL(sal_Int64(3), xDocumentContext->getAccessibleChildCount());
58 CPPUNIT_ASSERT_EQUAL(
59 OUString("PresentationTitle "),
60 xDocumentContext->getAccessibleChild(1)->getAccessibleContext()->getAccessibleName());
61 CPPUNIT_ASSERT_EQUAL(
62 OUString("PresentationSubtitle "),
63 xDocumentContext->getAccessibleChild(2)->getAccessibleContext()->getAccessibleName());
66 // test a11y tree order is stable (https://bugs.documentfoundation.org/show_bug.cgi?id=150064)
67 CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, tdf150064)
69 loadFromSrc(u"/sd/qa/unit/a11y/data/tdf150064.fodp");
70 Scheduler::ProcessEventsToIdle();
72 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxDocument,
73 uno::UNO_QUERY_THROW);
74 uno::Reference<frame::XModel> xModel(mxDocument, uno::UNO_QUERY_THROW);
75 uno::Reference<drawing::XDrawView> xDrawView(xModel->getCurrentController(),
76 uno::UNO_QUERY_THROW);
78 auto xDrawPages = xDrawPagesSupplier->getDrawPages();
79 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDrawPages->getCount());
81 // Loop a couple times to make sure output is stable when loading and when switching pages
82 for (int i = 0; i < 2; i++)
84 uno::Reference<drawing::XDrawPage> xDrawPage;
86 CPPUNIT_ASSERT(xDrawPages->getByIndex(0) >>= xDrawPage);
87 xDrawView->setCurrentPage(xDrawPage);
88 Scheduler::ProcessEventsToIdle();
90 CPPUNIT_ASSERT_EQUAL(
91 rtl::OUString("<SHAPE name=\"PageShape: Slide 1\" description=\" \"/>"
92 "<SHAPE name=\"PresentationTitle \" description=\" \">"
93 "<PARAGRAPH description=\"Paragraph: 0 P1 title\">P1 title</PARAGRAPH>"
94 "</SHAPE>"
95 "<SHAPE name=\"PresentationSubtitle \" description=\" \">"
96 "<PARAGRAPH description=\"Paragraph: 0 Some text\">Some text</PARAGRAPH>"
97 "</SHAPE>"
98 "<TABLE name=\"TableShape \" description=\" \">"
99 "<TABLE_CELL name=\"A1\">"
100 "<PARAGRAPH description=\"Paragraph: 0 1\">1</PARAGRAPH>"
101 "</TABLE_CELL>"
102 "<TABLE_CELL name=\"B1\">"
103 "<PARAGRAPH description=\"Paragraph: 0 2\">2</PARAGRAPH>"
104 "</TABLE_CELL>"
105 "<TABLE_CELL name=\"C1\">"
106 "<PARAGRAPH description=\"Paragraph: 0 3\">3</PARAGRAPH>"
107 "</TABLE_CELL>"
108 "<TABLE_CELL name=\"D1\">"
109 "<PARAGRAPH description=\"Paragraph: 0 4\">4</PARAGRAPH>"
110 "</TABLE_CELL>"
111 "<TABLE_CELL name=\"E1\">"
112 "<PARAGRAPH description=\"Paragraph: 0 5\">5</PARAGRAPH>"
113 "</TABLE_CELL>"
114 "<TABLE_CELL name=\"A2\">"
115 "<PARAGRAPH description=\"Paragraph: 0 6\">6</PARAGRAPH>"
116 "</TABLE_CELL>"
117 "<TABLE_CELL name=\"B2\">"
118 "<PARAGRAPH description=\"Paragraph: 0 7\">7</PARAGRAPH>"
119 "</TABLE_CELL>"
120 "<TABLE_CELL name=\"C2\">"
121 "<PARAGRAPH description=\"Paragraph: 0 8\">8</PARAGRAPH>"
122 "</TABLE_CELL>"
123 "<TABLE_CELL name=\"D2\">"
124 "<PARAGRAPH description=\"Paragraph: 0 9\">9</PARAGRAPH>"
125 "</TABLE_CELL>"
126 "<TABLE_CELL name=\"E2\">"
127 "<PARAGRAPH description=\"Paragraph: 0 10\">10</PARAGRAPH>"
128 "</TABLE_CELL>"
129 "</TABLE>"),
130 collectText());
132 CPPUNIT_ASSERT(xDrawPages->getByIndex(1) >>= xDrawPage);
133 xDrawView->setCurrentPage(xDrawPage);
134 Scheduler::ProcessEventsToIdle();
136 CPPUNIT_ASSERT_EQUAL(
137 rtl::OUString("<SHAPE name=\"PageShape: Slide 2\" description=\" \"/>"
138 "<SHAPE name=\"PresentationTitle \" description=\" \">"
139 "<PARAGRAPH description=\"Paragraph: 0 P2 title\">P2 title</PARAGRAPH>"
140 "</SHAPE>"
141 "<SHAPE name=\"PresentationOutliner \" description=\" \">"
142 "<PARAGRAPH description=\"Paragraph: 0 1\">1</PARAGRAPH>"
143 "</SHAPE>"
144 "<SHAPE name=\"PresentationOutliner \" description=\" \">"
145 "<PARAGRAPH description=\"Paragraph: 0 2\">2</PARAGRAPH>"
146 "</SHAPE>"
147 "<SHAPE name=\"PresentationOutliner \" description=\" \">"
148 "<PARAGRAPH description=\"Paragraph: 0 3\">3</PARAGRAPH>"
149 "</SHAPE>"),
150 collectText());
154 CPPUNIT_PLUGIN_IMPLEMENT();