forked from amazingfate/loongoffice
With 16k column support in Calc enabled by default in
commit 4c5f8ccf0a2320432b8fe91add1dcadf54d9fd58
Date: Tue Mar 8 12:44:49 2022 +0100
change default Calc number of columns to 16384 (tdf#50916)
, the number of Calc cells in a spreadsheet is larger than
SAL_MAX_INT32, meaning that a 32-bit a11y child index is no more
enough and using it resulted in integer overflows in
methods handling corresponding Calc cells in the a11y layer.
This e.g. had the effect of the Orca and NVDA screen readers
not announcing focused or selected cells properly when their
a11y child index was out of the 32-bit integer range.
Switch the internal a11y child indices to 64 bit to
be able to handle this properly internally.
Since the platform APIs (at least AT-SPI on Linux and
IAccessible2 on Windows; from what I can see LO's macOS
a11y bridge doesn't directly expose the child index)
are still restricted to 32 bit, larger child indices
still cannot be exposed via the platform APIs.
As a consequence, use of the the IAccessible2 and
AT-SPI methods that use the child index remains
problematic in those cases where the child index
is larger. However, as an alternative to using the
AT-SPI Table interface and the IAccessibleTable/
IAccessibleTable2 interfaces with the child index
to retrieve information about a specific cell,
both AT-SPI and IAccessible2 also provide interfaces
to retrieve that information directly
from the cell object (TableCell interface for AT-SPI,
IAccessibleTableCell for IAccessible2).
Those interfaces are already implemented/exposed
for winaccessibility (s. `CAccTable`) and the
qt5/qt6/kf5 VCL plugins (s. the `QAccessibleTableCellInterface`
methods implemented in `QtAccessibleInterface`).
With the switch to 64-bit internal a11y child indices,
these now behave correctly for cells with a child
index that doesn't fit into 32 bit as well.
NVDA on Windows already uses the IAccessibleTableCell
interface and thus announcing focused cells works fine
with this change in place.
Orca on Linux currently doesn't make use of the AT-SPI
TableCell interface yet, but with a suggested change to
do so [1], announcement of selected cells works
with the qt6 VCL plugin with a current qtbase dev branch
as well - when combined with the suggested changes
to implement support for the AT-SPI TableCell interface
in Qt [2] [3] and the LO change based on that [4] and
a fix for a nullptr dereference [5].
The gtk3 VCL plugin doesn't expose the AT-SPI
TableCell interface yet, but once it does so
(via `AtkTableCell`), it also works with the
suggested Orca change [1] in place.
(Adding that is planned for an upcoming change,
works with a local WIP patch.)
For handling return values that are larger than what
platform APIs support, the following approach has
been chosen for now:
1) When the return value is for the count of
(selected) children, the maximum value N
supported by the platform API is returned.
(This is what `ScAccessibleTableBase::getAccessibleChildCount`
did previously.)
The first N elements can be accessed by their
actual (selection) indices.
2) When the return value is the child/cell index,
-2 is returned for objects whose index is greater
than the maximum value supported by the platform
API.
Using a non-negative value would mean that the
index would refer to *another* actually existing
child. A child index of -1 on the other hand
tends to be interpreted as "child is invalid" or
"object isn't actually a child of its (previous)
parent any more)". For the Orca case, this would
result in objects with a child index of -1
not being announced, as they are considered
"zombies" [6].
What's still somewhat problematic is the case where
more than 2^31 children are *selected*, since access
to those children still happens by the index into
the selection in the platform APIs, and not all
selected items are accessible this way.
(Screen readers usually just retrieve
the first and last element from the selection and
announce those.)
Orca already seems to apply different handling for the
case for fully selected rows and columns, so
"All cells selected" or "Columns ... to ... selected"
is announced just fine even if more than 2^31
cells are selected.
(Side note: While Microsoft User Interface
Automation - UIA - also uses 32-bit indices, it also
has specific methods in the ISelectionProvider2
interface that allow to explicitly retrieve the
first and last selected item,
`ISelectionProvider2::get_FirstSelectedItem` and
`ISelectionProvider2::get_LastSelectedItem`, but
we currently don't support UIA on Windows.)
Bound checks at the beginning of the methods from the
`XAccessibleContext`, `XAccessibleSelection` and
`XAccessibleTable` interfaces that take a child index
(or in helper methods called by those) should generally
already prevent too large indices from being passed to
the methods in the lower layer code that take smaller
integer types. Such bound checking has been
been added in various places where it wasn't present yet.
If there any remaining issues of this
kind that show after this commit, they can probably be
solved in a similar way (s.e.g. the change to
`AccessibleBrowseBox::getAccessibleChild` in this
commit).
A few asserts were also added at
places where my understanding is that values shouldn't
be larger than what is supported by a called method
anyway.
A test case will be added in a following change.
[1] https://gitlab.gnome.org/GNOME/orca/-/merge_requests/131
[2] https://codereview.qt-project.org/c/qt/qtbase/+/428566
[3] https://codereview.qt-project.org/c/qt/qtbase/+/428567
[4] https://gerrit.libreoffice.org/c/core/+/138750
[5] https://codereview.qt-project.org/c/qt/qtbase/+/430157
[6] 82c8542002/src/orca/script_utilities.py (L5155)
Change-Id: I3af590c988b0e6754fc72545918412f39e8fea07
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139258
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
1000 lines
36 KiB
Java
1000 lines
36 KiB
Java
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* 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 .
|
|
*/
|
|
|
|
package ifc.accessibility;
|
|
|
|
import lib.MultiMethodTest;
|
|
|
|
import com.sun.star.accessibility.XAccessible;
|
|
import com.sun.star.accessibility.XAccessibleContext;
|
|
import com.sun.star.accessibility.XAccessibleSelection;
|
|
import com.sun.star.accessibility.XAccessibleTable;
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
/**
|
|
* Testing <code>com.sun.star.accessibility.XAccessibleTable</code>
|
|
* interface methods :
|
|
* <ul>
|
|
* <li><code>getAccessibleRowCount()</code></li>
|
|
* <li><code>getAccessibleColumnCount()</code></li>
|
|
* <li><code>getAccessibleRowDescription()</code></li>
|
|
* <li><code>getAccessibleColumnDescription()</code></li>
|
|
* <li><code>getAccessibleRowExtentAt()</code></li>
|
|
* <li><code>getAccessibleColumnExtentAt()</code></li>
|
|
* <li><code>getAccessibleRowHeaders()</code></li>
|
|
* <li><code>getAccessibleColumnHeaders()</code></li>
|
|
* <li><code>getSelectedAccessibleRows()</code></li>
|
|
* <li><code>getSelectedAccessibleColumns()</code></li>
|
|
* <li><code>isAccessibleRowSelected()</code></li>
|
|
* <li><code>isAccessibleColumnSelected()</code></li>
|
|
* <li><code>getAccessibleCellAt()</code></li>
|
|
* <li><code>getAccessibleCaption()</code></li>
|
|
* <li><code>getAccessibleSummary()</code></li>
|
|
* <li><code>isAccessibleSelected()</code></li>
|
|
* <li><code>getAccessibleIndex()</code></li>
|
|
* <li><code>getAccessibleRow()</code></li>
|
|
* <li><code>getAccessibleColumn()</code></li>
|
|
* </ul> <p>
|
|
* @see com.sun.star.accessibility.XAccessibleTable
|
|
*/
|
|
public class _XAccessibleTable extends MultiMethodTest {
|
|
|
|
public XAccessibleTable oObj = null;
|
|
XAccessibleSelection xASel = null;
|
|
XAccessibleContext xACont = null;
|
|
|
|
@Override
|
|
protected void before() {
|
|
xASel = UnoRuntime.queryInterface(XAccessibleSelection.class, oObj);
|
|
if (xASel == null) {
|
|
log.println("The component doesn't implement the interface " +
|
|
"XAccessibleSelection.");
|
|
log.println("This interface is required for more detailed tests.");
|
|
}
|
|
|
|
xACont = UnoRuntime.queryInterface(XAccessibleContext.class, oObj);
|
|
}
|
|
|
|
int rowCount = 0;
|
|
|
|
/**
|
|
* Calls the method and stores the returned value to the variable
|
|
* <code>rowCount</code>.
|
|
*/
|
|
public void _getAccessibleRowCount() {
|
|
rowCount = oObj.getAccessibleRowCount();
|
|
log.println("Accessible row count: " + rowCount);
|
|
tRes.tested("getAccessibleRowCount()", true);
|
|
}
|
|
|
|
int colCount = 0;
|
|
|
|
/**
|
|
* Calls the method and stores the returned value to the variable
|
|
* <code>colCount</code>.
|
|
*/
|
|
public void _getAccessibleColumnCount() {
|
|
colCount = oObj.getAccessibleColumnCount();
|
|
log.println("Accessible column count: " + colCount);
|
|
tRes.tested("getAccessibleColumnCount()", true);
|
|
}
|
|
|
|
/**
|
|
* Calls the method with the wrong indexes and with the correct index,
|
|
* checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value isn't <code>null</code>.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleRowDescription() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
boolean res = true;
|
|
|
|
try {
|
|
log.print("getAccessibleRowDescription(-1): ");
|
|
String descr = oObj.getAccessibleRowDescription(-1);
|
|
log.println("'" + descr + "'");
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRowDescription(" + rowCount + "): ");
|
|
String descr = oObj.getAccessibleRowDescription(rowCount);
|
|
log.println("'" + descr + "'");
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRowDescription(" + (rowCount - 1) + "): ");
|
|
String descr =
|
|
oObj.getAccessibleRowDescription(rowCount - 1);
|
|
res &= descr != null;
|
|
log.println("'" + descr + "'");
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleRowDescription()", res);
|
|
}
|
|
|
|
/**
|
|
* Calls the method with the wrong indexes and with the correct index,
|
|
* checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value isn't <code>null</code>.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleColumnCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleColumnDescription() {
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
|
|
try {
|
|
log.print("getAccessibleColumnDescription(-1): ");
|
|
String descr = oObj.getAccessibleColumnDescription(-1);
|
|
log.println("'" + descr + "'");
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumnDescription(" + colCount + "): ");
|
|
String descr = oObj.getAccessibleColumnDescription(colCount);
|
|
log.println("'" + descr + "'");
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumnDescription(" + (colCount - 1) + "): ");
|
|
String descr =
|
|
oObj.getAccessibleColumnDescription(colCount - 1);
|
|
res &= descr != null;
|
|
log.println("'" + descr + "'");
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleColumnDescription()", res);
|
|
}
|
|
|
|
|
|
/**
|
|
* Calls the method with the wrong parameters and with the correct
|
|
* parameters, checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value is greater than or is equal to 1.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleColumnCount()</code> </li>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleRowExtentAt() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
|
|
try {
|
|
log.print("getAccessibleRowExtentAt(-1," + (colCount-1) + "):");
|
|
int ext = oObj.getAccessibleRowExtentAt(-1, colCount - 1);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRowExtentAt(" + (rowCount-1) + ",-1):");
|
|
int ext = oObj.getAccessibleRowExtentAt(rowCount - 1, -1);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRowExtentAt(0," + colCount + "):");
|
|
int ext = oObj.getAccessibleRowExtentAt(0, colCount);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRowExtentAt(" + rowCount + ",0):");
|
|
int ext = oObj.getAccessibleRowExtentAt(rowCount, 0);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRowExtentAt(" +
|
|
(rowCount-1) + "," + (colCount-1) + "):");
|
|
int ext = oObj.getAccessibleRowExtentAt(rowCount-1, colCount - 1);
|
|
log.println(ext);
|
|
res &= ext >= 1;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleRowExtentAt()", res);
|
|
}
|
|
|
|
/**
|
|
* Calls the method with the wrong parameters and with the correct
|
|
* parameters, checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value is greater than or is equal to 1.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleColumnCount()</code> </li>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleColumnExtentAt() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
|
|
try {
|
|
log.print("getAccessibleColumnExtentAt(-1," + (colCount-1) + "):");
|
|
int ext = oObj.getAccessibleColumnExtentAt(-1, colCount - 1);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumnExtentAt(" + (rowCount-1) + ",-1):");
|
|
int ext = oObj.getAccessibleColumnExtentAt(rowCount - 1, -1);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumnExtentAt(0," + colCount + "):");
|
|
int ext = oObj.getAccessibleColumnExtentAt(0, colCount);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumnExtentAt(" + rowCount + ",0):");
|
|
int ext = oObj.getAccessibleColumnExtentAt(rowCount, 0);
|
|
log.println(ext);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumnExtentAt(" +
|
|
(rowCount-1) + "," + (colCount-1) + "):");
|
|
int ext = oObj.getAccessibleColumnExtentAt(rowCount-1,colCount - 1);
|
|
log.println(ext);
|
|
res &= ext >= 1;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleColumnExtentAt()", res);
|
|
}
|
|
|
|
/**
|
|
* Calls the method and checks a returned value.
|
|
* Has OK status if returned value isn't <code>null</code>.
|
|
*/
|
|
public void _getAccessibleRowHeaders() {
|
|
XAccessibleTable rowHeaders = oObj.getAccessibleRowHeaders();
|
|
log.println("getAccessibleRowHeaders(): " + rowHeaders);
|
|
tRes.tested("getAccessibleRowHeaders()", true);
|
|
}
|
|
|
|
/**
|
|
* Calls the method and checks a returned value.
|
|
* Has OK status if returned value isn't <code>null</code>.
|
|
*/
|
|
public void _getAccessibleColumnHeaders() {
|
|
XAccessibleTable colHeaders = oObj.getAccessibleColumnHeaders();
|
|
log.println("getAccessibleColumnHeaders(): " + colHeaders);
|
|
tRes.tested("getAccessibleColumnHeaders()", true);
|
|
}
|
|
|
|
/**
|
|
* If the interface <code>XAccessibleSelection</code> is supported by
|
|
* the component than selects all accessible children.
|
|
* Calls the method and checks a returned sequence.
|
|
* Has OK status if a returned sequince is in ascending order.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getSelectedAccessibleRows() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
boolean res = true;
|
|
boolean locRes = true;
|
|
int selRows[] = null;
|
|
|
|
if (xASel != null) {
|
|
log.println("XAccessibleSelection.selectAllAccessibleChildren()");
|
|
xASel.selectAllAccessibleChildren();
|
|
}
|
|
|
|
log.println("getSelectedAccessibleRows()");
|
|
selRows = oObj.getSelectedAccessibleRows();
|
|
log.println("Length of the returned sequince: " + selRows.length);
|
|
if (xASel != null) {
|
|
res &= selRows.length == rowCount;
|
|
} else {
|
|
res &= selRows.length == 0;
|
|
}
|
|
|
|
if (selRows.length > 0) {
|
|
log.println("Checking that returned sequence is" +
|
|
" in ascending order");
|
|
}
|
|
|
|
for(int i = 1; i < selRows.length; i++) {
|
|
locRes &= selRows[i] >= selRows[i - 1];
|
|
res &= locRes;
|
|
if (!locRes) {
|
|
log.println("Element #" + i + ":" + selRows[i] +
|
|
" is less than element #" + (i-1) + ": " +
|
|
selRows[i-1]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
tRes.tested("getSelectedAccessibleRows()", res);
|
|
}
|
|
|
|
/**
|
|
* If the interface <code>XAccessibleSelection</code> is supported by
|
|
* the component than selects all accessible children.
|
|
* Calls the method and checks a returned sequence.
|
|
* Has OK status if a returned sequince is in ascending order.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleColumnCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getSelectedAccessibleColumns() {
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
boolean locRes = true;
|
|
int selCols[] = null;
|
|
|
|
if (xASel != null) {
|
|
log.println("XAccessibleSelection.selectAllAccessibleChildren()");
|
|
xASel.selectAllAccessibleChildren();
|
|
}
|
|
|
|
log.println("getSelectedAccessibleColumns()");
|
|
selCols = oObj.getSelectedAccessibleColumns();
|
|
log.println("Length of the returned sequince: " + selCols.length);
|
|
|
|
if (xASel != null) {
|
|
res &= selCols.length == colCount;
|
|
} else {
|
|
res &= selCols.length == 0;
|
|
}
|
|
|
|
if (selCols.length > 0) {
|
|
log.println("Checking that returned sequence is" +
|
|
" in ascending order");
|
|
}
|
|
|
|
for(int i = 1; i < selCols.length; i++) {
|
|
locRes &= selCols[i] >= selCols[i - 1];
|
|
res &= locRes;
|
|
if (!locRes) {
|
|
log.println("Element #" + i + ":" + selCols[i] +
|
|
" is less than element #" + (i-1) + ": " +
|
|
selCols[i-1]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
tRes.tested("getSelectedAccessibleColumns()", res);
|
|
}
|
|
|
|
/**
|
|
* Calls the method with invalid indexes.
|
|
* If the interface <code>XAccessibleSelection</code> is supported by
|
|
* the component than selects all accessible children.
|
|
* Calls the method for every row and checks returned values.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _isAccessibleRowSelected() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
boolean res = true;
|
|
boolean locRes = true;
|
|
|
|
try {
|
|
log.print("isAccessibleRowSelected(-1): ");
|
|
locRes = oObj.isAccessibleRowSelected(-1);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("isAccessibleRowSelected(" + rowCount + "): ");
|
|
locRes = oObj.isAccessibleRowSelected(rowCount);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
if (xASel != null) {
|
|
log.println("XAccessibleSelection.selectAllAccessibleChildren()");
|
|
xASel.selectAllAccessibleChildren();
|
|
}
|
|
|
|
try {
|
|
log.println("Checking of every row selection...");
|
|
for(int i = 0; i < rowCount; i++) {
|
|
boolean isSel = oObj.isAccessibleRowSelected(i);
|
|
locRes = (xASel == null) ? !isSel : isSel;
|
|
res &= locRes;
|
|
if (!locRes) {
|
|
log.println("isAccessibleRowSelected(" + i + "): " + isSel);
|
|
break;
|
|
}
|
|
}
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("isAccessibleRowSelected()", res);
|
|
}
|
|
|
|
/**
|
|
* Calls the method with invalid indexes.
|
|
* If the interface <code>XAccessibleSelection</code> is supported by
|
|
* the component than selects all accessible children.
|
|
* Calls the method for every column and checks returned values.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _isAccessibleColumnSelected() {
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
boolean locRes = true;
|
|
|
|
try {
|
|
log.print("isAccessibleColumnSelected(-1): ");
|
|
locRes = oObj.isAccessibleColumnSelected(-1);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("isAccessibleColumnSelected(" + colCount + "): ");
|
|
locRes = oObj.isAccessibleColumnSelected(colCount);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
if (xASel != null) {
|
|
log.println("XAccessibleSelection.selectAllAccessibleChildren()");
|
|
xASel.selectAllAccessibleChildren();
|
|
}
|
|
|
|
try {
|
|
log.println("Checking of every column selection...");
|
|
for(int i = 0; i < colCount; i++) {
|
|
boolean isSel = oObj.isAccessibleColumnSelected(i);
|
|
locRes = (xASel == null) ? !isSel : isSel;
|
|
res &= locRes;
|
|
if (!locRes) {
|
|
log.println("isAccessibleColumnSelected(" + i + "): " + isSel);
|
|
break;
|
|
}
|
|
}
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("isAccessibleColumnSelected()", res);
|
|
}
|
|
|
|
XAccessible xCellAc = null;
|
|
|
|
/**
|
|
* Calls the method with the wrong parameters and with the correct
|
|
* parameter, checks a returned value and stores it to the variable
|
|
* <code>xCellAc</code>.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value isn't null.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleColumnCount()</code> </li>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleCellAt() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
|
|
try {
|
|
log.print("getAccessibleCellAt(-1," + (colCount-1) + "):");
|
|
xCellAc = oObj.getAccessibleCellAt(-1, colCount - 1);
|
|
log.println(xCellAc);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleCellAt(" + (rowCount-1) + ",-1):");
|
|
xCellAc = oObj.getAccessibleCellAt(rowCount - 1, -1);
|
|
log.println(xCellAc);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleCellAt(0, " + colCount + "):");
|
|
xCellAc = oObj.getAccessibleCellAt(0, colCount);
|
|
log.println(xCellAc);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleCellAt(" + rowCount + ",0):");
|
|
XAccessible xCellAc = oObj.getAccessibleCellAt(rowCount, 0);
|
|
log.println(xCellAc);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleCellAt(" + (rowCount-1) + "," +
|
|
(colCount-1) + "): ");
|
|
xCellAc = oObj.getAccessibleCellAt(
|
|
rowCount - 1, colCount - 1);
|
|
log.println(xCellAc);
|
|
res &= xCellAc != null;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleCellAt()", res);
|
|
}
|
|
|
|
/**
|
|
* Just calls the method.
|
|
*/
|
|
public void _getAccessibleCaption() {
|
|
XAccessible caption = oObj.getAccessibleCaption();
|
|
log.println("getAccessibleCaption(): " + caption);
|
|
tRes.tested("getAccessibleCaption()", true);
|
|
}
|
|
|
|
/**
|
|
* Just calls the method.
|
|
*/
|
|
public void _getAccessibleSummary() {
|
|
XAccessible summary = oObj.getAccessibleSummary();
|
|
log.println("getAccessibleSummary(): " + summary);
|
|
tRes.tested("getAccessibleSummary()", true);
|
|
}
|
|
|
|
/**
|
|
* Calls the method with the wrong parameters and with the correct
|
|
* parameter, checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleColumnCount()</code> </li>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _isAccessibleSelected() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
boolean locRes = true;
|
|
|
|
try {
|
|
log.print("isAccessibleSelected(-1," + (colCount-1) + "):");
|
|
locRes = oObj.isAccessibleSelected(-1, colCount - 1);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("isAccessibleSelected(" + (rowCount-1) + ",-1):");
|
|
locRes = oObj.isAccessibleSelected(rowCount - 1, -1);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("isAccessibleSelected(0, " + colCount + "):");
|
|
locRes = oObj.isAccessibleSelected(0, colCount);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("isAccessibleSelected(" + rowCount + ",0):");
|
|
locRes = oObj.isAccessibleSelected(rowCount, 0);
|
|
log.println(locRes);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
if (xASel != null) {
|
|
log.println("XAccessibleSelection.selectAllAccessibleChildren()");
|
|
xASel.selectAllAccessibleChildren();
|
|
}
|
|
|
|
try {
|
|
log.print("isAccessibleSelected(" + (rowCount-1) + "," +
|
|
(colCount-1) + "): ");
|
|
boolean isSel = oObj.isAccessibleSelected(
|
|
rowCount - 1, colCount - 1);
|
|
log.println(isSel);
|
|
locRes = (xASel == null) ? !isSel : isSel ;
|
|
res &= locRes;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("isAccessibleSelected()", res);
|
|
}
|
|
|
|
/**
|
|
* Calls the method with the wrong parameters and with the correct
|
|
* parameter, checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value is equal to value returned by calling
|
|
* <code>XAccessibleContext::getAccessibleIndexInParent</code> for the cell.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleCellAt()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleIndex() {
|
|
executeMethod("getAccessibleCellAt()");
|
|
boolean res = true;
|
|
|
|
try {
|
|
log.print("getAccessibleIndex(-1," + (colCount-1) + "):");
|
|
long indx = oObj.getAccessibleIndex(-1, colCount - 1);
|
|
log.println(indx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleIndex(" + (rowCount-1) + ",-1):");
|
|
long indx = oObj.getAccessibleIndex(rowCount - 1, -1);
|
|
log.println(indx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleIndex(0," + colCount + "):");
|
|
long indx = oObj.getAccessibleIndex(0, colCount);
|
|
log.println(indx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleIndex(" + rowCount + ",0):");
|
|
long indx = oObj.getAccessibleIndex(rowCount, 0);
|
|
log.println(indx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleIndex(" + (rowCount-1) + "," +
|
|
(colCount-1) + "): ");
|
|
long indx = oObj.getAccessibleIndex(rowCount - 1, colCount - 1);
|
|
log.println(indx);
|
|
if (xCellAc != null) {
|
|
XAccessibleContext xAC = xCellAc.getAccessibleContext();
|
|
long expIndx = xAC.getAccessibleIndexInParent();
|
|
log.println("Expected index: " + expIndx);
|
|
res &= expIndx == indx;
|
|
} else {
|
|
res &= true;
|
|
}
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleIndex()", res);
|
|
}
|
|
|
|
/**
|
|
* Receives an accessible child count using the interface
|
|
* <code>XAccessibleContext</code>.
|
|
* Calls the method with the wrong parameters and with the correct
|
|
* parameter, checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value is greater than zero and is less than
|
|
* accessible row count.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleRowCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleRow() {
|
|
requiredMethod("getAccessibleRowCount()");
|
|
boolean res = true;
|
|
|
|
if (xACont != null) {
|
|
long childCount = xACont.getAccessibleChildCount();
|
|
log.println("accessible child count: " + childCount);
|
|
|
|
try {
|
|
log.print("getAccessibleRow(" + childCount + "): ");
|
|
int rowIndx = oObj.getAccessibleRow(childCount);
|
|
log.println(rowIndx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRow(" + (childCount-1) + "): ");
|
|
int rowIndx = oObj.getAccessibleRow(childCount - 1);
|
|
log.println(rowIndx);
|
|
res &= (rowIndx >= 0 && rowIndx <= rowCount);
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRow(-1): ");
|
|
int rowIndx = oObj.getAccessibleRow(-1);
|
|
log.println(rowIndx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleRow(0): ");
|
|
int rowIndx = oObj.getAccessibleRow(0);
|
|
log.println(rowIndx);
|
|
res &= (rowIndx >= 0 && rowIndx <= rowCount);
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleRow()", res);
|
|
}
|
|
|
|
/**
|
|
* Receives an accessible child count using the interface
|
|
* <code>XAccessibleContext</code>.
|
|
* Calls the method with the wrong parameters and with the correct
|
|
* parameter, checks a returned value.
|
|
* Has OK status if exceptions were thrown for the wrong indexes,
|
|
* if exception wasn't thrown for the correct index and
|
|
* if returned value is greater than zero and is less than
|
|
* accessible column count.
|
|
* The following method tests are to be executed before:
|
|
* <ul>
|
|
* <li> <code>getAccessibleColumnCount()</code> </li>
|
|
* </ul>
|
|
*/
|
|
public void _getAccessibleColumn() {
|
|
requiredMethod("getAccessibleColumnCount()");
|
|
boolean res = true;
|
|
|
|
if (xACont != null) {
|
|
long childCount = xACont.getAccessibleChildCount();
|
|
log.println("accessible child count: " + childCount);
|
|
|
|
try {
|
|
log.print("getAccessibleColumn(" + childCount + "): ");
|
|
int colIndx = oObj.getAccessibleColumn(childCount);
|
|
log.println(colIndx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumn(" + (childCount-1) + "): ");
|
|
int colIndx = oObj.getAccessibleColumn(childCount - 1);
|
|
log.println(colIndx);
|
|
res &= (colIndx >= 0 && colIndx <= colCount);
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumn(-1): ");
|
|
int colIndx = oObj.getAccessibleColumn(-1);
|
|
log.println(colIndx);
|
|
log.println("Exception was expected");
|
|
res &= false;
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("expected exception");
|
|
res &= true;
|
|
}
|
|
|
|
try {
|
|
log.print("getAccessibleColumn(0): ");
|
|
int colIndx = oObj.getAccessibleColumn(0);
|
|
log.println(colIndx);
|
|
res &= (colIndx >= 0 && colIndx <= rowCount);
|
|
} catch(com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
log.println("Unexpected exception");
|
|
e.printStackTrace(log);
|
|
res &= false;
|
|
}
|
|
|
|
tRes.tested("getAccessibleColumn()", res);
|
|
}
|
|
}
|