Search in sources :

Example 21 with EmptyProgressIndicator

use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.

the class GitChangeProviderTest method getChanges.

/**
   * Marks the given files dirty in myDirtyScope, gets changes from myChangeProvider and groups the changes in the map.
   * Assumes that only one change for a file has happened.
   */
protected Map<FilePath, Change> getChanges(VirtualFile... changedFiles) throws VcsException {
    final List<FilePath> changedPaths = ObjectsConvertor.vf2fp(Arrays.asList(changedFiles));
    // get changes
    MockChangelistBuilder builder = new MockChangelistBuilder();
    myChangeProvider.getChanges(myDirtyScope, builder, new EmptyProgressIndicator(), new MockChangeListManagerGate(ChangeListManager.getInstance(myProject)));
    List<Change> changes = builder.getChanges();
    // get changes for files
    final Map<FilePath, Change> result = new HashMap<>();
    for (Change change : changes) {
        VirtualFile file = change.getVirtualFile();
        FilePath filePath = null;
        if (file == null) {
            // if a file was deleted, just find the reference in the original list of files and use it. 
            String path = change.getBeforeRevision().getFile().getPath();
            for (FilePath fp : changedPaths) {
                if (FileUtil.pathsEqual(fp.getPath(), path)) {
                    filePath = fp;
                    break;
                }
            }
        } else {
            filePath = VcsUtil.getFilePath(file);
        }
        result.put(filePath, change);
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MockChangeListManagerGate(com.intellij.testFramework.vcs.MockChangeListManagerGate) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) HashMap(java.util.HashMap) Change(com.intellij.openapi.vcs.changes.Change) MockChangelistBuilder(com.intellij.testFramework.vcs.MockChangelistBuilder)

Example 22 with EmptyProgressIndicator

use of com.intellij.openapi.progress.EmptyProgressIndicator in project android by JetBrains.

the class InstallTaskTest method runWithFallbackOnComplete.

@Test
public void runWithFallbackOnComplete() throws Exception {
    Installer fallback = Mockito.mock(Installer.class);
    Mockito.when(fallback.prepare(myProgressIndicator)).thenReturn(true);
    Mockito.when(myInstaller2.complete(myProgressIndicator)).thenReturn(false);
    Mockito.when(myInstaller2.getFallbackOperation()).thenReturn(fallback);
    myInstallTask.run(new StudioProgressIndicatorAdapter(myProgressIndicator, new EmptyProgressIndicator()));
    Mockito.verify(myInstaller).prepare(myProgressIndicator);
    Mockito.verify(myInstaller2).prepare(myProgressIndicator);
    Mockito.verify(myUninstaller).prepare(myProgressIndicator);
    Mockito.verify(fallback).prepare(myProgressIndicator);
    Mockito.verify(myInstaller).complete(myProgressIndicator);
    Mockito.verify(myUninstaller).complete(myProgressIndicator);
    Mockito.verify(fallback).complete(myProgressIndicator);
    Mockito.verify(myInstaller2).complete(myProgressIndicator);
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) Test(org.junit.Test)

Example 23 with EmptyProgressIndicator

use of com.intellij.openapi.progress.EmptyProgressIndicator in project android by JetBrains.

the class InstallTaskTest method runBasic.

@Test
public void runBasic() throws Exception {
    myInstallTask.run(new StudioProgressIndicatorAdapter(myProgressIndicator, new EmptyProgressIndicator()));
    InOrder installer1Calls = Mockito.inOrder(myInstaller);
    installer1Calls.verify(myInstaller).prepare(myProgressIndicator);
    installer1Calls.verify(myInstaller).complete(myProgressIndicator);
    InOrder installer2Calls = Mockito.inOrder(myInstaller2);
    installer2Calls.verify(myInstaller2).prepare(myProgressIndicator);
    installer2Calls.verify(myInstaller2).complete(myProgressIndicator);
    InOrder uninstallerCalls = Mockito.inOrder(myUninstaller);
    uninstallerCalls.verify(myUninstaller).prepare(myProgressIndicator);
    uninstallerCalls.verify(myUninstaller).complete(myProgressIndicator);
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) InOrder(org.mockito.InOrder) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) Test(org.junit.Test)

