IDEA-206761 ui: fix Presentation copying

A better fix for IDEA-85566, as `getTextWithMnemonic()`
now properly escapes returned value.
This commit is contained in:
Aleksey Pivovarov
2019-02-06 16:23:12 +03:00
parent 7c79420970
commit c0496f3a64
2 changed files with 22 additions and 2 deletions
@@ -354,7 +354,7 @@ public final class Presentation implements Cloneable {
if (!Objects.equals(myText, presentation.myText) ||
myDisplayedMnemonicIndex != presentation.myDisplayedMnemonicIndex ||
myMnemonic != presentation.myMnemonic) {
setText(presentation.getTextWithMnemonic(), presentation.myDisplayedMnemonicIndex > -1);
setText(presentation.getTextWithMnemonic());
}
setDescription(presentation.getDescription());
setIcon(presentation.getIcon());
@@ -46,7 +46,7 @@ public class PresentationTest extends LightPlatformTestCase {
}
}
public void testPresentationSetText() {
public void testSetTextWithUnderscores() {
for (Data testCase : data) {
Presentation p = new Presentation();
p.setText(testCase.inputTextsUnderscore);
@@ -55,7 +55,9 @@ public class PresentationTest extends LightPlatformTestCase {
assertEquals(testCase.index, p.getDisplayedMnemonicIndex());
assertEquals(testCase.fullMenuText, p.getTextWithMnemonic());
}
}
public void testSetTextWithAmpersands() {
for (Data testCase : data) {
Presentation p = new Presentation();
p.setText(testCase.inputTextsAmpersand);
@@ -66,7 +68,9 @@ public class PresentationTest extends LightPlatformTestCase {
assertTrue(testCase.menuText.length() > p.getDisplayedMnemonicIndex());
}
}
public void testGetTextWithMnemonic() {
for (Data testCase : data) {
Presentation p1 = new Presentation();
p1.setText(testCase.inputTextsUnderscore);
@@ -78,7 +82,9 @@ public class PresentationTest extends LightPlatformTestCase {
assertEquals(p1.getMnemonic(), p2.getMnemonic());
assertEquals(p1.getDisplayedMnemonicIndex(), p2.getDisplayedMnemonicIndex());
}
}
public void testMnemonicCharacters() {
for (Data testCase : data) {
Presentation p1 = new Presentation();
p1.setText(testCase.inputTextsAmpersand);
@@ -91,6 +97,20 @@ public class PresentationTest extends LightPlatformTestCase {
}
}
public void testPresentationCopying() {
for (Data testCase : data) {
Presentation p1 = new Presentation();
p1.setText(testCase.inputTextsUnderscore);
Presentation p2 = new Presentation();
p2.copyFrom(p1);
assertEquals(p1.getText(), p2.getText());
assertEquals(p1.getMnemonic(), p2.getMnemonic());
assertEquals(p1.getDisplayedMnemonicIndex(), p2.getDisplayedMnemonicIndex());
}
}
@Override
public void setUp() throws Exception {
super.setUp();