use of org.fest.swing.edt.GuiTask in project intellij-community by JetBrains.
the class GuiTestBase method closeAllProjects.
@SuppressWarnings("UnusedDeclaration")
protected // Called by GuiTestRunner via reflection.
void closeAllProjects() {
pause(new Condition("Close all projects") {
@Override
public boolean test() {
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
TransactionGuard.submitTransaction(ApplicationManager.getApplication(), () -> {
for (Project project : openProjects) {
assertTrue("Failed to close project " + quote(project.getName()), closeAndDispose(project));
}
});
}
});
return ProjectManager.getInstance().getOpenProjects().length == 0;
}
}, SHORT_TIMEOUT);
//noinspection ConstantConditions
boolean welcomeFrameShown = execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (openProjects.length == 0) {
WelcomeFrame.showNow();
WindowManagerImpl windowManager = (WindowManagerImpl) WindowManager.getInstance();
windowManager.disposeRootFrame();
return true;
}
return false;
}
});
if (welcomeFrameShown) {
pause(new Condition("'Welcome' frame to show up") {
@Override
public boolean test() {
for (Frame frame : Frame.getFrames()) {
if (frame == WelcomeFrame.getInstance() && frame.isShowing()) {
return true;
}
}
return false;
}
}, SHORT_TIMEOUT);
}
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class GradleSyncTest method sdkCreationForAddons.
// https://code.google.com/p/android/issues/detail?id=185313
@Test
public void sdkCreationForAddons() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
Project project = ideFrame.getProject();
Module appModule = ideFrame.getModule("app");
GradleBuildFile buildFile = GradleBuildFile.get(appModule);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
runWriteCommandAction(project, () -> buildFile.setValue(BuildFileKey.COMPILE_SDK_VERSION, "Google Inc.:Google APIs:24"));
}
});
ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
Sdk sdk = ModuleRootManager.getInstance(appModule).getSdk();
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
SdkAdditionalData data = sdk.getSdkAdditionalData();
assertThat(data).isInstanceOf(AndroidSdkAdditionalData.class);
AndroidSdkAdditionalData androidSdkData = (AndroidSdkAdditionalData) data;
IAndroidTarget buildTarget = androidSdkData.getBuildTarget(sdkData);
// By checking that there are no additional libraries in the SDK, we are verifying that an additional SDK was not created for add-ons.
assertThat(buildTarget.getAdditionalLibraries()).hasSize(0);
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class GradleSyncTest method gradleModelCache.
@Test
public void gradleModelCache() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrameFixture = guiTest.ideFrame();
File projectPath = ideFrameFixture.getProjectPath();
ideFrameFixture.closeProject();
AtomicBoolean syncSkipped = new AtomicBoolean(false);
// Reopen project and verify that sync was skipped (i.e. model loaded from cache)
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
Project project = projectManager.convertAndLoadProject(projectPath.getPath());
GradleSyncState.subscribe(project, new GradleSyncListener.Adapter() {
@Override
public void syncSkipped(@NotNull Project project) {
syncSkipped.set(true);
}
});
projectManager.openProject(project);
}
});
Wait.seconds(5).expecting("sync to be skipped").until(syncSkipped::get);
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class GradleSyncTest method aarSourceAttachments.
@Test
public void aarSourceAttachments() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
Project project = ideFrame.getProject();
Module appModule = ideFrame.getModule("app");
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
runWriteCommandAction(project, () -> {
GradleBuildModel buildModel = GradleBuildModel.get(appModule);
String newDependency = "com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4@aar";
buildModel.dependencies().addArtifact(COMPILE, newDependency);
buildModel.applyChanges();
});
}
});
ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
// Verify that the library has sources.
LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
String libraryName = "mapbox-android-sdk-0.7.4";
Library library = libraryTable.getLibraryByName(libraryName);
VirtualFile[] files = library.getFiles(SOURCES);
assertThat(files).asList().hasSize(1);
}
use of org.fest.swing.edt.GuiTask in project android by JetBrains.
the class ConvertToWebpActionTest method invokeConvertToWebpAction.
private static void invokeConvertToWebpAction(@NotNull Project project, @NotNull VirtualFile res) {
// Ideally I'd invoke the context menu on the res node, "Convert to WebP Format",
// but the pane fixture doesn't support invoking context menu actions yet.
// Shortcut:
//ProjectViewFixture.PaneFixture pane = projectFrame.getProjectView().selectAndroidPane();
//pane.selectByPath("app", "res");
Map<String, Object> data = Maps.newHashMap();
data.put(CommonDataKeys.VIRTUAL_FILE_ARRAY.getName(), new VirtualFile[] { res });
data.put(CommonDataKeys.PROJECT.getName(), project);
DataContext context = SimpleDataContext.getSimpleContext(data, null);
AnActionEvent actionEvent = new AnActionEvent(null, context, "test", new Presentation(), ActionManager.getInstance(), 0);
ConvertToWebpAction action = new ConvertToWebpAction();
GuiActionRunner.execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> action.actionPerformed(actionEvent));
}
});
}
Aggregations