Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 0c846a2

Browse files
committed
Fix compatibility with Eclipse 4.4
Replace BaseClassLoader with EquinoxClassLoader, fix ViewMenu recognition, fix dependency in com.windowtester.swt.runtime, fix method call after signature changed, fix AbstractRecorderSmokeTest.closeWelcomePageIfNecessary(), use Eclipse Luna repository
1 parent 10ca954 commit 0c846a2

File tree

6 files changed

+120
-105
lines changed

6 files changed

+120
-105
lines changed

com.windowtester.eclipse.ui/src/com/windowtester/eclipse/ui/launcher/RecorderSWTLaunchConfDelegate.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
/*******************************************************************************
2-
* Copyright (c) 2012 Google, Inc.
3-
* All rights reserved. This program and the accompanying materials
4-
* are made available under the terms of the Eclipse Public License v1.0
5-
* which accompanies this distribution, and is available at
6-
* http://www.eclipse.org/legal/epl-v10.html
7-
*
8-
* Contributors:
9-
* Google, Inc. - initial API and implementation
10-
*******************************************************************************/
1+
/*******************************************************************************
2+
* Copyright (c) 2012 Google, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Google, Inc. - initial API and implementation
10+
*******************************************************************************/
1111
package com.windowtester.eclipse.ui.launcher;
1212

1313
import java.util.ArrayList;
@@ -91,7 +91,7 @@ protected void mapSources(ILaunchConfigurationWorkingCopy wc) throws CoreExcepti
9191
* @throws CoreException
9292
*/
9393
private void setEnvironment(ILaunchConfigurationWorkingCopy wc) throws CoreException {
94-
wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<?, ?>)wcSwt.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<?, ?>)null));
94+
wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>)wcSwt.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map<String, String>)null));
9595
wc.setAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, wcSwt.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false));
9696
}
9797

com.windowtester.runtime/src/com/windowtester/internal/runtime/bundle/BundleResolver.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
/*******************************************************************************
2-
* Copyright (c) 2012 Google, Inc.
3-
* All rights reserved. This program and the accompanying materials
4-
* are made available under the terms of the Eclipse Public License v1.0
5-
* which accompanies this distribution, and is available at
6-
* http://www.eclipse.org/legal/epl-v10.html
7-
*
8-
* Contributors:
9-
* Google, Inc. - initial API and implementation
10-
*******************************************************************************/
1+
/*******************************************************************************
2+
* Copyright (c) 2012 Google, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Google, Inc. - initial API and implementation
10+
*******************************************************************************/
1111
package com.windowtester.internal.runtime.bundle;
1212

13-
import org.eclipse.osgi.baseadaptor.BaseData;
14-
import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
13+
import org.eclipse.osgi.internal.loader.EquinoxClassLoader;
1514
import org.osgi.framework.Bundle;
1615