Example 24 with EmptyProgressIndicator

use of com.intellij.openapi.progress.EmptyProgressIndicator in project android by JetBrains.

the class InstallTaskTest method runCallbacks.

@Test
public void runCallbacks() throws Exception {
    Runnable prepareComplete = Mockito.mock(Runnable.class);
    myInstallTask.setPrepareCompleteCallback(prepareComplete);
    Function<List<RepoPackage>, Void> complete = (Function<List<RepoPackage>, Void>) Mockito.mock(Function.class);
    myInstallTask.setCompleteCallback(complete);
    myInstallTask.run(new StudioProgressIndicatorAdapter(myProgressIndicator, new EmptyProgressIndicator()));
    InOrder callbackCalls = Mockito.inOrder(myInstaller, prepareComplete, complete);
    callbackCalls.verify(myInstaller).prepare(myProgressIndicator);
    callbackCalls.verify(prepareComplete).run();
    callbackCalls.verify(myInstaller).complete(myProgressIndicator);
    callbackCalls.verify(complete).apply(new ArrayList<>());
}
Also used : Function(java.util.function.Function) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) InOrder(org.mockito.InOrder) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) Test(org.junit.Test)

Example 25 with EmptyProgressIndicator

use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-plugins by JetBrains.

the class AppTestBase method launchAndInitializeApplication.

private void launchAndInitializeApplication() throws Exception {
    if (DesignerApplicationManager.getInstance().isApplicationClosed()) {
        changeServicesImplementation();
        new DesignerApplicationLauncher(myModule, new DesignerApplicationLauncher.PostTask() {

            @Override
            public boolean run(Module module, ProjectComponentReferenceCounter projectComponentReferenceCounter, ProgressIndicator indicator, ProblemsHolder problemsHolder) {
                assertTrue(DocumentProblemManager.getInstance().toString(problemsHolder.getProblems()), problemsHolder.isEmpty());
                client = (TestClient) Client.getInstance();
                client.flush();
                try {
                    assertAfterInitLibrarySets(projectComponentReferenceCounter.unregistered);
                } catch (IOException e) {
                    throw new AssertionError(e);
                }
                return true;
            }
        }).run(new EmptyProgressIndicator());
    } else {
        client = (TestClient) Client.getInstance();
        ProblemsHolder problemsHolder = new ProblemsHolder();
        ProjectComponentReferenceCounter projectComponentReferenceCounter = LibraryManager.getInstance().registerModule(myModule, problemsHolder, isRequireLocalStyleHolder());
        assertTrue(problemsHolder.isEmpty());
        assertAfterInitLibrarySets(projectComponentReferenceCounter.unregistered);
    }
    socketInputHandler = (TestSocketInputHandler) SocketInputHandler.getInstance();
    applicationLaunchedAndInitialized();
}
Also used : ProjectComponentReferenceCounter(com.intellij.flex.uiDesigner.mxml.ProjectComponentReferenceCounter) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) IOException(java.io.IOException) Module(com.intellij.openapi.module.Module)

Aggregations

EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)46 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)14 NotNull (org.jetbrains.annotations.NotNull)14 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 IOException (java.io.IOException)6 ProgressManager (com.intellij.openapi.progress.ProgressManager)5 Test (org.junit.Test)5 StudioProgressIndicatorAdapter (com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter)4 Processor (com.intellij.util.Processor)4 File (java.io.File)4 UpdatedFiles (com.intellij.openapi.vcs.update.UpdatedFiles)3 DiffLog (com.intellij.psi.impl.source.text.DiffLog)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Future (java.util.concurrent.Future)3 Nullable (org.jetbrains.annotations.Nullable)3 Disposable (com.intellij.openapi.Disposable)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 Logger (com.intellij.openapi.diagnostic.Logger)2 PluginId (com.intellij.openapi.extensions.PluginId)2