Java Code Examples for com.intellij.openapi.ui.Messages#setTestDialog()

The following examples show how to use com.intellij.openapi.ui.Messages#setTestDialog() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected static AtomicInteger configConfirmationForYesAnswer() {
  final AtomicInteger counter = new AtomicInteger();
  Messages.setTestDialog(new TestDialog() {
    @Override
    public int show(String message) {
      counter.set(counter.get() + 1);
      return 0;
    }
  });
  return counter;
}
 
Example 2
protected static AtomicInteger configConfirmationForNoAnswer() {
  final AtomicInteger counter = new AtomicInteger();
  Messages.setTestDialog(new TestDialog() {
    @Override
    public int show(String message) {
      counter.set(counter.get() + 1);
      return 1;
    }
  });
  return counter;
}
 
Example 3
protected static AtomicInteger configConfirmationForYesAnswer() {
  final AtomicInteger counter = new AtomicInteger();
  Messages.setTestDialog(message -> {
    counter.getAndIncrement();
    return Messages.YES;
  });
  return counter;
}
 
Example 4
protected static AtomicInteger configConfirmationForNoAnswer() {
  final AtomicInteger counter = new AtomicInteger();
  Messages.setTestDialog(message -> {
    counter.getAndIncrement();
    return Messages.NO;
  });
  return counter;
}
 
Example 5
Source Project: azure-devops-intellij   File: PasswordMgtTests.java    License: MIT License 5 votes vote down vote up
private static void verifyShowsMessage(String expectedMessage, int messageResult, Runnable action) {
    AtomicReference<String> messageShown = new AtomicReference<>();
    TestDialog oldTestDialog = Messages.setTestDialog(message -> {
        messageShown.set(message);
        return messageResult;
    });

    try {
        action.run();
        assertEquals("Message shown in dialog", expectedMessage, messageShown.get());
    } finally {
        Messages.setTestDialog(oldTestDialog);
    }
}
 
Example 6
@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",
    "FileBasedIndex"
  );
  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);

  // TODO(cosmicexplorer): after updating from 172.4343.14 to 173.3531.6,
  // intellij's provided test class sometimes yells about a leaky jdk
  // table. i don't think this indicates any problems, so for now if tests
  // fail with leaky sdk errors, broaden this to include the leaked sdks.
  removeJdks(jdk -> jdk.getName().contains("pants"));
  super.tearDown();
}
 
Example 7
public void doOverrideTest(String testFile, TestDialog answer) throws Throwable {
  Messages.setTestDialog(answer);
  myFixture.configureByFiles(testFile, "com/bar/TestSearchOverrides.hx");
  myFixture.copyFileToProject(getResultsPath());
  compareExpectedUsages(findUsages());
}
 
Example 8
public void testLogSimple() throws Exception {
  Messages.setTestDialog(TestDialog.DEFAULT);
  doTest();
}
 
Example 9
public void testLogRename() throws Exception {
  Messages.setTestDialog(TestDialog.OK);
  doTest();
}
 
Example 10
public void testLogPublic() throws Exception {
  Messages.setTestDialog(TestDialog.OK);
  doTest();
}
 
Example 11
public void testLogNonStatic() throws Exception {
  Messages.setTestDialog(TestDialog.OK);
  doTest();
}
 
Example 12
public void testLogNonFinal() throws Exception {
  Messages.setTestDialog(TestDialog.OK);
  doTest();
}