Skip to content

Commit 01a6811

Browse files
committed
Merge branch 'release/2.6'
2 parents 074533a + a6d40e8 commit 01a6811

File tree

9 files changed

+404
-94
lines changed

9 files changed

+404
-94
lines changed

rcp/org.eclipse.rcptt.ui/src/org/eclipse/rcptt/ui/tags/TagsView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ public void focusLost(FocusEvent e) {
149149
Job setInputJob = new UIJob(tagsViewer.getControl().getDisplay(), "Initialize tags view") {
150150
@Override
151151
public IStatus runInUIThread(IProgressMonitor monitor) {
152+
if (tagsViewer.getControl().isDisposed()) {
153+
return Status.OK_STATUS;
154+
}
152155
final TagsRegistry tagsRegistry = Q7UIPlugin.getDefault().getTags();
153156
tagsLabelListener = new EContentAdapter() {
154157
@Override

rcpttTests/platform_tests/Recording/GetTooltipsWhenColumnsWithoutText.test

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Element-Type: testcase
66
Element-Version: 3.0
77
External-Reference:
88
Id: _XS8ZEFqHEeSjvvK1muLiaA
9-
Runtime-Version: 2.5.5.202404041628
10-
Save-Time: 3/8/25, 11:12 PM
9+
Runtime-Version: 2.6.0.qualifier
10+
Save-Time: 5/9/25, 11:35 PM
1111
Testcase-Type: ecl
1212

1313
------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
@@ -24,14 +24,12 @@ get-view Tasks | get-tree | get-item 1 -column Priority
2424
| equals "TODO Auto-generated method stub" | verify-true
2525

2626
with [get-view Tasks | get-tree] {
27-
get-item "FIXME Very important action" -column Description | get-property "values['Priority']" | equals 2
28-
| verify-true
29-
get-item "FIXME Very important action" -column Description | get-property "values['Completion']" | equals false
30-
| verify-true
31-
get-item "TODO Auto-generated method stub" -column Description | get-property "values['Priority']" | equals 1
32-
| verify-true
33-
get-item "TODO Auto-generated method stub" -column Description | get-property "values['Completion']"
34-
| equals false | verify-true
27+
with [get-item -path "FIXME Very important action" -column Description] {
28+
get-property "cells[1].image.path" | equals "org.eclipse.ui.ide/icons/full/obj16/hprio_tsk.png" | verify-true
29+
get-property "cells[1].image" | equals "" | verify-false
30+
}
31+
get-item "TODO Auto-generated method stub" -column Description | get-property "cells[1].image" | equals "" | verify-true
32+
3533
}
3634

3735
------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--

runtime/tesla/org.eclipse.rcptt.tesla.recording.swt/src/org/eclipse/rcptt/tesla/recording/core/swt/SWTAssertManager.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,13 @@ public void run() {
887887
selectionShell.setBackground(selectionShell.getDisplay()
888888
.getSystemColor(SWT.COLOR_RED));
889889
selectionShell.setText("Hover");
890+
Shell copy = selectionShell;
891+
copy.addDisposeListener(ignored -> {
892+
Region region = copy.getRegion();
893+
if (region != null) {
894+
region.dispose();
895+
}
896+
});
890897
disposeMenuPopups();
891898
clearPopupMenus();
892899
}

runtime/tesla/org.eclipse.rcptt.tesla.swt/src/org/eclipse/rcptt/tesla/internal/ui/player/SWTModelMapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,12 @@ private static Object getColumnValue(org.eclipse.swt.widgets.Widget widget,
914914
columnViewer, "editingSupport");
915915
Object value = null;
916916
if (es != null) {
917-
value = TeslaSWTAccess.callMethod(EditingSupport.class, es,
917+
if ((Boolean)TeslaSWTAccess.callMethod(EditingSupport.class, es,
918+
"canEdit", new Class[] { Object.class }, ((Item) widget).getData())) {
919+
value = TeslaSWTAccess.callMethod(EditingSupport.class, es,
918920
"getValue", new Class[] { Object.class },
919921
((Item) widget).getData());
922+
}
920923
}
921924
return value;
922925
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Xored Software Inc and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* Contributors:
9+
* Xored Software Inc - initial API and implementation and/or initial documentation
10+
*******************************************************************************/
11+
package org.eclipse.rcptt.core.tests;
12+
13+
import java.util.Arrays;
14+
15+
import org.eclipse.core.runtime.CoreException;
16+
import org.eclipse.core.runtime.ILog;
17+
import org.eclipse.core.runtime.ILogListener;
18+
import org.eclipse.core.runtime.IStatus;
19+
import org.eclipse.core.runtime.MultiStatus;
20+
import org.eclipse.core.runtime.Platform;
21+
import org.junit.rules.ExternalResource;
22+
import org.osgi.framework.FrameworkUtil;
23+
24+
public class NoErrorsInLog extends ExternalResource {
25+
26+
private final ILog log;
27+
private final MultiStatus statusLog;
28+
private final ILogListener listener = new ILogListener() {
29+
30+
@Override
31+
public void logging(IStatus status, String plugin) {
32+
synchronized (statusLog) {
33+
statusLog.add(status);
34+
}
35+
}
36+
};
37+
38+
public NoErrorsInLog(Class<?> clazzToWatchLogFor) {
39+
this.log = Platform.getLog(FrameworkUtil.getBundle(clazzToWatchLogFor));
40+
this.statusLog = new MultiStatus("org.eclipse.rcptt.tesla.swt.test", 0, "Errors in the error log", null);
41+
}
42+
43+
public void assertNoErrors() {
44+
synchronized (statusLog) {
45+
checkErrors();
46+
}
47+
}
48+
49+
@Override
50+
protected void before() throws Throwable {
51+
super.before();
52+
log.addLogListener(listener);
53+
}
54+
55+
@Override
56+
protected void after() {
57+
System.gc(); // Detect leaks with org.eclipse.rcptt.core.persistence.LeakDetector
58+
log.removeLogListener(listener);
59+
synchronized (statusLog) {
60+
checkErrors();
61+
}
62+
super.after();
63+
}
64+
65+
private void checkErrors() throws AssertionError {
66+
if (statusLog.matches(IStatus.ERROR)) {
67+
Arrays.stream(statusLog.getChildren()).filter(s -> s.matches(IStatus.ERROR)).map(s -> s.getException())
68+
.filter(RuntimeException.class::isInstance).map(RuntimeException.class::cast).forEach(e -> {
69+
throw e;
70+
});
71+
throw new AssertionError(new CoreException(statusLog));
72+
}
73+
}
74+
75+
}
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2019 Xored Software Inc and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-v20.html
7+
*
8+
* Contributors:
9+
* Xored Software Inc - initial API and implementation and/or initial documentation
10+
*******************************************************************************/
11+
package org.eclipse.rcptt.core.tests.model;
12+
13+
import static org.junit.Assert.*;
14+
15+
import org.eclipse.core.resources.IProject;
16+
import org.eclipse.core.resources.IProjectDescription;
17+
import org.eclipse.core.resources.IWorkspace;
18+
import org.eclipse.core.resources.ResourcesPlugin;
19+
import org.eclipse.core.runtime.CoreException;
20+
import org.eclipse.core.runtime.NullProgressMonitor;
21+
import org.eclipse.rcptt.core.Scenarios;
22+
import org.eclipse.rcptt.core.model.IElementChangedListener;
23+
import org.eclipse.rcptt.core.model.IQ7NamedElement;
24+
import org.eclipse.rcptt.core.model.IQ7Project;
25+
import org.eclipse.rcptt.core.model.ITestCase;
26+
import org.eclipse.rcptt.core.model.ModelException;
27+
import org.eclipse.rcptt.core.nature.RcpttNature;
28+
import org.eclipse.rcptt.core.tests.NoErrorsInLog;
29+
import org.eclipse.rcptt.core.workspace.RcpttCore;
30+
import org.junit.After;
31+
import org.junit.Assert;
32+
import org.junit.Before;
33+
import org.junit.Rule;
34+
import org.junit.Test;
35+
36+
public class WorkingCopyTest {
37+
static String PRJ_NAME = "workingCopyTests";
38+
private static final IWorkspace WORKSPACE = ResourcesPlugin.getWorkspace();
39+
private static final IProject PROJECT = WORKSPACE.getRoot().getProject(PRJ_NAME);
40+
private IQ7Project q7project;
41+
private static final int LEAK_SIZE = 100;
42+
43+
44+
@Rule
45+
public final NoErrorsInLog NO_ERRORS = new NoErrorsInLog(RcpttCore.class);
46+
47+
@Before
48+
@After
49+
public void cleanup() throws CoreException {
50+
for (IProject i: WORKSPACE.getRoot().getProjects()) {
51+
i.delete(true, true, null);
52+
}
53+
}
54+
55+
@Before
56+
public void before() throws CoreException {
57+
IProjectDescription deQ7ion = WORKSPACE.newProjectDescription(PROJECT.getName());
58+
deQ7ion.setNatureIds(new String[] { RcpttNature.NATURE_ID });
59+
PROJECT.create(deQ7ion, null);
60+
q7project = RcpttCore.create(PROJECT);
61+
PROJECT.open(null);
62+
}
63+
64+
@Test
65+
public void testNewTestcaseAppear() throws ModelException {
66+
IQ7Project prj = q7project;
67+
ITestCase testcase = prj.getRootFolder().createTestCase("mytestcase",
68+
true, new NullProgressMonitor());
69+
70+
ITestCase copy = (ITestCase) testcase
71+
.getWorkingCopy(new NullProgressMonitor());
72+
73+
copy.setElementName("new test case name");
74+
copy.setTags("tag0");
75+
76+
assertEquals("mytestcase", testcase.getElementName());
77+
assertEquals("new test case name", copy.getElementName());
78+
79+
copy.commitWorkingCopy(true, new NullProgressMonitor());
80+
assertEquals("new test case name", testcase.getElementName());
81+
}
82+
83+
84+
@Test
85+
public void queryDeletedResource() throws CoreException, InterruptedException {
86+
IQ7Project prj = q7project;
87+
for (int i = 0; i < LEAK_SIZE; i++) {
88+
ITestCase testcase = prj.getRootFolder().createTestCase("mytestcase"+i,true, new NullProgressMonitor());
89+
PROJECT.getFile(testcase.getName()).delete(true, null);
90+
try {
91+
testcase.getContexts(); // may cause leaks
92+
Assert.fail();
93+
} catch(ModelException e) {
94+
// expected, as resource is deleted
95+
}
96+
System.gc();
97+
NO_ERRORS.assertNoErrors();
98+
}
99+
}
100+
101+
@Test
102+
public void deleteWorkingCopyResource() throws CoreException {
103+
for (int i = 0; i < LEAK_SIZE; i++) {
104+
ITestCase testcase = q7project.getRootFolder().createTestCase("mytestcase" + i, true, new NullProgressMonitor());
105+
106+
ITestCase copy = (ITestCase) testcase
107+
.getWorkingCopy(new NullProgressMonitor());
108+
assertTrue(testcase.exists());
109+
assertFalse(copy.hasUnsavedChanges());
110+
PROJECT.getFile(testcase.getName()).delete(true, null);
111+
System.gc();
112+
NO_ERRORS.assertNoErrors();
113+
}
114+
}
115+
116+
@Test
117+
public void deleteEditedResource() throws CoreException, InterruptedException {
118+
IQ7Project prj = q7project;
119+
IElementChangedListener listener = event -> {
120+
for (IQ7NamedElement i : event.getDelta().getNamedElements()) {
121+
try {
122+
i.getDescription(); // causes element info revival
123+
} catch (ModelException e) {
124+
// Does not exist
125+
}
126+
}
127+
};
128+
RcpttCore.addElementChangedListener(listener);
129+
try {
130+
for (int i = 0; i < LEAK_SIZE; i++) {
131+
ITestCase testcase = prj.getRootFolder().createTestCase("mytestcase"+i,true, new NullProgressMonitor());
132+
133+
ITestCase copy = (ITestCase) testcase
134+
.getWorkingCopy(new NullProgressMonitor());
135+
assertTrue(testcase.exists());
136+
assertFalse(copy.hasUnsavedChanges());
137+
PROJECT.getFile(testcase.getName()).delete(true, null);
138+
try {
139+
testcase.getElementName();
140+
} catch (ModelException e) {
141+
// Does not exist
142+
}
143+
try {
144+
copy.getElementName();
145+
} catch (ModelException e) {
146+
// Does not exist
147+
}
148+
copy.discardWorkingCopy();
149+
System.gc();
150+
NO_ERRORS.assertNoErrors();
151+
assertFalse(testcase.exists());
152+
}
153+
} finally {
154+
RcpttCore.removeElementChangedListener(listener);
155+
}
156+
}
157+
158+
159+
}

tests/org.eclipse.rcptt.core.tests/src/org/eclipse/rcptt/core/tests/model/WorkingCopyTests.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)