Example usage for com.intellij.openapi.ui Messages setTestDialog

List of usage examples for com.intellij.openapi.ui Messages setTestDialog

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages setTestDialog.

Prototype

@TestOnly
    public static TestDialog setTestDialog(TestDialog newValue) 

Source Link

Usage

From source file:com.android.tools.idea.gradle.dependencies.GradleDependencyManagerTest.java

License:Apache License

@SuppressWarnings("unused")
public void ignore_testDependencyAarIsExplodedForLayoutLib() throws Exception {
    loadSimpleApplication();/*from   w  ww. j  av a2s.c o m*/
    List<GradleCoordinate> dependencies = Collections.singletonList(RECYCLER_VIEW_DEPENDENCY);
    GradleDependencyManager dependencyManager = GradleDependencyManager.getInstance(getProject());
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isNotEmpty();
    Messages.setTestDialog(new TestMessagesDialog(Messages.OK));
    boolean found = dependencyManager.ensureLibraryIsIncluded(myModules.getAppModule(), dependencies, null);
    assertThat(found).isTrue();
    List<ResourceItem> items = AppResourceRepository.getAppResources(myAndroidFacet, true)
            .getResourceItem(ResourceType.DECLARE_STYLEABLE, "RecyclerView");
    assertThat(items).isNotEmpty();
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isEmpty();
}

From source file:com.android.tools.idea.gradle.dependencies.GradleDependencyManagerTest.java

License:Apache License

public void testDependencyCanBeCancelledByUser() throws Exception {
    loadSimpleApplication();// w w  w  . jav a2s.c o m
    List<GradleCoordinate> dependencies = Collections.singletonList(RECYCLER_VIEW_DEPENDENCY);
    GradleDependencyManager dependencyManager = GradleDependencyManager.getInstance(getProject());
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isNotEmpty();
    Messages.setTestDialog(new TestMessagesDialog(Messages.NO));
    boolean found = dependencyManager.ensureLibraryIsIncluded(myModules.getAppModule(), dependencies, null);
    assertThat(found).isFalse();
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isNotEmpty();
}

From source file:com.android.tools.idea.gradle.project.sync.cleanup.GradleDistributionCleanUpTaskTest.java

License:Apache License

@Override
public void setUp() throws Exception {
    super.setUp();
    myTestDialog = new TestMessagesDialog(Messages.OK);
    Messages.setTestDialog(myTestDialog);

    myCleanUpTask = new GradleDistributionCleanUpTask();
}

From source file:com.android.tools.idea.testing.AndroidGradleTestCase.java

License:Apache License

@Override
protected void tearDown() throws Exception {
    try {/*from w  ww. j  av a2  s .  c om*/
        Messages.setTestDialog(TestDialog.DEFAULT);
        if (myFixture != null) {
            try {
                Project project = myFixture.getProject();
                // Since we don't really open the project, but we manually register listeners in the gradle importer
                // by explicitly calling AndroidGradleProjectComponent#configureGradleProject, we need to counteract
                // that here, otherwise the testsuite will leak
                if (AndroidProjectInfo.getInstance(project).requiresAndroidModel()) {
                    AndroidGradleProjectComponent projectComponent = AndroidGradleProjectComponent
                            .getInstance(project);
                    projectComponent.projectClosed();
                }
            } finally {
                try {
                    myFixture.tearDown();
                } catch (Exception e) {
                    LOG.warn("Failed to tear down " + myFixture.getClass().getSimpleName(), e);
                }
                myFixture = null;
            }
        }

        GradleProjectImporter.ourSkipSetupFromTest = false;

        ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
        Project[] openProjects = projectManager.getOpenProjects();
        if (openProjects.length > 0) {
            PlatformTestCase.closeAndDisposeProjectAndCheckThatNoOpenProjects(openProjects[0]);
        }
    } finally {
        try {
            assertEquals(0, ProjectManager.getInstance().getOpenProjects().length);
        } finally {
            //noinspection ThrowFromFinallyBlock
            super.tearDown();
        }
    }
}

From source file:com.hp.alm.ali.idea.IntellijTest.java

License:Apache License

@Before
public void reset() throws Exception {
    if (isIsolated()) {
        fixture = FixtureFactory.createFixture(version);
        handler = FixtureFactory.createHandler(version, fixture);
    } else {/*from www  . java2s.  com*/
        fixture = FixtureFactory.ensureFixture(version);
        handler = FixtureFactory.ensureHandler(version, fixture);
        handler.clear();
    }

    errorService = getComponent(ErrorService.class);
    entityService = getComponent(EntityService.class);
    entityListeners = new LinkedList<EntityListener>();
    getComponent(MetadataService.class).connectedTo(ServerType.NONE);
    getComponent(MetadataSimpleService.class).connectedTo(ServerType.NONE);
    testMessages = new TestMessages();
    Messages.setTestDialog(testMessages);
    testApplication = new TestApplication();
    ApplicationUtil._setApplication(testApplication);
}

From source file:com.hp.alm.ali.idea.IntellijTest.java

License:Apache License

@After
public void done() throws Throwable {
    testApplication.waitForBackgroundActivityToFinish();
    if (handler != null) {
        handler.finish();//from w  w w  .j av  a2  s .  com
    }
    Assert.assertTrue("Unhandled messages: " + testMessages.asString(), testMessages.isEmpty());
    Messages.setTestDialog(TestDialog.DEFAULT);
    List<Exception> ex = errorService._shiftErrors();
    Assert.assertTrue("Unhandled exceptions: " + ex.toString(), ex.isEmpty());
    for (EntityListener listener : entityListeners) {
        entityService.removeEntityListener(listener);
    }
    getComponent(DetailUtil.class)._restore();
    if (isIsolated()) {
        handler.getServer().stop();
    }
}

