fix ProjectOpeningTest

GitOrigin-RevId: 75548ee7fd3a7319c2b8d2d7c0dd57a48d202403
This commit is contained in:
Vladimir Krivosheev
2019-06-11 18:07:01 +03:00
committed by intellij-monorepo-bot
parent 7839d203ef
commit 30cb7b88c7
2 changed files with 23 additions and 13 deletions
@@ -294,6 +294,13 @@ public abstract class ExtensionPointImpl<T> implements ExtensionPoint<T>, Iterab
assertBeforeProcessing();
CHECK_CANCELED.run();
if (isInReadOnlyMode()) {
for (T extension : myExtensionsCache) {
consumer.accept(extension, myDescriptor /* doesn't matter for tests */);
}
return;
}
List<ExtensionComponentAdapter> adapters = myAdapters;
int size = adapters.size();
if (size == 0) {
@@ -376,6 +383,7 @@ public abstract class ExtensionPointImpl<T> implements ExtensionPoint<T>, Iterab
@NotNull
private synchronized T[] processAdapters() {
assertBeforeProcessing();
assertNotReadOnlyMode();
long startTime = StartUpMeasurer.getCurrentTime();
@@ -473,7 +481,6 @@ public abstract class ExtensionPointImpl<T> implements ExtensionPoint<T>, Iterab
throw new IllegalStateException("Recursive processAdapters() detected. You must have called 'getExtensions()' from within your extension constructor - don't. " +
"Either pass extension via constructor parameter or call getExtensions() later.");
}
assertNotReadOnlyMode();
}
// used in upsource
@@ -529,13 +536,15 @@ public abstract class ExtensionPointImpl<T> implements ExtensionPoint<T>, Iterab
myExtensionsCacheAsArray = list.toArray(ArrayUtil.newArray(getExtensionClass(), 0));
POINTS_IN_READONLY_MODE.add(this);
if (oldList != null) {
for (T extension : oldList) {
notifyListenersOnRemove(extension, null, myListeners);
if (myListeners.length > 0) {
if (oldList != null) {
for (T extension : oldList) {
notifyListenersOnRemove(extension, null, myListeners);
}
}
for (T extension : list) {
notifyListenersOnAdd(extension, null, myListeners);
}
}
for (T extension : list) {
notifyListenersOnAdd(extension, null, myListeners);
}
Disposer.register(parentDisposable, new Disposable() {
@@ -17,25 +17,26 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import static com.intellij.openapi.startup.StartupActivity.POST_STARTUP_ACTIVITY;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
/**
* @author Dmitry Avdeev
*/
public class ProjectOpeningTest extends PlatformTestCase {
public void testOpenProjectCancelling() throws Exception {
File foo = createTempDir("foo");
Project project = null;
MyStartupActivity activity = new MyStartupActivity();
POST_STARTUP_ACTIVITY.getPoint(null).registerExtension(activity, getTestRootDisposable());
PlatformTestUtil.maskExtensions(POST_STARTUP_ACTIVITY, Collections.singletonList(activity), getTestRootDisposable());
try {
ProjectManagerEx manager = ProjectManagerEx.getInstanceEx();
File foo = createTempDir("foo");
project = manager.createProject(null, foo.getPath());
assertFalse(manager.openProject(project));
assertFalse(project.isOpen());
assertTrue(activity.passed);
assertThat(manager.openProject(project)).isFalse();
assertThat(project.isOpen()).isFalse();
assertThat(activity.passed).isTrue();
}
finally {
closeProject(project);