Skip to content

Commit 87b207a

Browse files
committed
Add call hierarchy UI test.
1 parent ea6a89d commit 87b207a

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

rascal-vscode-extension/src/test/vscode-suite/dsl.test.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
* POSSIBILITY OF SUCH DAMAGE.
2626
*/
2727

28-
import { VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester';
29-
import { Delays, IDEOperations, RascalREPL, TestWorkspace, ignoreFails, printRascalOutputOnFailure, sleep } from './utils';
28+
import { By, until, VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester';
29+
import { Delays, IDEOperations, ignoreFails, printRascalOutputOnFailure, RascalREPL, sleep, TestWorkspace } from './utils';
3030

31+
import { expect } from 'chai';
3132
import * as fs from 'fs/promises';
32-
import * as path from 'path';
3333
import { Suite } from 'mocha';
34-
import { expect } from 'chai';
34+
import * as path from 'path';
3535

3636
function parameterizedDescribe(body: (this: Suite, errorRecovery: boolean) => void) {
3737
describe('DSL', function() { body.apply(this, [false]); });
@@ -258,4 +258,25 @@ parameterizedDescribe(function (errorRecovery: boolean) {
258258

259259
await fs.rm(newDir, {recursive: true, force: true});
260260
});
261+
262+
it("call hierarchy works", async function() {
263+
const editor = await ide.openModule(TestWorkspace.picoCallsFile);
264+
await editor.selectText("multiply");
265+
await bench.executeCommand("view.showCallHierarchy");
266+
await driver.wait(until.elementLocated(By.xpath("//div[contains(@class, 'title-label')]/h2[contains(text(), 'References')]")));
267+
268+
await bench.executeCommand("view.showOutgoingCalls");
269+
await driver.wait(until.elementLocated(By.xpath("//div[contains(@class, 'title-label')]/h2[contains(text(), 'Calls From')]")));
270+
await driver.wait(async () => {
271+
const hieraryItems = await bench.getSideBar().findElements(By.xpath("//div[@role='treeitem']"));
272+
return hieraryItems.length === 3;
273+
}, Delays.normal, "Call hierarchy should show `multiply` and its two outgoing calls.");
274+
275+
await bench.executeCommand("view.showIncomingCalls");
276+
await driver.wait(until.elementLocated(By.xpath("//div[contains(@class, 'title-label')]/h2[contains(text(), 'Callers Of')]")));
277+
await driver.wait(async () => {
278+
const hieraryItems = await bench.getSideBar().findElements(By.xpath("//div[@role='treeitem']"));
279+
return hieraryItems.length === 2;
280+
}, Delays.normal, "Call hierarchy should show `multiply` and its recursive call.");
281+
});
261282
});

rascal-vscode-extension/src/test/vscode-suite/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class TestWorkspace {
6868

6969
public static readonly picoFile = path.join(src(this.testProject, 'pico'), 'testing.pico');
7070
public static readonly picoNewFile = path.join(src(this.testProject, 'pico'), 'testing.pico-new');
71+
public static readonly picoCallsFile = path.join(src(this.testProject, 'pico'), 'calls.pico');
7172
}
7273

7374

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
begin
2+
declare
3+
add(x: natural, y: natural): natural := x + y,
4+
multiply(x: natural, y: natural): natural := add(x, multiply(x - 1, y));
5+
end

0 commit comments

Comments
 (0)