Search in sources :

Example 11 with Revision

use of com.android.repository.Revision in project android by JetBrains.

the class PatchInstallerFactoryTest method cantHandleNoSrcOnWindows.

@Test
public void cantHandleNoSrcOnWindows() {
    myFileOp.setIsWindows(true);
    FakeRemotePackage remote = new FakeRemotePackage("foo");
    remote.setRevision(new Revision(2));
    myRepositoryPackages.setLocalPkgInfos(ImmutableList.of(PATCHER_4));
    myRepositoryPackages.setRemotePkgInfos(ImmutableList.of(remote));
    assertFalse(myInstallerFactory.canHandlePackage(remote, myRepoManager, myFileOp));
}
Also used : FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) Revision(com.android.repository.Revision) Test(org.junit.Test)

Example 12 with Revision

use of com.android.repository.Revision in project android by JetBrains.

the class SdkComponentSource method getStatuses.

@NotNull
@Override
public Collection<? extends Pair<String, String>> getStatuses() {
    Revision toolsRevision = null;
    LocalPackage toolsPackage = getRepoManager().getPackages().getLocalPackages().get(SdkConstants.FD_TOOLS);
    if (toolsPackage != null) {
        toolsRevision = toolsPackage.getVersion();
    }
    Revision platformRevision = null;
    AndroidVersion platformVersion = null;
    for (LocalPackage info : getRepoManager().getPackages().getLocalPackagesForPrefix(SdkConstants.FD_PLATFORMS)) {
        if (info.getTypeDetails() instanceof DetailsTypes.PlatformDetailsType) {
            DetailsTypes.PlatformDetailsType details = (DetailsTypes.PlatformDetailsType) info.getTypeDetails();
            AndroidVersion testVersion = new AndroidVersion(details.getApiLevel(), details.getCodename());
            if (platformVersion == null || platformVersion.compareTo(testVersion) < 0) {
                platformRevision = info.getVersion();
                platformVersion = testVersion;
            }
        }
    }
    List<Pair<String, String>> result = Lists.newArrayList();
    if (toolsRevision != null) {
        result.add(Pair.create("Android SDK Tools:", toolsRevision.toString()));
    }
    if (platformVersion != null) {
        result.add(Pair.create("Android Platform Version:", String.format("%1$s revision %2$s", platformVersion.getCodename() != null ? platformVersion.getCodename() : SdkVersionInfo.getAndroidName(platformVersion.getApiLevel()), platformRevision)));
    }
    return result;
}
Also used : Revision(com.android.repository.Revision) DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) AndroidVersion(com.android.sdklib.AndroidVersion) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with Revision

use of com.android.repository.Revision 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());
}
Also used : StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) AtomicReference(java.util.concurrent.atomic.AtomicReference) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings) ExternalUpdate(com.intellij.openapi.updateSettings.impl.ExternalUpdate) Revision(com.android.repository.Revision) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent)

Example 14 with Revision

use of com.android.repository.Revision 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());
}
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 15 with Revision

use of com.android.repository.Revision 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)

Aggregations

Revision (com.android.repository.Revision)37 Test (org.junit.Test)11 FakeRemotePackage (com.android.repository.testframework.FakePackage.FakeRemotePackage)10 FakeLocalPackage (com.android.repository.testframework.FakePackage.FakeLocalPackage)9 File (java.io.File)8 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)6 UpdatableExternalComponent (com.intellij.ide.externalComponents.UpdatableExternalComponent)6 Nullable (org.jetbrains.annotations.Nullable)6 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)5 LocalPackage (com.android.repository.api.LocalPackage)4 BuildToolInfo (com.android.sdklib.BuildToolInfo)4 StudioProgressIndicatorAdapter (com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter)4 NotNull (org.jetbrains.annotations.NotNull)4 Installer (com.android.repository.api.Installer)3 FakeDownloader (com.android.repository.testframework.FakeDownloader)3 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)3 ExternalUpdate (com.intellij.openapi.updateSettings.impl.ExternalUpdate)3 UpdateSettings (com.intellij.openapi.updateSettings.impl.UpdateSettings)3 VisibleForTesting (com.android.annotations.VisibleForTesting)2 GradleVersion (com.android.ide.common.repository.GradleVersion)2