Search in sources :

Example 6 with StudioProgressIndicatorAdapter

use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter in project android by JetBrains.

the class SdkComponentSourceTest method testUpdates.

public void testUpdates() throws Exception {
    ExternalComponentManager.getInstance().registerComponentSource(myTestComponentSource);
    ProgressIndicator progress = new StudioProgressIndicatorAdapter(new FakeProgressIndicator(), null);
    UpdateSettings settings = new UpdateSettings() {

        @Override
        public List<String> getEnabledExternalUpdateSources() {
            return ImmutableList.of(myTestComponentSource.getName());
        }
    };
    Collection<ExternalUpdate> updates = UpdateChecker.updateExternal(true, settings, progress);
    assertEquals(1, updates.size());
    ExternalUpdate update = updates.iterator().next();
    Iterator<UpdatableExternalComponent> iter = update.getComponents().iterator();
    UpdatableExternalComponent component = iter.next();
    assertEquals("package newerPreview", component.getName());
    assertEquals(new Revision(1, 0, 0, 2), ((RepoPackage) component.getKey()).getVersion());
    component = iter.next();
    assertEquals("package newerRemote", component.getName());
    assertEquals(new Revision(1, 1, 0), ((RepoPackage) component.getKey()).getVersion());
    assertFalse(iter.hasNext());
}
Also used : ExternalUpdate(com.intellij.openapi.updateSettings.impl.ExternalUpdate) Revision(com.android.repository.Revision) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings)

Example 7 with StudioProgressIndicatorAdapter

use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter 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 8 with StudioProgressIndicatorAdapter

use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter 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 9 with StudioProgressIndicatorAdapter

use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter in project android by JetBrains.

the class SdkComponentSourceTest method testAvailableBetaVersions.

public void testAvailableBetaVersions() throws Exception {
    myChannelId = 1;
    ProgressIndicator progress = new StudioProgressIndicatorAdapter(new FakeProgressIndicator(), null);
    Set<UpdatableExternalComponent> components = Sets.newTreeSet(COMPONENT_COMPARATOR);
    components.addAll(myTestComponentSource.getAvailableVersions(progress, null));
    Iterator<UpdatableExternalComponent> componentIter = components.iterator();
    validateStablePackages(componentIter);
    UpdatableExternalComponent c = componentIter.next();
    assertEquals("package zNewerInBeta", c.getName());
    assertEquals(new Revision(2, 0, 0), ((RepoPackage) c.getKey()).getVersion());
    assertFalse(componentIter.hasNext());
}
Also used : Revision(com.android.repository.Revision) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter)

Example 10 with StudioProgressIndicatorAdapter

use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter in project android by JetBrains.

the class InstallTaskTest method runWithFallbackOnPrepare.

@Test
public void runWithFallbackOnPrepare() throws Exception {
    Installer fallback = Mockito.mock(Installer.class);
    Mockito.when(fallback.prepare(myProgressIndicator)).thenReturn(true);
    Mockito.when(myInstaller2.prepare(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, Mockito.never()).complete(myProgressIndicator);
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) Test(org.junit.Test)

Aggregations

StudioProgressIndicatorAdapter (com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter)10 UpdatableExternalComponent (com.intellij.ide.externalComponents.UpdatableExternalComponent)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 Revision (com.android.repository.Revision)4 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)4 Test (org.junit.Test)4 ExternalUpdate (com.intellij.openapi.updateSettings.impl.ExternalUpdate)3 UpdateSettings (com.intellij.openapi.updateSettings.impl.UpdateSettings)3 InOrder (org.mockito.InOrder)2 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Function (java.util.function.Function)1