1716
/**
@@ -24,12 +23,18 @@ public class BundleResolver {
2423
* Get the bundle associated with this class.
2524
*/
2625
public static Bundle bundleForClass(Class<?> cls) {
26+
2727
ClassLoader classLoader = cls.getClassLoader();
28-
if (classLoader instanceof BaseClassLoader) {
29-
BaseClassLoader loader = (BaseClassLoader)classLoader;
30-
BaseData baseData = loader.getClasspathManager().getBaseData();
31-
return baseData.getBundle();
28+
if (classLoader instanceof EquinoxClassLoader) {
29+
EquinoxClassLoader loader = (EquinoxClassLoader) classLoader;
30+
return loader.getBundle();
3231
}
32+
/* Does not work anymore in Eclipse 4.4.2 */
33+
// if (classLoader instanceof BaseClassLoader) {
34+
// BaseClassLoader loader = (BaseClassLoader)classLoader;
35+
// BaseData baseData = loader.getClasspathManager().getBaseData();
36+
// return baseData.getBundle();
37+
// }
3338
return null;
3439
}
3540

com.windowtester.swt.runtime/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Require-Bundle: org.eclipse.swt,
9090
com.windowtester.runtime;visibility:=reexport,
9191
com.windowtester.swing.runtime,
9292
org.eclipse.e4.ui.model.workbench,
93-
org.eclipse.e4.ui.workbench.renderers.swt
93+
org.eclipse.e4.ui.workbench.renderers.swt,
94+
org.eclipse.e4.ui.workbench
9495
Bundle-ActivationPolicy: lazy
9596
Bundle-RequiredExecutionEnvironment: J2SE-1.5

com.windowtester.swt.runtime/src/com/windowtester/runtime/swt/internal/widgets/CTabFolderReference.java

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
/*******************************************************************************
2-
* Copyright (c) 2012 Google, Inc.
3-
* All rights reserved. This program and the accompanying materials
4-
* are made available under the terms of the Eclipse Public License v1.0
5-
* which accompanies this distribution, and is available at
6-
* http://www.eclipse.org/legal/epl-v10.html
7-
*
8-
* Contributors:
9-
* Google, Inc. - initial API and implementation
10-
*******************************************************************************/
1+
/*******************************************************************************
2+
* Copyright (c) 2012 Google, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-v10.html
7+
*
8+
* Contributors:
9+
* Google, Inc. - initial API and implementation
10+
*******************************************************************************/
1111
package com.windowtester.runtime.swt.internal.widgets;
1212

1313
import java.util.concurrent.Callable;
1414

15-
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
16-
import org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer;
15+
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
16+
import org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer;
1717
import org.eclipse.swt.custom.CTabFolder;
1818
import org.eclipse.swt.widgets.Composite;
19-
import org.eclipse.swt.widgets.Control;
20-
import org.eclipse.swt.widgets.ToolBar;
21-
import org.eclipse.swt.widgets.ToolItem;
19+
import org.eclipse.swt.widgets.Control;
20+
import org.eclipse.swt.widgets.ToolBar;
21+
import org.eclipse.swt.widgets.ToolItem;
2222

2323
/**
2424
* A {@link CTabFolder} reference.
@@ -65,40 +65,49 @@ public CTabItemReference[] call() throws Exception {
6565
}
6666
});
6767
}
68-
69-
/**
70-
* Returns "ViewMenu" ToolItemReference <br/>
71-
* Works only with Eclipse 4.x!
72-
*
73-
* @return
74-
*/
75-
public ToolItemReference getViewMenu(){
76-
return displayRef.execute(new Callable<ToolItemReference>() {
77-
public ToolItemReference call() throws Exception {
78-
for(Control control : widget.getChildren()){
79-
if(control instanceof Composite){
80-
Composite comp = (Composite) control;
81-
for(Control compChildren : comp.getChildren()){
82-
if(compChildren instanceof ToolBar){
83-
ToolBar compChildrenToolBar = (ToolBar) compChildren;
84-
for(ToolItem compChildrenToolBarItem : compChildrenToolBar.getItems()){
85-
//TODO: Improve check (without internal classes?)
86-
MMenu mmenu = (MMenu) compChildrenToolBarItem.getData("theMenu");
87-
if(mmenu != null && mmenu.getTags().contains(StackRenderer.TAG_VIEW_MENU)){
88-
//System.out.println("View Menu found!");
89-
return asReferenceOfType(compChildrenToolBarItem, ToolItemReference.class);
90-
}
91-
}
92-
}
93-
}
94-
}
95-
}
96-
return null;
97-
}
98-
});
99-
100-
}
101-
68+
69+
/**
70+
* Returns "ViewMenu" ToolItemReference <br/>
71+
* Works only with Eclipse 4.x!
72+
*
73+
* @return
74+
*/
75+
public ToolItemReference getViewMenu(){
76+
return displayRef.execute(new Callable<ToolItemReference>() {
77+
public ToolItemReference call() throws Exception {
78+
for(Control control : widget.getChildren()){
79+
if(control instanceof Composite){
80+
Composite comp = (Composite) control;
81+
for(Control compChildren : comp.getChildren()){
82+
//System.out.println("compChildren: " + compChildren.getClass().getSimpleName() + " " + compChildren.getData());
83+
if(compChildren instanceof ToolBar){
84+
ToolBar compChildrenToolBar = (ToolBar) compChildren;
85+
//Works only with Eclipse 4.4
86+
if("ViewMenu".equals(compChildrenToolBar.getData())) {
87+
ToolItem compChildrenToolBarItem = compChildrenToolBar.getItems()[0];
88+
return asReferenceOfType(compChildrenToolBarItem, ToolItemReference.class);
89+
}
90+
91+
//Works only with Eclipse 4.x - 4.3
92+
for(ToolItem compChildrenToolBarItem : compChildrenToolBar.getItems()){
93+
//System.out.println("compChildrenToolBarItem: " + compChildrenToolBarItem.getClass().getSimpleName() + " " + compChildrenToolBarItem.getData());
94+
//TODO: Improve check (without internal classes?)
95+
MMenu mmenu = (MMenu) compChildrenToolBarItem.getData("theMenu");
96+
if(mmenu != null && mmenu.getTags().contains(StackRenderer.TAG_VIEW_MENU)){
97+
//System.out.println("View Menu found!");
98+
return asReferenceOfType(compChildrenToolBarItem, ToolItemReference.class);
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}
105+
return null;
106+
}
107+
});
108+
109+
}
110+
102111
// /* (non-Javadoc)
103112
// * @see com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference#accept(com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.Visitor)
104113
// */

com.windowtester_parent/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
<repositories>
2828
<repository>
29-
<id>juno</id>
29+
<id>luna</id>
3030
<layout>p2</layout>
31-
<url>http://download.eclipse.org/releases/juno</url>
31+
<url>http://download.eclipse.org/releases/luna</url>
3232
</repository>
3333
</repositories>
3434

@@ -133,7 +133,7 @@
133133
<artifactId>tycho-packaging-plugin</artifactId>
134134
<version>${tycho-version}</version>
135135
<configuration>
136-
<format>'e4x'yyyyMMddHHmm</format>
136+
<format>'e44x'yyyyMMddHHmm</format>
137137
</configuration>
138138
</plugin>
139139
<plugin>

com.windowtester_test/src/com/windowtester/test/eclipse/codegen/AbstractRecorderSmokeTest.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,24 @@
1313
import org.osgi.framework.Bundle;
1414

1515
import com.windowtester.recorder.event.ISemanticEvent;
16-
import com.windowtester.runtime.WidgetSearchException;
17-
import com.windowtester.runtime.locator.IWidgetLocator;
18-
import com.windowtester.runtime.locator.XYLocator;
16+
import com.windowtester.runtime.WaitTimedOutException;
1917
import com.windowtester.runtime.swt.UITestCaseSWT;
2018
import com.windowtester.runtime.swt.locator.CTabItemLocator;
2119
import com.windowtester.runtime.util.TestMonitor;
2220
import com.windowtester.test.eclipse.EclipseUtil;
2321
import com.windowtester.test.util.PlatformEventWatcherAndCodegenerator;
2422
import com.windowtester.test.util.PlatformEventWatcherAndCodegenerator.API;
2523

26-
/*******************************************************************************
27-
* Copyright (c) 2012 Google, Inc.
28-
* All rights reserved. This program and the accompanying materials
29-
* are made available under the terms of the Eclipse Public License v1.0
30-
* which accompanies this distribution, and is available at
31-
* http://www.eclipse.org/legal/epl-v10.html
32-
*
33-
* Contributors:
34-
* Google, Inc. - initial API and implementation
35-
*******************************************************************************/
24+
/*******************************************************************************
25+
* Copyright (c) 2012 Google, Inc.
26+
* All rights reserved. This program and the accompanying materials
27+
* are made available under the terms of the Eclipse Public License v1.0
28+
* which accompanies this distribution, and is available at
29+
* http://www.eclipse.org/legal/epl-v10.html
30+
*
31+
* Contributors:
32+
* Google, Inc. - initial API and implementation
33+
*******************************************************************************/
3634
public abstract class AbstractRecorderSmokeTest extends UITestCaseSWT {
3735

3836
private static final boolean DISPLAY_EVENTS = true;
@@ -175,19 +173,21 @@ private PlatformEventWatcherAndCodegenerator getWatcher() {
175173
/**
176174
* Recent versions of Eclipse do not close the welcome page when view
177175
* is opened. Make sure it gets closed.
178-
* @throws WidgetSearchException
176+
* @throws Exception
177+
* @throws WaitTimedOutException
179178
*/
180-
protected void closeWelcomePageIfNecessary() throws WidgetSearchException {
181-
IWidgetLocator[] welcomeTab = getUI().findAll(new CTabItemLocator("Welcome"));
182-
if (welcomeTab.length == 0)
183-
return;
184-
// TODO: compute x based on tab width to avoid font dependencies
185-
int x = 88;
186-
if (abbot.Platform.isOSX())
187-
x = 95;
188-
else if (abbot.Platform.isLinux())
189-
x = 100;
190-
getUI().click(new XYLocator(welcomeTab[0], x, 12));
179+
protected void closeWelcomePageIfNecessary() throws WaitTimedOutException, Exception {
180+
getUI().ensureThat(new CTabItemLocator("Welcome").isClosed());
181+
// IWidgetLocator[] welcomeTab = getUI().findAll(new CTabItemLocator("Welcome"));
182+
// if (welcomeTab.length == 0)
183+
// return;
184+
// // TODO: compute x based on tab width to avoid font dependencies
185+
// int x = 88;
186+
// if (abbot.Platform.isOSX())
187+
// x = 95;
188+
// else if (abbot.Platform.isLinux())
189+
// x = 100;
190+
// getUI().click(new XYLocator(welcomeTab[0], x, 12));
191191
}
192192

193193
////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)