Search in sources :

Example 1 with FakeSettingsController

use of com.android.repository.testframework.FakeSettingsController 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)1 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)1 FakeSettingsController (com.android.repository.testframework.FakeSettingsController)1 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)1 Before (org.junit.Before)1