use of com.android.tools.idea.gradle.projectView.AndroidTreeStructureProvider in project android by JetBrains.
the class GradleSyncTest method jdkNodeModificationInProjectView.
@Test
public void jdkNodeModificationInProjectView() throws IOException {
guiTest.importSimpleApplication();
Project project = guiTest.ideFrame().getProject();
AndroidTreeStructureProvider treeStructureProvider = null;
TreeStructureProvider[] treeStructureProviders = Extensions.getExtensions(TreeStructureProvider.EP_NAME, project);
for (TreeStructureProvider current : treeStructureProviders) {
if (current instanceof AndroidTreeStructureProvider) {
treeStructureProvider = (AndroidTreeStructureProvider) current;
}
}
List<AbstractTreeNode> changedNodes = Lists.newArrayList();
treeStructureProvider.addChangeListener((parent, newChildren) -> changedNodes.add(parent));
ProjectViewFixture projectView = guiTest.ideFrame().getProjectView();
ProjectViewFixture.PaneFixture projectPane = projectView.selectProjectPane();
ProjectViewFixture.NodeFixture externalLibrariesNode = projectPane.findExternalLibrariesNode();
projectPane.expand();
// 2 nodes should be changed: JDK (remove all children except rt.jar) and rt.jar (remove all children except packages 'java' and
// 'javax'.
Wait.seconds(1).expecting("'Project View' to be customized").until(() -> changedNodes.size() == 2);
List<ProjectViewFixture.NodeFixture> libraryNodes = externalLibrariesNode.getChildren();
ProjectViewFixture.NodeFixture jdkNode = null;
// Find JDK node.
for (ProjectViewFixture.NodeFixture node : libraryNodes) {
if (node.isJdk()) {
jdkNode = node;
break;
}
}
ProjectViewFixture.NodeFixture finalJdkNode = jdkNode;
Wait.seconds(1).expecting("JDK node to be customized").until(() -> finalJdkNode.getChildren().size() == 1);
// Now we verify that the JDK node has only these children:
// - jdk
// - rt.jar
// - java
// - javax
List<ProjectViewFixture.NodeFixture> jdkChildren = jdkNode.getChildren();
assertThat(jdkChildren).hasSize(1);
ProjectViewFixture.NodeFixture rtJarNode = jdkChildren.get(0);
rtJarNode.requireDirectory("rt.jar");
List<ProjectViewFixture.NodeFixture> rtJarChildren = rtJarNode.getChildren();
assertThat(rtJarChildren).hasSize(2);
rtJarChildren.get(0).requireDirectory("java");
rtJarChildren.get(1).requireDirectory("javax");
}
Aggregations