StateTree { public boolean isActive(StateNode node) { boolean isVisible = isVisible(node); if (!isVisible || node.getParent() == null) { return isVisible; } return isActive(node.getParent()); } StateTree(Registry registry); void setUpdateInProgress(boolean updateInProgress); boolean isUpdateInProgress(); final void registerNode(StateNode node); void unregisterNode(StateNode node); void prepareForResync(); StateNode getNode(int id); StateNode getRootNode(); void sendEventToServer(StateNode node, String eventType,
            JsonObject eventData); void sendNodePropertySyncToServer(MapProperty property); void sendTemplateEventToServer(StateNode node, String methodName,
            JsArray<?> argsArray, int promiseId); void sendExistingElementAttachToServer(StateNode parent,
            int requestedId, int assignedId, String tagName, int index); void sendExistingElementWithIdAttachToServer(StateNode parent,
            int requestedId, int assignedId, String id); Registry getRegistry(); boolean isVisible(StateNode node); boolean isActive(StateNode node);  }
@Test public void isActive_nodeIsVisibleAndNoParent_nodeIsActive() { TestVisibilityTree tree = new TestVisibilityTree(); StateNode stateNode = new StateNode(7, tree); tree.isVisible = true; Assert.assertTrue(tree.isActive(stateNode)); }
@Test public void isActive_nodeIsInvisibleAndNoParent_nodeIsActive() { TestVisibilityTree tree = new TestVisibilityTree(); StateNode stateNode = new StateNode(7, tree); tree.isVisible = false; Assert.assertFalse(tree.isActive(stateNode)); }
@Test public void isActive_nodeIsVisibleAndVisibleParent_nodeIsActive() { TestVisibilityTree tree = new TestVisibilityTree(); StateNode stateNode = new StateNode(7, tree); StateNode parent = new StateNode(8, tree); stateNode.setParent(parent); tree.isVisible = true; Assert.assertTrue(tree.isActive(stateNode)); }
@Test public void isActive_nodeIsVisibleAndInvisibleParent_nodeIsNotActive() { StateNode stateNode = new StateNode(7, tree); StateNode parent = new StateNode(8, tree); stateNode.setParent(parent); TestVisibilityTree tree = new TestVisibilityTree() { @Override public boolean isVisible(StateNode node) { return parent != node; } }; Assert.assertFalse(tree.isActive(stateNode)); }