Search in sources :

Example 1 with TestInputDialog

use of com.intellij.openapi.ui.TestInputDialog in project intellij-community by JetBrains.

the class RenameModuleTest method testRename.

public void testRename() throws Exception {
    String moduleName = "module";
    String newModuleName = "moduleA";
    Module module = createModule(moduleName);
    assertEquals(moduleName, module.getName());
    MapDataContext context = new MapDataContext();
    context.put(LangDataKeys.MODULE_CONTEXT, module);
    final RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(context);
    assertNotNull(renameHandler);
    Messages.setTestInputDialog(new TestInputDialog() {

        @Override
        public String show(String message) {
            return null;
        }

        @Override
        public String show(String message, @Nullable InputValidator validator) {
            assertNotNull(validator);
            boolean canClose = validator.canClose(newModuleName);
            assertTrue(canClose);
            return newModuleName;
        }
    });
    renameHandler.invoke(myProject, PsiElement.EMPTY_ARRAY, context);
    assertEquals(newModuleName, module.getName());
}
Also used : MapDataContext(com.intellij.testFramework.MapDataContext) InputValidator(com.intellij.openapi.ui.InputValidator) RenameHandler(com.intellij.refactoring.rename.RenameHandler) TestInputDialog(com.intellij.openapi.ui.TestInputDialog) Module(com.intellij.openapi.module.Module)

Aggregations

Module (com.intellij.openapi.module.Module)1 InputValidator (com.intellij.openapi.ui.InputValidator)1 TestInputDialog (com.intellij.openapi.ui.TestInputDialog)1 RenameHandler (com.intellij.refactoring.rename.RenameHandler)1 MapDataContext (com.intellij.testFramework.MapDataContext)1