use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter in project android by JetBrains.
the class StudioDownloader method downloadFully.
@Override
public void downloadFully(@NotNull URL url, @NotNull File target, @Nullable String checksum, @NotNull ProgressIndicator indicator) throws IOException {
if (target.exists() && checksum != null) {
if (checksum.equals(Downloader.hash(new BufferedInputStream(new FileInputStream(target)), target.length(), indicator))) {
return;
}
}
// We don't use the settings here explicitly, since HttpRequests picks up the network settings from studio directly.
indicator.logInfo("Downloading " + url);
indicator.setText("Downloading...");
indicator.setSecondaryText(url.toString());
com.intellij.openapi.progress.ProgressIndicator studioProgress = myStudioProgressIndicator;
if (studioProgress == null) {
studioProgress = ProgressManager.getInstance().getProgressIndicator();
}
HttpRequests.request(url.toExternalForm()).saveToFile(target, new StudioProgressIndicatorAdapter(indicator, studioProgress));
}
use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter 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<>());
}
use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter in project android by JetBrains.
the class SdkComponentSourceTest method testIgnored.
public void testIgnored() throws Exception {
final AtomicReference<String> id = new AtomicReference<String>();
ProgressIndicator progress = new StudioProgressIndicatorAdapter(new FakeProgressIndicator(), null);
for (UpdatableExternalComponent c : myTestComponentSource.getAvailableVersions(progress, null)) {
if ("package newerRemote".equals(c.getName())) {
id.set(SdkComponentSource.getPackageRevisionId((RepoPackage) c.getKey()));
}
}
assertNotNull(id.get());
ExternalComponentManager.getInstance().registerComponentSource(myTestComponentSource);
UpdateSettings settings = new UpdateSettings() {
@Override
public List<String> getEnabledExternalUpdateSources() {
return ImmutableList.of(myTestComponentSource.getName());
}
@Override
public List<String> getIgnoredBuildNumbers() {
return ImmutableList.of(id.get());
}
};
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());
assertFalse(iter.hasNext());
}
use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter in project android by JetBrains.
the class SdkComponentSourceTest method testAvailableStableVersions.
public void testAvailableStableVersions() throws Exception {
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);
assertFalse(componentIter.hasNext());
}
use of com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter in project android by JetBrains.
the class SdkComponentSourceTest method testBetaUpdates.
public void testBetaUpdates() throws Exception {
myChannelId = 1;
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());
component = iter.next();
assertEquals("package zNewerInBeta", component.getName());
assertEquals(new Revision(2, 0, 0), ((RepoPackage) component.getKey()).getVersion());
assertFalse(iter.hasNext());
}
Aggregations