Search in sources :

Example 6 with FakeRepoManager

use of com.android.repository.testframework.FakeRepoManager in project android by JetBrains.

the class PatchInstallerUtilTest method getDependantPatcher.

@Test
public void getDependantPatcher() throws Exception {
    LocalPackage target = new FakeLocalPackage("patcher;v2");
    List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("patcher;v1"), target, new FakeLocalPackage("patcher;v3"));
    FakeRemotePackage update = new FakeRemotePackage("p");
    List<RemotePackage> remote = ImmutableList.of(update, new FakeRemotePackage("patcher;v4"));
    update.setDependencies(ImmutableList.of(new FakeDependency(target.getPath())));
    RepositoryPackages packages = new RepositoryPackages(local, remote);
    FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages);
    LocalPackage patcher = PatchInstallerUtil.getDependantPatcher(update, mgr);
    assertEquals(target, patcher);
}
Also used : FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) LocalPackage(com.android.repository.api.LocalPackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeDependency(com.android.repository.testframework.FakeDependency) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) RemotePackage(com.android.repository.api.RemotePackage) FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) File(java.io.File) Test(org.junit.Test)

Example 7 with FakeRepoManager

use of com.android.repository.testframework.FakeRepoManager in project android by JetBrains.

the class PatchInstallerUtilTest method dependantPatcherNotInstalled.

@Test
public void dependantPatcherNotInstalled() throws Exception {
    FakeLocalPackage target = new FakeLocalPackage("patcher;v2");
    List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("patcher;v1"), new FakeLocalPackage("patcher;v3"));
    FakeRemotePackage update = new FakeRemotePackage("p");
    List<RemotePackage> remote = ImmutableList.of(update, new FakeRemotePackage("patcher;v4"));
    update.setDependencies(ImmutableList.of(new FakeDependency(target.getPath())));
    RepositoryPackages packages = new RepositoryPackages(local, remote);
    FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages);
    LocalPackage patcher = PatchInstallerUtil.getDependantPatcher(update, mgr);
    assertNull(patcher);
}
Also used : FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) LocalPackage(com.android.repository.api.LocalPackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeDependency(com.android.repository.testframework.FakeDependency) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) RemotePackage(com.android.repository.api.RemotePackage) FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) File(java.io.File) Test(org.junit.Test)

Example 8 with FakeRepoManager

use of com.android.repository.testframework.FakeRepoManager in project android by JetBrains.

the class PatchInstallerUtilTest method noLatestPatcher.

@Test
public void noLatestPatcher() throws Exception {
    List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("foo"));
    RepositoryPackages packages = new RepositoryPackages(local, ImmutableList.of());
    FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages);
    LocalPackage patcher = PatchInstallerUtil.getLatestPatcher(mgr);
    assertNull(patcher);
}
Also used : FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) LocalPackage(com.android.repository.api.LocalPackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) File(java.io.File) Test(org.junit.Test)

Example 9 with FakeRepoManager

use of com.android.repository.testframework.FakeRepoManager in project android by JetBrains.

the class InstallTaskTest method setUp.

@Before
public void setUp() {
    Mockito.when(myExisting1.getPath()).thenReturn("p1");
    Mockito.when(myAvailable1.getPath()).thenReturn("p2");
    Mockito.when(myAvailable2.getPath()).thenReturn("p3");
    RepositoryPackages repoPackages = new RepositoryPackages(ImmutableList.of(myExisting1), ImmutableList.of(myAvailable1, myAvailable2));
    AndroidSdkHandler repoHandler = new AndroidSdkHandler(SDK_ROOT, null, myFileOp, new FakeRepoManager(SDK_ROOT, repoPackages));
    RepoManager repoManager = repoHandler.getSdkManager(myProgressIndicator);
    myInstallTask = new InstallTask(factory, repoHandler, new FakeSettingsController(false), myProgressIndicator);
    myInstallTask.setInstallRequests(ImmutableList.of(new UpdatablePackage(myAvailable1), new UpdatablePackage(myAvailable2)));
    myInstallTask.setUninstallRequests(ImmutableList.of(myExisting1));
    Mockito.when(myInstaller.prepare(myProgressIndicator)).thenReturn(true);
    Mockito.when(myInstaller2.prepare(myProgressIndicator)).thenReturn(true);
    Mockito.when(myUninstaller.prepare(myProgressIndicator)).thenReturn(true);
    Mockito.when(myInstaller.complete(myProgressIndicator)).thenReturn(true);
    Mockito.when(myInstaller2.complete(myProgressIndicator)).thenReturn(true);
    Mockito.when(myUninstaller.complete(myProgressIndicator)).thenReturn(true);
    myOperations = new HashMap<>();
    myOperations.put(myExisting1, myUninstaller);
    myOperations.put(myAvailable1, myInstaller);
    myOperations.put(myAvailable2, myInstaller2);
    Mockito.when(factory.createInstaller(eq(myAvailable1), eq(repoManager), any(), eq(myFileOp))).thenReturn(myInstaller);
    Mockito.when(factory.createInstaller(eq(myAvailable2), eq(repoManager), any(), eq(myFileOp))).thenReturn(myInstaller2);
    Mockito.when(factory.createUninstaller(myExisting1, repoManager, myFileOp)).thenReturn(myUninstaller);
}
Also used : RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) FakeSettingsController(com.android.repository.testframework.FakeSettingsController) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) Before(org.junit.Before)

Aggregations

RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)9 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)9 File (java.io.File)6 FakeLocalPackage (com.android.repository.testframework.FakePackage.FakeLocalPackage)5 LocalPackage (com.android.repository.api.LocalPackage)4 RemotePackage (com.android.repository.api.RemotePackage)4 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)4 Test (org.junit.Test)4 RepoManager (com.android.repository.api.RepoManager)3 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)2 FakeDependency (com.android.repository.testframework.FakeDependency)2 FakeRemotePackage (com.android.repository.testframework.FakePackage.FakeRemotePackage)2 MockFileOp (com.android.repository.testframework.MockFileOp)2 Before (org.junit.Before)2 BasicInstallerFactory (com.android.repository.impl.installer.BasicInstallerFactory)1 FakeSettingsController (com.android.repository.testframework.FakeSettingsController)1 NotNull (org.jetbrains.annotations.NotNull)1