mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
cleanup: organize PresentationTest test data
This commit is contained in:
+53
-32
@@ -6,43 +6,64 @@ import com.intellij.ide.ui.UISettingsState;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
|
||||
public class PresentationTest extends LightPlatformTestCase {
|
||||
private final String[] inputTextsUnderscores = new String[]{"No mnemonic", "_First char",
|
||||
"S_econd char", "Pre-last and not unique ch_ar", "Last cha_r", "Too late_", "Do__uble", "Dou_&ble",
|
||||
"Complete double__", "Complete double_&", "Repea_te_d", "Re_peate&d", "Run 'test__1' with Co&verage"
|
||||
/*,
|
||||
"Alphanumeric only _! _@ _# _$ _% _^ _& _* _( _) _- __ _= _+ _| _\\ _/ _0"*/};
|
||||
private final String[] inputTextsAmpersands = new String[]{"No mnemonic", "&First char", "S&econd char",
|
||||
"Pre-last and not unique ch&ar", "Last cha&r", "Too late&", "Do&_uble", "Dou&&ble", "Complete double&_",
|
||||
"Complete double&&", "Repea&te_d", "Re&peate&d"
|
||||
/*,
|
||||
"Alphanumeric only &! &@ &# &$ &% &^ && &* &( &) &- &_ &= &+ &| &\\ &/ &0"*/};
|
||||
private final String[] menuTexts = new String[]{"No mnemonic", "First char", "Second char",
|
||||
"Pre-last and not unique char", "Last char", "Too late", "Do_uble", "Dou&ble", "Complete double_",
|
||||
"Complete double&", "Repeate_d", "Repeate&d", "Run 'test_1' with Coverage"};
|
||||
private final int[] mnemonics = new int[]{0, 'F', 'E', 'A', 'R', 0, 0, 0, 0, 0, 'T', 'P', 'V'};
|
||||
private final int[] indeces = new int[]{-1, 0, 1, 26, 8, -1, -1, -1, -1, -1, 5, 2, 20};
|
||||
private final String[] fullMenuTexts = new String[]{"No mnemonic", "_First char", "S_econd char",
|
||||
"Pre-last and not unique ch_ar", "Last cha_r", "Too late", "Do_uble", "Dou&ble", "Complete double_",
|
||||
"Complete double&", "Repea_te_d", "Re_peate&d", "Run 'test_1' with Co_verage"};
|
||||
private final Data[] data = new Data[]{
|
||||
new Data("No mnemonic", "No mnemonic", "No mnemonic", "No mnemonic", 0, -1),
|
||||
new Data("_First char", "&First char", "First char", "_First char", 'F', 0),
|
||||
new Data("S_econd char", "S&econd char", "Second char", "S_econd char", 'E', 1),
|
||||
new Data("Pre-last and not unique ch_ar", "Pre-last and not unique ch&ar", "Pre-last and not unique char", "Pre-last and not unique ch_ar", 'A', 26),
|
||||
new Data("Last cha_r", "Last cha&r", "Last char", "Last cha_r", 'R', 8),
|
||||
new Data("Too late_", "Too late&", "Too late", "Too late", 0, -1),
|
||||
new Data("Do__uble", "Do&_uble", "Do_uble", "Do_uble", 0, -1),
|
||||
new Data("Dou_&ble", "Dou&&ble", "Dou&ble", "Dou&ble", 0, -1),
|
||||
new Data("Complete double__", "Complete double&_", "Complete double_", "Complete double_", 0, -1),
|
||||
new Data("Complete double_&", "Complete double&&", "Complete double&", "Complete double&", 0, -1),
|
||||
new Data("Repea_te_d", "Repea&te_d", "Repeate_d", "Repea_te_d", 'T', 5),
|
||||
new Data("Re_peate&d", "Re&peate&d", "Repeate&d", "Re_peate&d", 'P', 2),
|
||||
new Data("Run 'test__1' with Co_verage", "Run 'test__1' with Co&verage", "Run 'test_1' with Coverage", "Run 'test_1' with Co_verage", 'V', 20)
|
||||
};
|
||||
|
||||
private static class Data {
|
||||
public final String inputTextsUnderscore;
|
||||
public final String inputTextsAmpersand;
|
||||
public final String menuText;
|
||||
public final String fullMenuText;
|
||||
public final int mnemonic;
|
||||
public final int index;
|
||||
|
||||
private Data(String inputTextsUnderscore,
|
||||
String inputTextsAmpersand,
|
||||
String menuText,
|
||||
String fullMenuText,
|
||||
int mnemonic,
|
||||
int index) {
|
||||
this.inputTextsUnderscore = inputTextsUnderscore;
|
||||
this.inputTextsAmpersand = inputTextsAmpersand;
|
||||
this.menuText = menuText;
|
||||
this.mnemonic = mnemonic;
|
||||
this.index = index;
|
||||
this.fullMenuText = fullMenuText;
|
||||
}
|
||||
}
|
||||
|
||||
public void testPresentationSetText() {
|
||||
for (int i = 0; i < inputTextsUnderscores.length; i++) {
|
||||
for (Data testCase : data) {
|
||||
Presentation p = new Presentation();
|
||||
p.setText(inputTextsUnderscores[i]);
|
||||
assertEquals(menuTexts[i], p.getText());
|
||||
assertEquals(mnemonics[i], p.getMnemonic());
|
||||
assertEquals(indeces[i], p.getDisplayedMnemonicIndex());
|
||||
assertEquals(fullMenuTexts[i], p.getTextWithMnemonic());
|
||||
p.setText(testCase.inputTextsUnderscore);
|
||||
assertEquals(testCase.menuText, p.getText());
|
||||
assertEquals(testCase.mnemonic, p.getMnemonic());
|
||||
assertEquals(testCase.index, p.getDisplayedMnemonicIndex());
|
||||
assertEquals(testCase.fullMenuText, p.getTextWithMnemonic());
|
||||
}
|
||||
for (int i = 0; i < inputTextsAmpersands.length; i++) {
|
||||
Presentation p = new Presentation();
|
||||
p.setText(inputTextsAmpersands[i]);
|
||||
assertEquals(menuTexts[i], p.getText());
|
||||
assertEquals(mnemonics[i], p.getMnemonic());
|
||||
assertEquals(indeces[i], p.getDisplayedMnemonicIndex());
|
||||
assertEquals(fullMenuTexts[i], p.getTextWithMnemonic());
|
||||
|
||||
assertTrue(menuTexts[i].length() > p.getDisplayedMnemonicIndex());
|
||||
for (Data testCase : data) {
|
||||
Presentation p = new Presentation();
|
||||
p.setText(testCase.inputTextsAmpersand);
|
||||
assertEquals(testCase.menuText, p.getText());
|
||||
assertEquals(testCase.mnemonic, p.getMnemonic());
|
||||
assertEquals(testCase.index, p.getDisplayedMnemonicIndex());
|
||||
assertEquals(testCase.fullMenuText, p.getTextWithMnemonic());
|
||||
|
||||
assertTrue(testCase.menuText.length() > p.getDisplayedMnemonicIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user