Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2023 Flowing Code
* Copyright (C) 2020 - 2026 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,6 +70,7 @@ public void setup() throws Exception {
setDriver(TestBench.createDriver(new ChromeDriver()));
}
getDriver().get(getURL(route));
getCommandExecutor().waitForVaadin();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2023 Flowing Code
* Copyright (C) 2020 - 2026 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -29,12 +29,11 @@
public class SelectionFeatureIT extends AbstractViewTest {

@Test
public void testSelectionFeature() throws InterruptedException {
public void testSelectionFeature1() throws InterruptedException {
XTermElement term = $(XTermElement.class).first();
Position pos;

term.write("abcd");
pos = term.cursorPosition();
Position pos = term.cursorPosition();

// select left, backspace
term.sendKeys(Keys.SHIFT, Keys.ARROW_LEFT);
Expand Down Expand Up @@ -69,9 +68,14 @@ public void testSelectionFeature() throws InterruptedException {
term.sendKeys(Keys.BACK_SPACE);
assertThat(term.currentLine(), isEmptyString());
assertThat(term.cursorPosition(), is(pos));
}

@Test
public void testSelectionFeature2() throws InterruptedException {
XTermElement term = $(XTermElement.class).first();

term.write("abcd");
pos = term.cursorPosition();
Position pos = term.cursorPosition();

// select to home, delete
term.sendKeys(Keys.SHIFT, Keys.HOME);
Expand All @@ -80,9 +84,16 @@ public void testSelectionFeature() throws InterruptedException {
term.sendKeys(Keys.DELETE);
assertThat(term.currentLine(), isEmptyString());
assertThat(term.cursorPosition(), is(pos.advance(-4, 0)));
}

@Test
public void testSelectionFeature3() throws InterruptedException {
XTermElement term = $(XTermElement.class).first();

// select to end, delete
term.write("abcd");
Position pos = term.cursorPosition();

// select to end, delete
term.sendKeys(Keys.HOME);
pos = term.cursorPosition();
term.sendKeys(Keys.SHIFT, Keys.END);
Expand All @@ -91,7 +102,11 @@ public void testSelectionFeature() throws InterruptedException {
term.sendKeys(Keys.DELETE);
assertThat(term.currentLine(), isEmptyString());
assertThat(term.cursorPosition(), is(pos));
}

@Test
public void testSelectionFeature4() throws InterruptedException {
XTermElement term = $(XTermElement.class).first();
String text = makeFullLine(term, true) + makeFullLine(term, false) + makeFullLine(term, false);

// select to home, delete (wrapping)
Expand All @@ -101,7 +116,12 @@ public void testSelectionFeature() throws InterruptedException {
assertThat(term.getSelection(), is(text));
term.sendKeys(Keys.DELETE);
assertThat(term.currentLine(), isEmptyString());
}

@Test
public void testSelectionFeature5() throws InterruptedException {
XTermElement term = $(XTermElement.class).first();
String text = makeFullLine(term, true) + makeFullLine(term, false) + makeFullLine(term, false);
// select to end, delete (wrapping)
term.write(text);
assertThat(term.currentLine(), is(text));
Expand All @@ -110,7 +130,6 @@ public void testSelectionFeature() throws InterruptedException {
assertThat(term.getSelection(), is(text));
term.sendKeys(Keys.DELETE);
assertThat(term.currentLine(), isEmptyString());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* XTerm Console Addon
* %%
* Copyright (C) 2020 - 2023 Flowing Code
* Copyright (C) 2020 - 2026 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -86,6 +86,11 @@ public void setPrompt(String value) {
@Override
public void sendKeys(CharSequence... keysToSend) {
input.sendKeys(keysToSend);
// Wait for terminal to process writes by using a write callback
getCommandExecutor().getDriver().executeAsyncScript("""
var callback = arguments[arguments.length - 1];
arguments[0].terminal.write('', callback);
""", this);
}

@Override
Expand Down