use of net.heartsome.test.swtbot.widgets.HsSWTBotStyledText in project translationstudio8 by heartsome.
the class SplitSegment method splitAt.
/**
* 在指定文本段的 index 处分割文本段
* @param xe
* @param segNum
* @param splitIndex
*/
public static void splitAt(XlfEditor xe, int segNum, int splitIndex) {
// 判断该文本段是否可编辑
String rowID = xe.rowIdOfSegNum(segNum);
XliffUtil xu = new XliffUtil(rowID);
SegmentAsserts.segIsEditable(xu);
// 进入编辑模式,方便读取样式文本框中的内容
xe.enterEditModeSource(segNum);
// 在实际进行分割文本段之前,得到原文本段的 tuid 和分割后两个文本段的预期内容,
// 用以在分割后验证得到的文本段内容是否符合预期。
String tuid = xe.tuidOfSegNum(segNum);
// 判断给定的分割点是否可分割,然后在两个分支中分别验证结果
HsSWTBotStyledText st = xe.getStyledText();
if (SegmentAsserts.indexIsSplitable(st, splitIndex)) {
String[] expectedText = st.splitTextAt(splitIndex);
// 将光标移到指定位置,并点击相应的菜单项进行分割
xe.navigateToIndex(splitIndex);
ts.menuTranslationSplitSegment().click();
xe.getNatTable();
// 确认文本段已按预期分割
SegmentAsserts.segIsSplit(tuid, expectedText, xe.getSplitXliffUtil(expectedText));
System.out.println("[Passed] Segment No.\"" + segNum + "\" was successfully split at Index \"" + splitIndex + "\".");
} else {
String expectedText = st.getText();
String position;
// 将光标移到指定位置,并点击相应的菜单项进行分割
if (splitIndex <= 0) {
position = "Beginning.";
xe.navigateToBegining();
} else {
position = "End.";
xe.navigateToEnd();
}
ts.menuTranslationSplitSegment().click();
// 弹出提示信息
InformationDialog dialog = new InformationDialog(1, TsUIConstants.getString("msgPlaceCursorToSplit"));
dialog.lblMessage().isVisible();
dialog.btnOK().click();
xe.getNatTable();
// 确认文本段没有被分割
SegmentAsserts.segNotSplit(tuid, expectedText, xu);
System.out.println("[Passed] Segment No.\"" + segNum + "\" was not split at the " + position);
}
}
use of net.heartsome.test.swtbot.widgets.HsSWTBotStyledText in project translationstudio8 by heartsome.
the class XlfEditor method navigateAfter.
/**
* 将光标定位到指定字符串之后
* @param afterText
* 指定的字符串,光标将置于其最后一个字符之后
*/
public void navigateAfter(String afterText) {
HsSWTBotStyledText styledText = getStyledText();
Position targetPos = styledText.positionOfFollowing(afterText);
Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + afterText + "\" not found.");
styledText.navigateTo(targetPos);
}
use of net.heartsome.test.swtbot.widgets.HsSWTBotStyledText in project translationstudio8 by heartsome.
the class XlfEditor method typeTextBefore.
/**
* 在指定字符串之前输入内容
* @param beforeText
* 指定的字符串,输入的内容将在其第一个字符之前
* @param text
* 要输入的内容
*/
public void typeTextBefore(String beforeText, String text) {
HsSWTBotStyledText styledText = getStyledText();
Position targetPos = styledText.positionOf(beforeText);
Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + beforeText + "\" not found.");
styledText.typeText(targetPos.line, targetPos.column, text);
}
use of net.heartsome.test.swtbot.widgets.HsSWTBotStyledText in project translationstudio8 by heartsome.
the class XlfEditor method navigateBefore.
/**
* 将光标定位到指定字符串之前
* @param beforeText
* 指定的字符串,光标将置于其第一个字符之前
*/
public void navigateBefore(String beforeText) {
HsSWTBotStyledText styledText = getStyledText();
Position targetPos = styledText.positionOf(beforeText);
Assert.isTrue(!targetPos.equals(new Position(-1, -1)), "Text \"" + beforeText + "\" not found.");
styledText.navigateTo(targetPos);
}
use of net.heartsome.test.swtbot.widgets.HsSWTBotStyledText in project translationstudio8 by heartsome.
the class XlfEditor method navigateToEnd.
/**
* 将光标定位到文本框末 在样式文本框中移动光标到结束位置
*/
public void navigateToEnd() {
HsSWTBotStyledText styledText = getStyledText();
int length = styledText.getText().length();
styledText.navigateTo(styledText.getPositionByIndex(length));
}
Aggregations