use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.
the class GradleProjectSyncDataTest method testEndToEnd.
public void testEndToEnd() throws Exception {
loadProject(PROJECT_WITH_APPAND_LIB);
Project project = myAndroidFacet.getModule().getProject();
GradleSyncState syncState = GradleSyncState.getInstance(project);
long previousSyncTime = syncState.getSummary().getSyncTimestamp();
GradleProjectSyncData data = GradleProjectSyncData.createFrom(project);
verifyGradleProjectSyncData(data, previousSyncTime);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(outputStream);
oos.writeObject(data);
oos.close();
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
ObjectInputStream ois = new ObjectInputStream(inputStream);
GradleProjectSyncData newData = (GradleProjectSyncData) ois.readObject();
ois.close();
verifyGradleProjectSyncData(newData, previousSyncTime);
}
use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.
the class GradleProjectInfoTest method registerLastSyncTimestamp.
private void registerLastSyncTimestamp(long timestamp) {
GradleSyncSummary summary = mock(GradleSyncSummary.class);
when(summary.getSyncTimestamp()).thenReturn(timestamp);
GradleSyncState syncState = IdeComponents.replaceServiceWithMock(getProject(), GradleSyncState.class);
when(syncState.getSummary()).thenReturn(summary);
}
use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.
the class GradleBuildInvokerTest method simulateLastSyncFailed.
private void simulateLastSyncFailed(boolean failed) {
GradleSyncState syncState = IdeComponents.replaceServiceWithMock(getProject(), GradleSyncState.class);
when(syncState.lastSyncFailed()).thenReturn(failed);
}
use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.
the class IdeFrameFixture method waitForGradleProjectSyncToStart.
@NotNull
public IdeFrameFixture waitForGradleProjectSyncToStart() {
Project project = getProject();
GradleSyncState syncState = GradleSyncState.getInstance(project);
if (!syncState.isSyncInProgress()) {
Wait.seconds(10).expecting("Syncing project " + quote(project.getName()) + " to finish").until(myGradleProjectEventListener::isSyncStarted);
}
return this;
}
use of com.android.tools.idea.gradle.project.sync.GradleSyncState in project android by JetBrains.
the class IdeFrameFixture method waitForGradleProjectSyncToFinish.
private void waitForGradleProjectSyncToFinish(boolean expectSyncFailure) {
Project project = getProject();
// ensure GradleInvoker (in-process build) is always enabled.
AndroidGradleBuildConfiguration buildConfiguration = AndroidGradleBuildConfiguration.getInstance(project);
buildConfiguration.USE_EXPERIMENTAL_FASTER_BUILD = true;
Wait.seconds(10).expecting("Syncing project " + quote(project.getName()) + " to finish").until(() -> {
GradleSyncState syncState = GradleSyncState.getInstance(project);
boolean syncFinished = (myGradleProjectEventListener.isSyncFinished() || syncState.isSyncNeeded() != ThreeState.YES) && !syncState.isSyncInProgress();
if (expectSyncFailure) {
syncFinished = syncFinished && myGradleProjectEventListener.hasSyncError();
}
return syncFinished;
});
waitForGradleSyncAction();
if (myGradleProjectEventListener.hasSyncError()) {
RuntimeException syncError = myGradleProjectEventListener.getSyncError();
myGradleProjectEventListener.reset();
throw syncError;
}
if (!myGradleProjectEventListener.isSyncSkipped()) {
waitForBuildToFinish(SOURCE_GEN);
}
GuiTests.waitForBackgroundTasks(robot());
}
Aggregations