Search in sources :

Example 6 with SyncMessagesStub

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub in project android by JetBrains.

the class UniquePathModuleValidatorStrategyTest method testFixAndReportFoundIssuesWithUniquePaths.

public void testFixAndReportFoundIssuesWithUniquePaths() throws Exception {
    Project project = getProject();
    SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(project);
    ProjectSubset projectSubset = IdeComponents.replaceServiceWithMock(project, ProjectSubset.class);
    when(projectSubset.isFeatureEnabled()).thenReturn(false);
    Multimap<String, Module> modulesByPath = myStrategy.getModulesByPath();
    modulesByPath.putAll("path1", Lists.newArrayList(myModule1));
    modulesByPath.putAll("path2", Lists.newArrayList(myModule2));
    myStrategy.fixAndReportFoundIssues();
    SyncMessage message = syncMessages.getFirstReportedMessage();
    assertNull(message);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) Project(com.intellij.openapi.project.Project) SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) ProjectSubset(com.android.tools.idea.gradle.project.subset.ProjectSubset) Module(com.intellij.openapi.module.Module)

Example 7 with SyncMessagesStub

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub in project android by JetBrains.

the class ExtraGeneratedFolderValidationStrategyTest method testFixAndReportFoundIssuesWithoutExtraFolders.

public void testFixAndReportFoundIssuesWithoutExtraFolders() {
    myStrategy.getExtraGeneratedSourceFolderPaths().clear();
    SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(getProject());
    myStrategy.fixAndReportFoundIssues();
    List<SyncMessage> messages = syncMessages.getReportedMessages();
    assertThat(messages).isEmpty();
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)

Example 8 with SyncMessagesStub

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub in project android by JetBrains.

the class JdkModuleSetupStepTest method testSetUpInAndroidStudio.

public void testSetUpInAndroidStudio() throws Exception {
    loadSimpleApplication();
    Module appModule = myModules.getAppModule();
    AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
    assertNotNull(androidModel);
    Sdk jdk = mock(Sdk.class);
    when(myIdeSdks.getJdk()).thenReturn(jdk);
    when(myJdks.isApplicableJdk(jdk, JDK_1_7)).thenReturn(false);
    SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(getProject());
    mySetupStep.setUpInAndroidStudio(appModule, androidModel);
    SyncMessage message = syncMessages.getFirstReportedMessage();
    assertNotNull(message);
    String[] text = message.getText();
    assertThat(text).isNotEmpty();
    assertThat(text[0]).matches("compileSdkVersion (.*) requires compiling with JDK 7 or newer.");
    GradleSyncSummary summary = GradleSyncState.getInstance(getProject()).getSummary();
    assertTrue(summary.hasSyncErrors());
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) GradleSyncSummary(com.android.tools.idea.gradle.project.sync.GradleSyncSummary) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Example 9 with SyncMessagesStub

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub in project android by JetBrains.

the class DependencySetupTest method WithUnresolvedDependencies.

// Fails in Bazel PSQ because of missing dependencies in the prebuilt Android SDK.
public void WithUnresolvedDependencies() throws Exception {
    loadSimpleApplication();
    File buildFilePath = getBuildFilePath("app");
    VirtualFile buildFile = findFileByIoFile(buildFilePath, true);
    assertNotNull(buildFile);
    boolean versionChanged = false;
    Project project = getProject();
    GradleBuildModel buildModel = GradleBuildModel.parseBuildFile(buildFile, project);
    for (ArtifactDependencyModel artifact : buildModel.dependencies().artifacts()) {
        if ("com.android.support".equals(artifact.group().value()) && "appcompat-v7".equals(artifact.name().value())) {
            artifact.setVersion("100.0.0");
            versionChanged = true;
            break;
        }
    }
    assertTrue(versionChanged);
    runWriteCommandAction(project, buildModel::applyChanges);
    LocalFileSystem.getInstance().refresh(false);
    SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(project);
    requestSyncAndWait();
    SyncMessage reportedMessage = syncMessages.getFirstReportedMessage();
    assertNotNull(reportedMessage);
    String[] text = reportedMessage.getText();
    assertThat(text).isNotEmpty();
    assertEquals("Failed to resolve: com.android.support:appcompat-v7:100.0.0", text[0]);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) Project(com.intellij.openapi.project.Project) GradleUtil.getAndroidProject(com.android.tools.idea.gradle.util.GradleUtil.getAndroidProject) SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) ArtifactDependencyModel(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) File(java.io.File)

Example 10 with SyncMessagesStub

use of com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub in project android by JetBrains.

the class EncodingValidationStrategyTest method testFixAndReportFoundIssues.

public void testFixAndReportFoundIssues() {
    SyncMessagesStub syncMessages = SyncMessagesStub.replaceSyncMessagesService(getProject());
    String mismatchingEncoding = "UTF-8";
    myStrategy.setMismatchingEncoding(mismatchingEncoding);
    myStrategy.fixAndReportFoundIssues();
    SyncMessage message = syncMessages.getFirstReportedMessage();
    assertNotNull(message);
    String[] text = message.getText();
    assertThat(text).hasLength(2);
    assertThat(text[0]).startsWith("The project encoding (ISO-8859-1) has been reset");
    verify(myEncodings, times(1)).setDefaultCharsetName(mismatchingEncoding);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) SyncMessagesStub(com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)

Aggregations

SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)12 SyncMessagesStub (com.android.tools.idea.gradle.project.sync.messages.SyncMessagesStub)12 Project (com.intellij.openapi.project.Project)5 Module (com.intellij.openapi.module.Module)3 AndroidProject (com.android.builder.model.AndroidProject)2 ProjectSubset (com.android.tools.idea.gradle.project.subset.ProjectSubset)2 File (java.io.File)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)1 ArtifactDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 GradleSyncSummary (com.android.tools.idea.gradle.project.sync.GradleSyncSummary)1 GradleUtil.getAndroidProject (com.android.tools.idea.gradle.util.GradleUtil.getAndroidProject)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1