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