use of com.intellij.refactoring.rename.DirectoryAsPackageRenameHandler in project android by JetBrains.
the class RenameTest method sourceRoot.
@Test
public void sourceRoot() throws Exception {
guiTest.importSimpleApplication();
final Project project = guiTest.ideFrame().getProject();
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots();
for (final VirtualFile sourceRoot : sourceRoots) {
PsiDirectory directory = GuiQuery.getNonNull(() -> PsiManager.getInstance(project).findDirectory(sourceRoot));
for (final RenameHandler handler : Extensions.getExtensions(RenameHandler.EP_NAME)) {
if (handler instanceof DirectoryAsPackageRenameHandler) {
final RenameDialogFixture renameDialog = RenameDialogFixture.startFor(directory, handler, guiTest.robot());
assertFalse(renameDialog.warningExists(null));
renameDialog.setNewName(renameDialog.getNewName() + 1);
// 'Rename dialog' show a warning asynchronously to the text change, that's why we wait here for the
// warning to appear
Wait.seconds(1).expecting("error text to appear").until(() -> renameDialog.warningExists(AndroidBundle.message("android.refactoring.gradle.warning.rename.source.root")));
renameDialog.clickCancel();
return;
}
}
}
}
}
Aggregations