use of com.android.repository.impl.manager.RepoManagerImpl in project android by JetBrains.
the class SdkComponentSourceTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
//noinspection Convert2Lambda Since otherwise it desn't create new instances.
myDisposable = new Disposable() {
@Override
public void dispose() {
}
};
MockApplicationEx instance = new MockApplicationEx(myDisposable);
instance.registerService(ExternalComponentManager.class, ExternalComponentManagerImpl.class);
instance.registerService(UpdateSettings.class, UpdateSettings.class);
ApplicationManager.setApplication(instance, myDisposable);
myFileOp = new MockFileOp();
myFileOp.recordExistingFile("/sdk/noRemote/package.xml", getLocalRepoXml("noRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/newerRemote/package.xml", getLocalRepoXml("newerRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/sameRemote/package.xml", getLocalRepoXml("sameRemote", new Revision(1)));
myFileOp.recordExistingFile("/sdk/olderRemote/package.xml", getLocalRepoXml("olderRemote", new Revision(1, 2)));
myFileOp.recordExistingFile("/sdk/hasPreview/package.xml", getLocalRepoXml("hasPreview", new Revision(1)));
myFileOp.recordExistingFile("/sdk/newerPreview/package.xml", getLocalRepoXml("newerPreview", new Revision(1, 0, 0, 1)));
myFileOp.recordExistingFile("/sdk/samePreview/package.xml", getLocalRepoXml("samePreview", new Revision(1, 0, 0, 1)));
myFileOp.recordExistingFile("/sdk/olderPreview/package.xml", getLocalRepoXml("olderPreview", new Revision(2)));
myFileOp.recordExistingFile("/sdk/zNewerInBeta/package.xml", getLocalRepoXml("zNewerInBeta", new Revision(1)));
final FakeDownloader downloader = new FakeDownloader(myFileOp);
List<String> remotePaths = Lists.newArrayList();
List<Revision> remoteRevisions = Lists.newArrayList();
List<Integer> remoteChannels = Lists.newArrayList();
remotePaths.add("newerRemote");
remoteRevisions.add(new Revision(1, 1));
remoteChannels.add(0);
remotePaths.add("sameRemote");
remoteRevisions.add(new Revision(1));
remoteChannels.add(0);
remotePaths.add("olderRemote");
remoteRevisions.add(new Revision(1, 1));
remoteChannels.add(0);
remotePaths.add("hasPreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("newerPreview");
remoteRevisions.add(new Revision(1, 0, 0, 2));
remoteChannels.add(0);
remotePaths.add("samePreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("olderPreview");
remoteRevisions.add(new Revision(1, 0, 0, 1));
remoteChannels.add(0);
remotePaths.add("onlyRemote");
remoteRevisions.add(new Revision(1));
remoteChannels.add(0);
remotePaths.add("zNewerInBeta");
remoteRevisions.add(new Revision(2));
remoteChannels.add(1);
String url = "http://example.com/repo";
downloader.registerUrl(new URL(url), getRepoXml(remotePaths, remoteRevisions, remoteChannels, true).getBytes());
final RepoManager mgr = new RepoManagerImpl(myFileOp);
mgr.setLocalPath(new File("/sdk"));
mgr.registerSchemaModule(AndroidSdkHandler.getRepositoryModule());
mgr.registerSchemaModule(AndroidSdkHandler.getCommonModule());
mgr.registerSourceProvider(new FakeRepositorySourceProvider(ImmutableList.<RepositorySource>of(new SimpleRepositorySource(url, "dummy", true, mgr.getSchemaModules(), null))));
myChannelId = 0;
myTestComponentSource = new SdkComponentSource() {
@Nullable
@Override
public List<String> getAllChannels() {
return null;
}
@Override
@NotNull
RepoManager getRepoManager() {
return mgr;
}
@NotNull
@Override
SettingsController getSettingsController() {
return new FakeSettingsController(false) {
@Override
public Channel getChannel() {
return Channel.create(myChannelId);
}
};
}
@NotNull
@Override
Downloader getDownloader(@Nullable ProgressIndicator indicator) {
return downloader;
}
};
}
Aggregations