use of com.android.tools.idea.tests.gui.framework.fixture.MessagesToolWindowFixture.HyperlinkFixture in project android by JetBrains.
the class GradleSyncTest method syncDuringOfflineMode.
@Test
public void syncDuringOfflineMode() throws IOException {
String hyperlinkText = "Disable offline mode and sync project";
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
File buildFile = new File(ideFrame.getProjectPath(), join("app", FN_BUILD_GRADLE));
assertAbout(file()).that(buildFile).isFile();
appendToFile(buildFile, "dependencies { compile 'something:not:exists' }");
GradleSettings gradleSettings = GradleSettings.getInstance(ideFrame.getProject());
gradleSettings.setOfflineWork(true);
ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
MessagesToolWindowFixture messagesToolWindow = ideFrame.getMessagesToolWindow();
MessageFixture message = messagesToolWindow.getGradleSyncContent().findMessage(ERROR, firstLineStartingWith("Failed to resolve:"));
HyperlinkFixture hyperlink = message.findHyperlink(hyperlinkText);
hyperlink.click();
assertFalse(gradleSettings.isOfflineWork());
ideFrame.waitForGradleProjectSyncToFinish();
messagesToolWindow = ideFrame.getMessagesToolWindow();
message = messagesToolWindow.getGradleSyncContent().findMessage(ERROR, firstLineStartingWith("Failed to resolve:"));
try {
message.findHyperlink(hyperlinkText);
fail(hyperlinkText + " link still present");
} catch (AssertionError e) {
// After offline mode is disable, the previous hyperlink will disappear after next sync
assertThat(e.getMessage()).contains("Failed to find URL");
assertThat(e.getMessage()).contains(hyperlinkText);
}
}
Aggregations