Java Code Examples for com.intellij.openapi.application.Application#isUnitTestMode()
The following examples show how to use
com.intellij.openapi.application.Application#isUnitTestMode() .
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
Source File: AsyncRateLimiter.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void performRequestOnUiThread() { final Runnable doRun = () -> { if (requestScheduler.isDisposed()) { return; } performRequest(); }; final Application app = ApplicationManager.getApplication(); if (app == null || app.isUnitTestMode()) { // This case exists to support unittesting. SwingUtilities.invokeLater(doRun); } else { app.invokeLater(doRun); } }
Example 2
Source File: FormatterImpl.java From consulo with Apache License 2.0 | 6 votes |
private void execute(@Nonnull SequentialTask task) { disableFormatting(); Application application = ApplicationManager.getApplication(); FormattingProgressTask progressTask = myProgressTask.getAndSet(null); if (progressTask == null || !application.isDispatchThread() || application.isUnitTestMode()) { try { task.prepare(); while (!task.isDone()) { task.iteration(); } } finally { enableFormatting(); } } else { progressTask.setTask(task); Runnable callback = () -> enableFormatting(); for (FormattingProgressCallback.EventType eventType : FormattingProgressCallback.EventType.values()) { progressTask.addCallback(eventType, callback); } ProgressManager.getInstance().run(progressTask); } }
Example 3
Source File: PopupFactoryImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public ListPopup createConfirmation(String title, final String yesText, String noText, final Runnable onYes, final Runnable onNo, int defaultOptionIndex) { final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title, yesText, noText) { @Override public PopupStep onChosen(String selectedValue, final boolean finalChoice) { return doFinalStep(selectedValue.equals(yesText) ? onYes : onNo); } @Override public void canceled() { onNo.run(); } @Override public boolean isMnemonicsNavigationEnabled() { return true; } }; step.setDefaultOptionIndex(defaultOptionIndex); final Application app = ApplicationManager.getApplication(); return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step, yesText); }
Example 4
Source File: FontComboBox.java From consulo with Apache License 2.0 | 6 votes |
private Model(boolean withAllStyles, boolean filterNonLatin, boolean noFontItem) { myNoFontItem = noFontItem ? new NoFontItem() : null; Application application = ApplicationManager.getApplication(); if (application == null || application.isUnitTestMode()) { setFonts(FontInfo.getAll(withAllStyles), filterNonLatin); } else { application.executeOnPooledThread(() -> { List<FontInfo> all = FontInfo.getAll(withAllStyles); application.invokeLater(() -> { setFonts(all, filterNonLatin); updateSelectedItem(); }, application.getAnyModalityState()); }); } }
Example 5
Source File: ClipboardSynchronizer.java From consulo with Apache License 2.0 | 6 votes |
@Inject public ClipboardSynchronizer(Application application) { if (application.isHeadlessEnvironment() && application.isUnitTestMode()) { myClipboardHandler = new HeadlessClipboardHandler(); } else if (Patches.SLOW_GETTING_CLIPBOARD_CONTENTS && SystemInfo.isMac) { myClipboardHandler = new MacClipboardHandler(); } else if (Patches.SLOW_GETTING_CLIPBOARD_CONTENTS && SystemInfo.isXWindow) { myClipboardHandler = new XWinClipboardHandler(); } else { myClipboardHandler = new ClipboardHandler(); } myClipboardHandler.init(); }
Example 6
Source File: GeneralTestEventsProcessor.java From consulo with Apache License 2.0 | 6 votes |
public void addToInvokeLater(final Runnable runnable) { final Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode()) { UIUtil.invokeLaterIfNeeded(() -> { if (!myProject.isDisposed()) { runnable.run(); } }); } else if (application.isHeadlessEnvironment() || SwingUtilities.isEventDispatchThread()) { runnable.run(); } else { myTransferToEDTQueue.offer(runnable); } }
Example 7
Source File: IdeaHelper.java From azure-devops-intellij with MIT License | 6 votes |
public static void runOnUIThread(final Runnable runnable, final boolean wait, final ModalityState modalityState) { Application application = ApplicationManager.getApplication(); if (application != null && !application.isDispatchThread() && !application.isUnitTestMode()) { if (wait) { application.invokeAndWait(runnable, modalityState); // TODO: use this instead after deprecating IDEA 15: TransactionGuard.getInstance().submitTransactionAndWait(runnable); } else { application.invokeLater(runnable, modalityState); // TODO: use this instead after deprecating IDEA 15: TransactionGuard.getInstance().submitTransaction(runnable); } } else { // If we are already on the dispatch thread then we can run it here // If we don't have an application or we are testing, just run the runnable here runnable.run(); } }
Example 8
Source File: AsyncRateLimiter.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void performRequestOnUiThread() { final Runnable doRun = () -> { if (requestScheduler.isDisposed()) { return; } performRequest(); }; final Application app = ApplicationManager.getApplication(); if (app == null || app.isUnitTestMode()) { // This case exists to support unittesting. SwingUtilities.invokeLater(doRun); } else { app.invokeLater(doRun); } }
Example 9
Source File: UndoManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
private void commandStarted(UndoConfirmationPolicy undoConfirmationPolicy, boolean recordOriginalReference) { if (myCommandLevel == 0) { myCurrentMerger = new CommandMerger(this, CommandProcessor.getInstance().isUndoTransparentActionInProgress()); if (recordOriginalReference && myProject != null) { Editor editor = null; final Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode() || application.isHeadlessEnvironment()) { editor = DataManager.getInstance().getDataContext().getData(CommonDataKeys.EDITOR); } else { Component component = WindowManagerEx.getInstanceEx().getFocusedComponent(myProject); if (component != null) { editor = DataManager.getInstance().getDataContext(component).getData(CommonDataKeys.EDITOR); } } if (editor != null) { Document document = editor.getDocument(); VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (file != null && file.isValid()) { myOriginatorReference = DocumentReferenceManager.getInstance().create(file); } } } } LOG.assertTrue(myCurrentMerger != null, String.valueOf(myCommandLevel)); myCurrentMerger.setBeforeState(getCurrentState()); myCurrentMerger.mergeUndoConfirmationPolicy(undoConfirmationPolicy); myCommandLevel++; }
Example 10
Source File: AsyncUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void invokeLater(Runnable runnable) { final Application app = ApplicationManager.getApplication(); if (app == null || app.isUnitTestMode()) { // This case existing to support unit testing. SwingUtilities.invokeLater(runnable); } else { app.invokeLater(runnable); } }
Example 11
Source File: AsyncUtils.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void invokeAndWait(Runnable runnable) throws ProcessCanceledException { final Application app = ApplicationManager.getApplication(); if (app == null || app.isUnitTestMode()) { try { // This case existing to support unit testing. SwingUtilities.invokeAndWait(runnable); } catch (InterruptedException | InvocationTargetException e) { throw new ProcessCanceledException(e); } } else { app.invokeAndWait(runnable); } }
Example 12
Source File: FileStatusManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void fileStatusChanged(final VirtualFile file) { final Application application = ApplicationManager.getApplication(); if (!application.isDispatchThread() && !application.isUnitTestMode()) { ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() { @Override public void run() { fileStatusChanged(file); } }); return; } if (file == null || !file.isValid()) return; FileStatus cachedStatus = getCachedStatus(file); if (cachedStatus == FileStatusNull.INSTANCE) { return; } if (cachedStatus == null) { cacheChangedFileStatus(file, FileStatusNull.INSTANCE); return; } FileStatus newStatus = calcStatus(file); if (cachedStatus == newStatus) return; cacheChangedFileStatus(file, newStatus); for (FileStatusListener listener : myListeners) { listener.fileStatusChanged(file); } }
Example 13
Source File: SystemNotifications.java From consulo with Apache License 2.0 | 4 votes |
public static SystemNotifications getInstance() { Application app = ApplicationManager.getApplication(); return app.isHeadlessEnvironment() || app.isUnitTestMode() ? NULL : ServiceManager.getService(SystemNotifications.class); }
Example 14
Source File: PendingEventDispatcher.java From consulo with Apache License 2.0 | 4 votes |
private void assertDispatchThread() { Application application = ApplicationManager.getApplication(); if (myAssertDispatchThread && !application.isUnitTestMode()) { application.assertIsDispatchThread(); } }
Example 15
Source File: DialogWrapperPeer.java From consulo with Apache License 2.0 | 4 votes |
public static boolean isHeadlessEnv() { Application app = ApplicationManager.getApplication(); if (app == null) return GraphicsEnvironment.isHeadless(); return app.isUnitTestMode() || app.isHeadlessEnvironment(); }
Example 16
Source File: NotificationsManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
private static boolean isDummyEnvironment() { final Application application = ApplicationManager.getApplication(); return application.isUnitTestMode() || application.isCommandLine(); }
Example 17
Source File: RefreshProgress.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public static ProgressIndicator create(@Nonnull String message) { Application app = ApplicationManager.getApplication(); return app == null || app.isUnitTestMode() ? new EmptyProgressIndicator() : new RefreshProgress(message); }
Example 18
Source File: CppSupportSettings.java From CppTools with Apache License 2.0 | 4 votes |
public static CppSupportSettings getInstance() { final Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode()) return instance; return application.getComponent(CppSupportSettings.class); }
Example 19
Source File: AbstractTreeUi.java From consulo with Apache License 2.0 | 4 votes |
private static boolean isUnitTestingMode() { Application app = ApplicationManager.getApplication(); return app != null && app.isUnitTestMode(); }
Example 20
Source File: DefaultProjectFactoryImpl.java From consulo with Apache License 2.0 | 4 votes |
@Inject public DefaultProjectFactoryImpl(@Nonnull Application application, @Nonnull ProjectManager projectManager) { myDefaultProject = new DefaultProjectImpl(application, projectManager, "", application.isUnitTestMode()); myDefaultProject.initNotLazyServices(null); }