use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class AndroidGradleProjectResolverIdeaTest method testCreateModuleWithOldModelVersion.
public void testCreateModuleWithOldModelVersion() {
AndroidProject androidProject = mock(AndroidProject.class);
ProjectImportAction.AllModels allModels = new ProjectImportAction.AllModels(myProjectModel);
allModels.addExtraProject(androidProject, AndroidProject.class, myAndroidModuleModel);
myResolverCtx.setModels(allModels);
when(androidProject.getModelVersion()).thenReturn("0.0.1");
ProjectData project = myProjectResolver.createProject();
DataNode<ProjectData> projectDataNode = new DataNode<>(PROJECT, project, null);
try {
myProjectResolver.createModule(myAndroidModuleModel, projectDataNode);
fail("Expecting IllegalStateException to be thrown");
} catch (IllegalStateException e) {
assertThat(e.getMessage()).startsWith("The project is using an unsupported version of the Android Gradle plug-in (0.0.1)");
}
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class SyncActionTest method executeWithExistingModel.
@Test
public void executeWithExistingModel() {
SyncAction action = new SyncAction(Lists.newArrayList(AndroidProject.class));
when(myBuildController.getModel(IdeaProject.class)).thenReturn(myProject);
when(myBuildController.findModel(myModule, AndroidProject.class)).thenReturn(myAndroidProject);
SyncAction.ProjectModels projectModels = action.execute(myBuildController);
assertNotNull(projectModels);
SyncAction.ModuleModels moduleModels = projectModels.getModels(myModule);
AndroidProject actual = moduleModels.findModel(AndroidProject.class);
assertSame(myAndroidProject, actual);
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class SyncActionTest method executeWithNotExistingModel.
@SuppressWarnings("deprecation")
@Test
public void executeWithNotExistingModel() {
SyncAction action = new SyncAction(Lists.newArrayList(ModuleExtendedModel.class));
when(myBuildController.getModel(IdeaProject.class)).thenReturn(myProject);
when(myBuildController.findModel(myModule, ModuleExtendedModel.class)).thenReturn(null);
SyncAction.ProjectModels projectModels = action.execute(myBuildController);
assertNotNull(projectModels);
SyncAction.ModuleModels moduleModels = projectModels.getModels(myModule);
AndroidProject actual = moduleModels.findModel(AndroidProject.class);
assertNull(actual);
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class BuildTools23Rc1ValidationStrategyTest method mockAndroidModel.
@NotNull
private static AndroidModuleModel mockAndroidModel(@Nullable String modelVersion, int apiVersion) {
AndroidProject androidProject = mock(AndroidProject.class);
when(androidProject.getModelVersion()).thenReturn(modelVersion);
when(androidProject.getApiVersion()).thenReturn(apiVersion);
AndroidModuleModel androidModel = mock(AndroidModuleModel.class);
when(androidModel.getAndroidProject()).thenReturn(androidProject);
return androidModel;
}
use of com.android.builder.model.AndroidProject in project android by JetBrains.
the class DependenciesModuleSetupStepTest method testUpdateLibraryDependencyWithLibraryInModule.
public void testUpdateLibraryDependencyWithLibraryInModule() throws IOException {
Module module = getModule();
createContentRoot(module);
VirtualFile moduleFolder = getModuleFolder(module);
// Create "build" folder inside the module.
String name = "build";
VirtualFile buildFolder = createFolder(moduleFolder, name);
AndroidProject androidProject = mock(AndroidProject.class);
when(androidProject.getBuildFolder()).thenReturn(virtualToIoFile(buildFolder));
// Create "jars" folder inside the module's "build" folder.
VirtualFile jarsFolder = createFolder(buildFolder, "jars");
File jarsFolderPath = virtualToIoFile(jarsFolder);
// We simulate the dependency to set up being inside the "jars" folder. We expect the "jars" folder to be excluded to avoid unnecessary
// indexing of the jar files.
LibraryDependency dependency = createFakeLibraryDependency(jarsFolderPath);
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
mySetupStep.updateLibraryDependency(module, modelsProvider, dependency, androidProject);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
// Make sure DependenciesSetup#setUpLibraryDependency was invoked.
verify(myDependenciesSetup).setUpLibraryDependency(module, modelsProvider, "myLibrary", COMPILE, dependency.getArtifactPath(), dependency.getPaths(BINARY), dependency.getPaths(DOCUMENTATION));
}
Aggregations