-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kay Werndli
committed
Apr 23, 2024
1 parent
247d90b
commit 6f2f238
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
console/src/test/java/org/jline/widget/TailTipWidgetsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.jline.widget; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
|
||
import org.jline.reader.LineReader; | ||
import org.jline.reader.impl.LineReaderImpl; | ||
import org.jline.terminal.Terminal; | ||
import org.jline.terminal.impl.DumbTerminal; | ||
import org.jline.utils.InfoCmp.Capability; | ||
import org.jline.utils.Status; | ||
import org.jline.widget.TailTipWidgets.TipType; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public final class TailTipWidgetsTest { | ||
|
||
/** A simple extension of {@link DumbTerminal} doing the minimal amount of work so that a {@link Status} constructed | ||
* from it is "supported". */ | ||
private static final class SupportedDumbTerminal extends DumbTerminal { | ||
private SupportedDumbTerminal() throws IOException { | ||
super(new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream()); | ||
strings.put(Capability.change_scroll_region, ""); | ||
strings.put(Capability.save_cursor, ""); | ||
strings.put(Capability.restore_cursor, ""); | ||
strings.put(Capability.cursor_address, ""); | ||
} | ||
} | ||
|
||
/** Subclass of {@link Status} exposing the {@code supported} field. For testing only. */ | ||
private static final class TestStatus extends Status { | ||
private TestStatus(Terminal terminal) { | ||
super(terminal); | ||
} | ||
private boolean isSupported() { return supported; } | ||
} | ||
|
||
/** A dummy {@link LineReader} that's immediately resized to 0x0. */ | ||
private static final class ZeroSizeLineReader extends LineReaderImpl { | ||
private ZeroSizeLineReader(Terminal terminal) throws IOException { | ||
super(terminal); | ||
display.resize(0, 0); | ||
} | ||
} | ||
|
||
@Test | ||
public void enableTest() throws Exception { | ||
Terminal terminal = new SupportedDumbTerminal(); | ||
assertTrue(new TestStatus(terminal).isSupported()); | ||
LineReader reader = new ZeroSizeLineReader(terminal); | ||
new TailTipWidgets(reader, __ -> null, 1, TipType.COMBINED).enable(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters