本文整理汇总了Java中com.musala.atmosphere.commons.util.structure.tree.Tree类的典型用法代码示例。如果您正苦于以下问题:Java Tree类的具体用法?Java Tree怎么用?Java Tree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Tree类属于com.musala.atmosphere.commons.util.structure.tree包,在下文中一共展示了Tree类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.musala.atmosphere.commons.util.structure.tree.Tree; //导入依赖的package包/类
/**
* Produces XML representation of the provided {@link AccessibilityElement accessibility elements} hierarchy,
* compatible with the Android`s AccessibilityNodeInfo XML dump (and the screen dump as it is the same thing).
*
* @param hierarchy
* - the hierarchy of {@link AccessibilityElement elements} as a tree
* @return the hierarchy as an XML document
*/
public static String serialize(Tree<AccessibilityElement> hierarchy) {
AccessibilityXmlSerializer serializer = new AccessibilityXmlSerializer();
serializer.startTag("hierarchy");
// if the hierarchy starts to contain information about the rotation this should be changed
serializer.addAttribute("rotation", "0");
serialize(hierarchy.getRoot(), serializer);
serializer.endTag("hierarchy");
return serializer.xmlBuilder.toString();
}
示例2: handle
import com.musala.atmosphere.commons.util.structure.tree.Tree; //导入依赖的package包/类
@Override
public Object handle(Object[] args) throws Exception {
boolean visibleOnly = (Boolean) args[0];
AccessibilityHelper helper = AccessibilityFactory.getAccessibilityHelper();
AccessibilityNodeInfo root = helper.getRootInActiveWindow();
Tree<AccessibilityElement> tree = TreeBuilder.buildTree(root, visibleOnly);
return TreeBuilder.buildTree(root, visibleOnly);
}
示例3: resolve
import com.musala.atmosphere.commons.util.structure.tree.Tree; //导入依赖的package包/类
private Type resolve(JsonElement typeElement, RoutingAction routingAction) {
Type type = null;
switch (routingAction) {
case EXECUTE_SHELL_COMMAND_SEQUENCE:
type = new TypeToken<List<String>>() {}.getType();
break;
case GET_UI_TREE:
type = new TypeToken<Tree<AccessibilityElement>>() {}.getType();
break;
case GET_UI_ELEMENTS:
case GET_CHILDREN:
case EXECUTE_XPATH_QUERY_ON_LOCAL_ROOT:
case EXECUTE_XPATH_QUERY:
type = new TypeToken<List<AccessibilityElement>>() {}.getType();
break;
case GET_LOGCAT_BUFFER:
type = new TypeToken<List<Pair<Integer, String>>>() {}.getType();
break;
case GET_WEB_VIEWS:
type = new TypeToken<Set<String>>() {}.getType();
break;
case FIND_WEB_ELEMENT:
type = new TypeToken<Map<String, Object>>() {}.getType();
break;
case FIND_WEB_ELEMENTS:
type = new TypeToken<List<Map<String, Object>>>() {}.getType();
break;
case WEB_ELEMENT_ACTION:
boolean isEmptyType = !typeElement.equals(new JsonObject());
boolean isPair = typeElement.getAsString().equals(Pair.class.getName());
if (isEmptyType && isPair) {
type = new TypeToken<Pair<Integer, Integer>>() {}.getType();
break;
}
default:
type = defaultResolver(typeElement);
break;
}
return type;
}
示例4: treeOfAccessibilityElementsResponseDataDeserializationTest
import com.musala.atmosphere.commons.util.structure.tree.Tree; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void treeOfAccessibilityElementsResponseDataDeserializationTest() {
// setup elements
AccessibilityElement rootElement = new AccessibilityElement();
AccessibilityElement firstChildElement = new AccessibilityElement();
AccessibilityElement secondChildElement = new AccessibilityElement();
AccessibilityElement childOfFirstChildElement = new AccessibilityElement();
Bounds expectedBounds = new Bounds(new Point(0, 0), new Point(4, 4));
rootElement.setPath(TestConst.TEST_PATH);
firstChildElement.setText("first_child_text");
secondChildElement.setEnabled(true);
childOfFirstChildElement.setBounds(expectedBounds);
// setup the nodes
Node<AccessibilityElement> firstChildNode = new Node<AccessibilityElement>(firstChildElement);
Node<AccessibilityElement> secondChildNode = new Node<AccessibilityElement>(secondChildElement);
Node<AccessibilityElement> childOfFirstChildNode = new Node<AccessibilityElement>(childOfFirstChildElement);
firstChildNode.addChild(childOfFirstChildNode);
// setup the tree
Tree<AccessibilityElement> tree = new Tree<AccessibilityElement>(rootElement);
tree.getRoot().addChild(firstChildNode);
tree.getRoot().addChild(secondChildNode);
Tree<AccessibilityElement> deserializedResponseData = (Tree<AccessibilityElement>) getExpectedResponseData(RoutingAction.GET_UI_TREE,
tree);
String rootActualPath = deserializedResponseData.getRoot().getData().getPath();
int rootActualChildrenCount = deserializedResponseData.getRoot().getChildCount();
Node<AccessibilityElement> actualFirstChild = deserializedResponseData.getRoot().getChildren().get(0);
Node<AccessibilityElement> actualSecondChild = deserializedResponseData.getRoot().getChildren().get(1);
String firstChildActualText = actualFirstChild.getData().getText();
Boolean secondChildActualisEnabled = actualSecondChild.getData().isEnabled();
Bounds actualBounds = actualFirstChild.getChild(0).getData().getBounds();
// asserts
Assert.assertEquals(TestConst.TEST_PATH, rootActualPath);
Assert.assertEquals(2, rootActualChildrenCount);
Assert.assertEquals("first_child_text", firstChildActualText);
Assert.assertTrue(secondChildActualisEnabled);
Assert.assertEquals(expectedBounds, actualBounds);
}
示例5: getUiTree
import com.musala.atmosphere.commons.util.structure.tree.Tree; //导入依赖的package包/类
/**
* Sends a request for building a tree representation of the active screen of the device.
*
* @param visibleOnly
* - if <code>true</code> only the visible nodes will be used; if <code>false</code> all nodes will be used
* @return a tree representation of the screen
* @throws CommandFailedException
* if request fails
*/
@SuppressWarnings("unchecked")
public Tree<AccessibilityElement> getUiTree(boolean visibleOnly) throws CommandFailedException {
Object[] arguments = new Object[] {visibleOnly};
return (Tree<AccessibilityElement>) requestActionWithResponse(UIAutomatorRequest.GET_UI_TREE, arguments);
}
示例6: buildTree
import com.musala.atmosphere.commons.util.structure.tree.Tree; //导入依赖的package包/类
/**
* Builds a {@link Tree tree} with {@link AccessibilityElement} based on the given root
* {@link AccessibilityNodeInfo}.
*
* @param root
* - the root {@link AccessibilityNodeInfo} on which the {@link Tree tree} is being built
* @param visibleOnly
* - if <code>true</code> only the visible nodes will be used; if <code>false</code> all nodes will be used
* @return a {@link Tree tree} with {@link AccessibilityElement} based on the given root
* {@link AccessibilityNodeInfo}
*/
public static Tree<AccessibilityElement> buildTree(AccessibilityNodeInfo root, boolean visibleOnly) {
Node<AccessibilityElement> rootNode = buildNode(root, 0, visibleOnly);
Tree<AccessibilityElement> builtTree = new Tree<AccessibilityElement>(rootNode);
return builtTree;
}