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());
}
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);
}
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);
}
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());
}
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);
}
Aggregations