Skip to content

Commit 3487c1f

Browse files
committed
Fix textOutput, put back accessibility tests
1 parent 42a121e commit 3487c1f

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

src/accessibility/outputs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ function outputs(p5, fn){
540540

541541
//gets position of shape in the canvas
542542
fn._getPos = function (x, y) {
543-
const { x: transformedX, y: transformedY } = this.worldToScreen(new this.Vector(x, y));
543+
const { x: transformedX, y: transformedY } = this.worldToScreen(new p5.Vector(x, y));
544544
const canvasWidth = this.width;
545545
const canvasHeight = this.height;
546546
if (transformedX < 0.4 * canvasWidth) {
@@ -657,7 +657,7 @@ function outputs(p5, fn){
657657
];
658658
// Apply the inverse of the current transformations to the canvas corners
659659
const currentTransform = this._renderer.isP3D ?
660-
new DOMMatrix(this._renderer.states.uMVMatrix.mat4) :
660+
new DOMMatrix(this._renderer.uMVMatrix.mat4) :
661661
this.drawingContext.getTransform();
662662
const invertedTransform = currentTransform.inverse();
663663
const tc = canvasCorners.map(

test/unit/accessibility/outputs.js

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { mockP5, mockP5Prototype } from '../../js/mocks';
22
import outputs from '../../../src/accessibility/outputs';
33
import textOutput from '../../../src/accessibility/textOutput';
4+
import p5 from '../../../src/app.js';
45

56
// TODO: Is it possible to test this without a runtime?
67
suite('outputs', function() {
@@ -17,10 +18,36 @@ suite('outputs', function() {
1718
assert.typeOf(mockP5Prototype.textOutput, 'function');
1819
});
1920

21+
test('should not break for webgl', async function() {
22+
await new Promise((res) => {
23+
new p5((p) => {
24+
p.setup = function() {
25+
p.createCanvas(50, 50, p.WEBGL);
26+
p.textOutput();
27+
p.circle(0, 0, 20);
28+
res();
29+
};
30+
});
31+
});
32+
});
33+
34+
test('should not break for webgl', async function() {
35+
await new Promise((res) => {
36+
new p5((p) => {
37+
p.setup = function() {
38+
p.createCanvas(50, 50, p.WEBGL);
39+
p.gridOutput();
40+
p.circle(0, 0, 20);
41+
res();
42+
};
43+
});
44+
});
45+
});
46+
2047
let expected =
2148
'Your output is a, 100 by 100 pixels, white canvas containing the following shape:';
2249

23-
test.todo('should create output as fallback', function() {
50+
test('should create output as fallback', function() {
2451
return new Promise(function(resolve, reject) {
2552
let actual = '';
2653
new p5(function(p) {
@@ -46,7 +73,7 @@ suite('outputs', function() {
4673
});
4774
});
4875

49-
test.todo('should create output as label', function() {
76+
test('should create output as label', function() {
5077
return new Promise(function(resolve, reject) {
5178
let label = '';
5279
let fallback = '';
@@ -76,7 +103,7 @@ suite('outputs', function() {
76103
});
77104
});
78105

79-
test.todo('should create text output for arc()', function() {
106+
test('should create text output for arc()', function() {
80107
return new Promise(function(resolve, reject) {
81108
expected =
82109
'<li><a href="#myCanvasIDtextOutputshape0">red arc</a>, at middle, covering 31% of the canvas.</li>';
@@ -104,7 +131,7 @@ suite('outputs', function() {
104131
});
105132
});
106133

107-
test.todo('should create text output for ellipse()', function() {
134+
test('should create text output for ellipse()', function() {
108135
return new Promise(function(resolve, reject) {
109136
expected =
110137
'<li><a href="#myCanvasIDtextOutputshape0">green circle</a>, at middle, covering 24% of the canvas.</li>';
@@ -132,7 +159,7 @@ suite('outputs', function() {
132159
});
133160
});
134161

135-
test.todo('should create text output for triangle()', function() {
162+
test('should create text output for triangle()', function() {
136163
return new Promise(function(resolve, reject) {
137164
expected =
138165
'<li><a href="#myCanvasIDtextOutputshape0">green triangle</a>, at top left, covering 13% of the canvas.</li>';
@@ -170,7 +197,7 @@ suite('outputs', function() {
170197
let expected =
171198
'white canvas, 100 by 100 pixels, contains 1 shape: 1 square';
172199

173-
test.todo('should create output as fallback', function() {
200+
test('should create output as fallback', function() {
174201
return new Promise(function(resolve, reject) {
175202
let actual = '';
176203
new p5(function(p) {
@@ -196,7 +223,7 @@ suite('outputs', function() {
196223
});
197224
});
198225

199-
test.todo('should create output as label', function() {
226+
test('should create output as label', function() {
200227
return new Promise(function(resolve, reject) {
201228
let label = '';
202229
let fallback = '';
@@ -226,7 +253,7 @@ suite('outputs', function() {
226253
});
227254
});
228255

229-
test.todo('should create text output for quad()', function() {
256+
test('should create text output for quad()', function() {
230257
return new Promise(function(resolve, reject) {
231258
expected = 'red quadrilateral, location = top left, area = 45 %';
232259
new p5(function(p) {
@@ -253,7 +280,7 @@ suite('outputs', function() {
253280
});
254281
});
255282

256-
test.todo('should create text output for point()', function() {
283+
test('should create text output for point()', function() {
257284
return new Promise(function(resolve, reject) {
258285
expected = 'dark fuchsia point, location = bottom right';
259286
new p5(function(p) {
@@ -280,7 +307,7 @@ suite('outputs', function() {
280307
});
281308
});
282309

283-
test.todo('should create text output for triangle()', function() {
310+
test('should create text output for triangle()', function() {
284311
return new Promise(function(resolve, reject) {
285312
expected = 'green triangle, location = top left, area = 13 %';
286313
new p5(function(p) {

0 commit comments

Comments
 (0)