8286266: [macos] Voice over moving JTable column to be the first column JVM crashes

Reviewed-by: prr
This commit is contained in:
Alexander Zuev 2022-05-20 21:19:42 +00:00
parent ba23f14025
commit b33c6e52c1
3 changed files with 43 additions and 9 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, JetBrains s.r.o.. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -29,6 +29,7 @@
@interface TableAccessibility : CommonComponentAccessibility <NSAccessibilityTable>
{
NSMutableDictionary<NSNumber*, id> *rowCache;
BOOL cacheValid;
}
- (BOOL)isAccessibleChildSelectedFromIndex:(int)index;

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2022, JetBrains s.r.o.. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -130,6 +130,15 @@ static jmethodID sjm_getAccessibleName = NULL;
if (rowCache == nil) {
int rowCount = [self accessibilityRowCount];
rowCache = [[NSMutableDictionary<NSNumber*, id> dictionaryWithCapacity:rowCount] retain];
cacheValid = YES;
}
if (!cacheValid) {
for (NSNumber *key in [rowCache allKeys]) {
[[rowCache objectForKey:key] release];
[rowCache removeObjectForKey:key];
}
cacheValid = YES;
}
id row = [rowCache objectForKey:[NSNumber numberWithUnsignedInteger:index]];
@ -223,11 +232,7 @@ static jmethodID sjm_getAccessibleName = NULL;
}
- (void)clearCache {
for (NSNumber *key in [rowCache allKeys]) {
[[rowCache objectForKey:key] release];
}
[rowCache release];
rowCache = nil;
cacheValid = NO;
}
@end

View File

@ -76,6 +76,27 @@ public class AccessibleJTableTest extends AccessibleComponentTest {
super.createUI(panel, "AccessibleJTableTest");
}
public void createUIDraggable() {
INSTRUCTIONS = "INSTRUCTIONS:\n"
+ "Check that table is properly updated when column order is changed.\n\n"
+ "Turn screen reader on, and Tab to the table.\n"
+ "Using arrow keys navigate to the last cell in the first row in the table."
+ "Screen reader should announce it as \"Column 3 row 1\"\n\n"
+ "Using mouse drag the header of the last culumn so the last column becomes the first one."
+ "Wait for the screen reader to finish announcing new position in table.\n\n"
+ "If new position in table corresponds to the new table layout ctrl+tab further "
+ "and press PASS, otherwise press FAIL.\n";
JTable table = new JTable(data, columnNames);
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
JScrollPane scrollPane = new JScrollPane(table);
panel.add(scrollPane);
panel.setFocusable(false);
exceptionString = "AccessibleJTable test failed!";
super.createUI(panel, "AccessibleJTableTest");
}
public void createUINamed() {
INSTRUCTIONS = "INSTRUCTIONS:\n"
+ "Check a11y of named JTable.\n\n"
@ -166,6 +187,13 @@ public class AccessibleJTableTest extends AccessibleComponentTest {
throw new RuntimeException(exceptionString);
}
countDownLatch = test.createCountDownLatch();
SwingUtilities.invokeAndWait(test::createUIDraggable);
countDownLatch.await(15, TimeUnit.MINUTES);
if (!testResult) {
throw new RuntimeException(exceptionString);
}
countDownLatch = test.createCountDownLatch();
SwingUtilities.invokeAndWait(test::createUINamed);
countDownLatch.await(15, TimeUnit.MINUTES);