Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 112f29c

Browse files
committedDec 31, 2020
Add integration test to cover #2114
1 parent c0d538c commit 112f29c

File tree

2 files changed

+107
-8
lines changed

2 files changed

+107
-8
lines changed
 
+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
open Oni_Model;
2+
open Oni_IntegrationTestLib;
3+
open EditorCoreTypes;
4+
5+
runTest(~name="InputRemapMotionTest (#2114)", (dispatch, wait, runEffects) => {
6+
wait(~name="Initial mode is normal", (state: State.t) =>
7+
Selectors.mode(state) |> Vim.Mode.isNormal
8+
);
9+
10+
let testFile = getAssetPath("some-test-file.txt");
11+
// Open an erroneous CSS file - verify we get some diagnostics
12+
dispatch(Actions.OpenFileByPath(testFile, None, None));
13+
14+
wait(~name="buffer load", (state: State.t) => {
15+
switch (Selectors.getActiveBuffer(state)) {
16+
| Some(buffer) => Oni_Core.Buffer.getNumberOfLines(buffer) > 2
17+
| None => false
18+
}
19+
});
20+
21+
// #2114 - remap hjkl -> jklm
22+
dispatch(
23+
VimExecuteCommand({allowAnimation: true, command: "nnoremap j h "}),
24+
);
25+
runEffects();
26+
27+
dispatch(
28+
VimExecuteCommand({allowAnimation: true, command: "nnoremap l k "}),
29+
);
30+
runEffects();
31+
32+
dispatch(
33+
VimExecuteCommand({allowAnimation: true, command: "nnoremap m l "}),
34+
);
35+
runEffects();
36+
37+
dispatch(
38+
VimExecuteCommand({allowAnimation: true, command: "nnoremap k j "}),
39+
);
40+
runEffects();
41+
42+
let input = key => {
43+
let modifiers = EditorInput.Modifiers.none;
44+
45+
let keyPress: EditorInput.KeyPress.t =
46+
EditorInput.KeyPress.physicalKey(
47+
~key=EditorInput.Key.Character(key),
48+
~modifiers,
49+
);
50+
let time = Revery.Time.now();
51+
52+
dispatch(Model.Actions.KeyDown({key: keyPress, scancode: 1, time}));
53+
dispatch(Model.Actions.KeyUp({key: keyPress, scancode: 1, time}));
54+
runEffects();
55+
};
56+
57+
let waitForCursorPosition = bytePosition => {
58+
wait(
59+
~name="Verify cursor is at:" ++ BytePosition.show(bytePosition),
60+
(state: State.t) => {
61+
let cursorPosition =
62+
state.layout
63+
|> Feature_Layout.activeEditor
64+
|> Feature_Editor.Editor.getPrimaryCursorByte;
65+
66+
cursorPosition == bytePosition;
67+
},
68+
);
69+
};
70+
71+
waitForCursorPosition(
72+
BytePosition.{line: LineNumber.zero, byte: ByteIndex.zero},
73+
);
74+
75+
// Move down, jklm style
76+
input('k');
77+
waitForCursorPosition(
78+
BytePosition.{line: LineNumber.(zero + 1), byte: ByteIndex.zero},
79+
);
80+
81+
// Move right, jklm style
82+
input('m');
83+
waitForCursorPosition(
84+
BytePosition.{line: LineNumber.(zero + 1), byte: ByteIndex.(zero + 1)},
85+
);
86+
87+
// Move up, jklm style
88+
input('l');
89+
waitForCursorPosition(
90+
BytePosition.{line: LineNumber.(zero), byte: ByteIndex.(zero + 1)},
91+
);
92+
93+
// Move left, jklm style
94+
input('j');
95+
waitForCursorPosition(
96+
BytePosition.{line: LineNumber.(zero), byte: ByteIndex.(zero)},
97+
);
98+
});

‎integration_test/dune

+9-8
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
ExCommandKeybindingNormTest ExtConfigurationChangedTest
99
ExtHostBufferOpenTest ExtHostBufferUpdatesTest ExtHostCompletionTest
1010
ExtHostDefinitionTest FileWatcherTest KeybindingsInvalidJsonTest
11-
KeySequenceJJTest InputIgnoreTest InputContextKeysTest LanguageCssTest
12-
LanguageTypeScriptTest LineEndingsLFTest LineEndingsCRLFTest
13-
QuickOpenEventuallyCompletesTest SearchShowClearHighlightsTest
14-
SyntaxServer SyntaxServerCloseTest SyntaxServerMessageExceptionTest
15-
SyntaxServerParentPidTest SyntaxServerParentPidCorrectTest
16-
SyntaxServerReadExceptionTest Regression1671Test Regression2349EnewTest
11+
KeySequenceJJTest InputIgnoreTest InputContextKeysTest
12+
InputRemapMotionTest LanguageCssTest LanguageTypeScriptTest
13+
LineEndingsLFTest LineEndingsCRLFTest QuickOpenEventuallyCompletesTest
14+
SearchShowClearHighlightsTest SyntaxServer SyntaxServerCloseTest
15+
SyntaxServerMessageExceptionTest SyntaxServerParentPidTest
16+
SyntaxServerParentPidCorrectTest SyntaxServerReadExceptionTest
17+
Regression1671Test Regression2349EnewTest
1718
RegressionCommandLineNoCompletionTest RegressionFontFallbackTest
1819
RegressionFileModifiedIndicationTest RegressionNonExistentDirectory
1920
RegressionVspEmptyInitialBufferTest RegressionVspEmptyExistingBufferTest
@@ -40,8 +41,8 @@
4041
ExtHostBufferUpdatesTest.exe ExtHostCompletionTest.exe
4142
ExtHostDefinitionTest.exe FileWatcherTest.exe
4243
KeybindingsInvalidJsonTest.exe KeySequenceJJTest.exe InputIgnoreTest.exe
43-
InputContextKeysTest.exe LanguageCssTest.exe LanguageTypeScriptTest.exe
44-
LineEndingsCRLFTest.exe LineEndingsLFTest.exe
44+
InputContextKeysTest.exe InputRemapMotionTest.exe LanguageCssTest.exe
45+
LanguageTypeScriptTest.exe LineEndingsCRLFTest.exe LineEndingsLFTest.exe
4546
QuickOpenEventuallyCompletesTest.exe Regression1671Test.exe
4647
Regression2349EnewTest.exe RegressionCommandLineNoCompletionTest.exe
4748
RegressionFileModifiedIndicationTest.exe RegressionFontFallbackTest.exe

0 commit comments

Comments
 (0)