Search in sources :

Example 1 with TestMessagesDialog

use of com.android.tools.idea.testing.TestMessagesDialog in project android by JetBrains.

the class GradleDependencyManagerTest method ignore_testDependencyAarIsExplodedForLayoutLib.

@SuppressWarnings("unused")
public void ignore_testDependencyAarIsExplodedForLayoutLib() throws Exception {
    loadSimpleApplication();
    List<GradleCoordinate> dependencies = Collections.singletonList(RECYCLER_VIEW_DEPENDENCY);
    GradleDependencyManager dependencyManager = GradleDependencyManager.getInstance(getProject());
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isNotEmpty();
    Messages.setTestDialog(new TestMessagesDialog(Messages.OK));
    boolean found = dependencyManager.ensureLibraryIsIncluded(myModules.getAppModule(), dependencies, null);
    assertThat(found).isTrue();
    List<ResourceItem> items = AppResourceRepository.getAppResources(myAndroidFacet, true).getResourceItem(ResourceType.DECLARE_STYLEABLE, "RecyclerView");
    assertThat(items).isNotEmpty();
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isEmpty();
}
Also used : TestMessagesDialog(com.android.tools.idea.testing.TestMessagesDialog) GradleCoordinate(com.android.ide.common.repository.GradleCoordinate) ResourceItem(com.android.ide.common.res2.ResourceItem)

Example 2 with TestMessagesDialog

use of com.android.tools.idea.testing.TestMessagesDialog in project android by JetBrains.

the class ForcedPluginPreviewVersionUpgradeStepIdeaTest method testCheckAndPerformUpgradeWhenUserDeclinesUpgrade.

// See https://code.google.com/p/android/issues/detail?id=227927
public void testCheckAndPerformUpgradeWhenUserDeclinesUpgrade() {
    GradleVersion latestPluginVersion = GradleVersion.parse("2.0.0");
    when(myPluginGeneration.getLatestKnownVersion()).thenReturn(latestPluginVersion.toString());
    when(myPluginInfo.getPluginVersion()).thenReturn(GradleVersion.parse("2.0.0-alpha9"));
    // Simulate user canceling upgrade.
    myOriginalTestDialog = ForcedPluginPreviewVersionUpgradeDialog.setTestDialog(new TestMessagesDialog(Messages.CANCEL));
    boolean upgraded = myVersionUpgrade.checkAndPerformUpgrade(getProject(), myPluginInfo);
    assertTrue(upgraded);
    List<SyncMessage> messages = mySyncMessages.getReportedMessages();
    assertThat(messages).hasSize(1);
    String message = messages.get(0).getText()[1];
    assertThat(message).contains("Please update your project to use version 2.0.0.");
    verify(mySyncState).syncEnded();
    verify(myVersionUpdater, never()).updatePluginVersionAndSync(latestPluginVersion, GradleVersion.parse(GRADLE_LATEST_VERSION), true);
}
Also used : SyncMessage(com.android.tools.idea.gradle.project.sync.messages.SyncMessage) TestMessagesDialog(com.android.tools.idea.testing.TestMessagesDialog) GradleVersion(com.android.ide.common.repository.GradleVersion)

Example 3 with TestMessagesDialog

use of com.android.tools.idea.testing.TestMessagesDialog in project android by JetBrains.

the class GradleDependencyManagerTest method testDependencyCanBeCancelledByUser.

public void testDependencyCanBeCancelledByUser() throws Exception {
    loadSimpleApplication();
    List<GradleCoordinate> dependencies = Collections.singletonList(RECYCLER_VIEW_DEPENDENCY);
    GradleDependencyManager dependencyManager = GradleDependencyManager.getInstance(getProject());
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isNotEmpty();
    Messages.setTestDialog(new TestMessagesDialog(Messages.NO));
    boolean found = dependencyManager.ensureLibraryIsIncluded(myModules.getAppModule(), dependencies, null);
    assertThat(found).isFalse();
    assertThat(dependencyManager.findMissingDependencies(myModules.getAppModule(), dependencies)).isNotEmpty();
}
Also used : TestMessagesDialog(com.android.tools.idea.testing.TestMessagesDialog) GradleCoordinate(com.android.ide.common.repository.GradleCoordinate)

Example 4 with TestMessagesDialog

use of com.android.tools.idea.testing.TestMessagesDialog in project android by JetBrains.

the class GradleDistributionCleanUpTaskTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    myTestDialog = new TestMessagesDialog(Messages.OK);
    Messages.setTestDialog(myTestDialog);
    myCleanUpTask = new GradleDistributionCleanUpTask();
}
Also used : TestMessagesDialog(com.android.tools.idea.testing.TestMessagesDialog)

Example 5 with TestMessagesDialog

use of com.android.tools.idea.testing.TestMessagesDialog in project android by JetBrains.

the class ForcedPluginPreviewVersionUpgradeStepIdeaTest method testCheckAndPerformUpgradeWhenUserAcceptsUpgrade.

public void testCheckAndPerformUpgradeWhenUserAcceptsUpgrade() {
    GradleVersion latestPluginVersion = GradleVersion.parse("2.0.0");
    when(myPluginGeneration.getLatestKnownVersion()).thenReturn(latestPluginVersion.toString());
    when(myPluginInfo.getPluginVersion()).thenReturn(GradleVersion.parse("2.0.0-alpha9"));
    // Simulate user accepting the upgrade.
    myOriginalTestDialog = ForcedPluginPreviewVersionUpgradeDialog.setTestDialog(new TestMessagesDialog(OK));
    boolean upgraded = myVersionUpgrade.checkAndPerformUpgrade(getProject(), myPluginInfo);
    assertTrue(upgraded);
    verify(mySyncState).syncEnded();
    verify(myVersionUpdater).updatePluginVersionAndSync(latestPluginVersion, GradleVersion.parse(GRADLE_LATEST_VERSION), true);
    assertThat(mySyncMessages.getReportedMessages()).isEmpty();
}
Also used : TestMessagesDialog(com.android.tools.idea.testing.TestMessagesDialog) GradleVersion(com.android.ide.common.repository.GradleVersion)

Aggregations

TestMessagesDialog (com.android.tools.idea.testing.TestMessagesDialog)5 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)2 GradleVersion (com.android.ide.common.repository.GradleVersion)2 ResourceItem (com.android.ide.common.res2.ResourceItem)1 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)1