fix: generated selector code is wrong for exists and waitFor

This commit is contained in:
hyb1996
2018-03-15 19:30:29 +08:00
parent 714cbd5759
commit 9679830c75
3 changed files with 10 additions and 6 deletions

View File

@@ -66,15 +66,12 @@ public class CodeGenerator {
generator.setUsingDesc(mUsingDesc);
generator.setUsingId(mUsingId);
generator.setUsingText(mUsingText);
String selector = generateCode(generator, mRoot, mTarget, 2, 2);
String selector = generateCode(generator, mRoot, mTarget, 2, 2, true);
if (selector == null)
return null;
return generateAction(selector);
}
protected String generateCode(UiSelectorGenerator generator, UiObject root, UiObject target, int maxParentLevel, int maxChildrenLevel) {
return generateCode(generator, root, target, maxParentLevel, maxChildrenLevel, true);
}
protected String generateCode(UiSelectorGenerator generator, UiObject root, UiObject target, int maxParentLevel, int maxChildrenLevel, boolean withFind) {
String selector;

View File

@@ -6,6 +6,7 @@ import com.stardust.util.Consumer;
import static com.stardust.autojs.codegeneration.CodeGenerator.FIND_ONE;
import static com.stardust.autojs.codegeneration.CodeGenerator.UNTIL_FIND;
import static com.stardust.autojs.codegeneration.CodeGenerator.WAIT_FOR;
/**
* Created by Stardust on 2017/12/7.
@@ -72,7 +73,13 @@ public class UiSelectorGenerator {
if (selector == null) {
return null;
}
return selector + (mSearchMode == FIND_ONE ? ".findOne()" : ".untilFind()");
if (mSearchMode == FIND_ONE) {
return selector + ".findOne()";
} else if (mSearchMode == UNTIL_FIND) {
return selector + ".untilFind()";
} else {
return selector.toString();
}
}