From source file:com.twitter.intellij.pants.testFramework.PantsIntegrationTestCase.java

License:Apache License

@Override
public void tearDown() throws Exception {
    // TODO thread leak either a IJ bug https://youtrack.jetbrains.com/issue/IDEA-155496
    // or a pants plugin bug https://github.com/pantsbuild/intellij-pants-plugin/issues/130
    // Temporarily ignore the following 'leaking' threads to pass CI.
    ThreadTracker.longRunningThreadCreated(ApplicationManager.getApplication(), "BaseDataReader",
            "ProcessWaitFor", "Timer");
    try {/*from  w w  w.  j a  v a2  s.c  o  m*/
        if (myCompilerTester != null) {
            myCompilerTester.tearDown();
        }

        // Kill nailgun after usage as memory on travis is limited, at a cost of slower later builds.
        killNailgun();
        cleanProjectRoot();
        Messages.setTestDialog(TestDialog.DEFAULT);
    } finally {
        super.tearDown();
        // double check.
        if (myProject != null && !myProject.isDisposed()) {
            Disposer.dispose(myProject);
        }
    }
}

From source file:org.consulo.compiler.server.Main.java

License:Apache License

public static void main(String[] args) throws Exception {
    File t = FileUtil.createTempDirectory("consulo", "data");
    System.setProperty(PathManager.PROPERTY_CONFIG_PATH, t.getAbsolutePath() + "/config");
    System.setProperty(PathManager.PROPERTY_SYSTEM_PATH, t.getAbsolutePath() + "/system");

    System.setProperty(PathManager.PROPERTY_PLUGINS_PATH, "G:\\target_for_build\\distMain\\plugins");
    System.setProperty(PathManager.PROPERTY_HOME_PATH, "G:\\target_for_build\\distMain");
    System.setProperty(FileWatcher.PROPERTY_WATCHER_DISABLED, "true");

    LOGGER.info("Data dir: " + t.getAbsolutePath());

    CompilerServerInterfaceImpl server = createServer();

    ApplicationEx app = CompilerServerApplication.createApplication();
    Messages.setTestDialog(new TestDialog() {
        @Override/*from ww w  .j  a  v  a2  s . c  o  m*/
        public int show(String message) {
            LOGGER.info(message);
            return 0;
        }
    });

    app.load(PathManager.getOptionsPath());

    setupSdk("JDK", "1.6", "I:\\Programs\\jdk6");
    setupSdk("JDK", "1.7", "I:\\Programs\\jdk7");
    setupSdk("Consulo Plugin SDK", "Consulo 1.SNAPSHOT", "G:\\target_for_build\\distMainn");

    server.compile(new CompilerClientInterface() {
        @Override
        public void addMessage(@NotNull CompilerMessageCategory category, String message, String url,
                int lineNum, int columnNum) throws RemoteException {
            LOGGER.info(category + ": " + message + ". Url: " + url);
        }

        @Override
        public void compilationFinished(boolean aborted, int errors, int warnings) throws RemoteException {
        }

        @NotNull
        @Override
        public String getProjectDir() {
            return "G:\\target_for_build\\consulo";
        }
    });
}

From source file:org.consulo.compiler.server.MainTest.java

License:Apache License

public static void main(String[] args) throws Exception {
    File t = FileUtil.createTempDirectory("consulo", "data");
    System.setProperty(PathManager.PROPERTY_CONFIG_PATH, t.getAbsolutePath() + "/config");
    System.setProperty(PathManager.PROPERTY_SYSTEM_PATH, t.getAbsolutePath() + "/system");
    //System.setProperty(PathManager.PROPERTY_CONFIG_PATH, "C:\\Users\\VISTALL\\.ConsuloData\\config");
    // System.setProperty(PathManager.PROPERTY_SYSTEM_PATH, "C:\\Users\\VISTALL\\.ConsuloData\\system");
    System.setProperty(PathManager.PROPERTY_HOME_PATH,
            "F:\\github.com\\consulo\\consulo\\out\\artifacts\\dist");
    System.setProperty(FileWatcher.PROPERTY_WATCHER_DISABLED, "true");

    initLogger();//  w  w w .  ja  v a  2s .  c  o m

    ApplicationEx app = CompilerServerApplication.createApplication();
    Messages.setTestDialog(new TestDialog() {
        @Override
        public int show(String message) {
            LOGGER.info(message);
            return 0;
        }
    });

    app.load(PathManager.getOptionsPath());

    System.out.println(
            "---------------------------------------------------------------------------------------------------------");

    /* File file = new File("../../../platform/compiler-server-impl/testData/zip1.zip");
            
     VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
            
     VirtualFile jarRootForLocalFile = ArchiveVfsUtil.getJarRootForLocalFile(virtualFile);
            
            
     StringBuilder builder = new StringBuilder();
     printTree(jarRootForLocalFile, 0, builder);
     System.out.println(builder);    */

    File file = new File("F:\\github.com\\consulo\\consulo\\out\\artifacts\\dist\\lib\\idea.jar");

    VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);

    VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(virtualFile);

    System.out.println(archiveRootForLocalFile.findFileByRelativePath("org/consulo/module/extension/ui"));
}

From source file:org.jetbrains.idea.maven.MavenImportingTestCase.java

License:Apache License

@Override
protected void tearDown() throws Exception {
    Messages.setTestDialog(TestDialog.DEFAULT);
    myProjectsManager.dispose();/* w  ww.  j ava  2  s.  co  m*/
    removeFromLocalRepository("test");

    super.tearDown();
}