View | Details | Raw Unified | Return to bug 43844
Collapse All | Expand All

(-).classpath (-1 / +3 lines)
Lines 9-15 Link Here
9
    <classpathentry kind="src" path="/org.eclipse.core.resources"/>
9
    <classpathentry kind="src" path="/org.eclipse.core.resources"/>
10
    <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
10
    <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
11
    <classpathentry kind="var" path="ECLIPSE_HOME/startup.jar"/>
11
    <classpathentry kind="var" path="ECLIPSE_HOME/startup.jar"/>
12
    <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
12
    <classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/>
13
    <classpathentry kind="src" path="Benchmark Tests"/>
13
    <classpathentry kind="src" path="Benchmark Tests"/>
14
    <classpathentry exported="true" kind="src" path="/org.eclipse.ui.workbench"/>
15
    <classpathentry kind="src" path="/org.eclipse.core.boot"/>
14
    <classpathentry kind="output" path="bin"/>
16
    <classpathentry kind="output" path="bin"/>
15
</classpath>
17
</classpath>
(-).project (+2 lines)
Lines 3-12 Link Here
3
	<name>org.eclipse.ui.tests</name>
3
	<name>org.eclipse.ui.tests</name>
4
	<comment></comment>
4
	<comment></comment>
5
	<projects>
5
	<projects>
6
		<project>org.eclipse.core.boot</project>
6
		<project>org.eclipse.core.resources</project>
7
		<project>org.eclipse.core.resources</project>
7
		<project>org.eclipse.core.runtime</project>
8
		<project>org.eclipse.core.runtime</project>
8
		<project>org.eclipse.swt</project>
9
		<project>org.eclipse.swt</project>
9
		<project>org.eclipse.ui</project>
10
		<project>org.eclipse.ui</project>
11
		<project>org.eclipse.ui.workbench</project>
10
		<project>org.junit</project>
12
		<project>org.junit</project>
11
	</projects>
13
	</projects>
12
	<buildSpec>
14
	<buildSpec>
(-)Eclipse (+103 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ui.tests.keys;
13
14
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IWorkspace;
17
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.jface.action.IAction;
20
import org.eclipse.swt.widgets.Display;
21
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.MenuItem;
23
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.ui.IWorkbenchActionConstants;
25
import org.eclipse.ui.IWorkbenchWindow;
26
import org.eclipse.ui.internal.Workbench;
27
import org.eclipse.ui.keys.KeyStroke;
28
import org.eclipse.ui.keys.ParseException;
29
import org.eclipse.ui.tests.util.UITestCase;
30
import org.eclipse.ui.texteditor.AbstractTextEditor;
31
32
/**
33
 * Tests Bug 43321
34
 * 
35
 * @since 3.0
36
 */
37
public class Bug43321Test extends UITestCase {
38
39
	private static final String NAVIGATOR_VIEW_ID = "org.eclipse.ui.views.ResourceNavigator";
40
	
41
	/*
42
	 * @see TestCase#setUp()
43
	 */
44
	protected void setUp() throws Exception {
45
		super.setUp();
46
	}
47
48
	/*
49
	 * @see TestCase#tearDown()
50
	 */
51
	protected void tearDown() throws Exception {
52
		super.tearDown();
53
	}
54
55
	/**
56
	 * Constructor for Bug43321Test.
57
	 * 
58
	 * @param name
59
	 *           The name of the test
60
	 */
61
	public Bug43321Test(String name) {
62
		super(name);
63
	}
64
65
	/**
66
	 * Tests that non-check box items on the menu are not checked when activated
67
	 * from the keyboard.
68
	 * @throws ParseException If "CTRL+C" isn't a valid key stroke.
69
	 */
70
	public void testNoCheckOnNonCheckbox() throws CoreException, ParseException {
71
		IWorkbenchWindow window = openTestWindow();
72
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
73
		IProject testProject = workspace.getRoot().getProject("TestProject"); //$NON-NLS-1$
74
		testProject.create(null);
75
		testProject.open(null);
76
		AbstractTextEditor editor = (AbstractTextEditor) window.getActivePage().openEditor(testProject.getFile(".project")); //$NON-NLS-1$
77
		editor.selectAndReveal(0, 1);
78
		
79
		// Update the display.
80
		Shell shell = window.getShell();
81
		Display display = shell.getDisplay();
82
		while (display.readAndDispatch());
83
		
84
		// Press "Ctrl+C" to perform a copy.
85
		KeyStroke[] keyStrokes = { KeyStroke.getInstance("CTRL+C") }; //$NON-NLS-1$
86
		Event event = new Event();
87
		((Workbench) window.getWorkbench()).press(keyStrokes, event);
88
89
		// Get the menu item we've just selected.
90
		IAction action = editor.getEditorSite().getActionBars().getGlobalActionHandler(IWorkbenchActionConstants.COPY);
91
		assertTrue("Non-checkbox menu item is checked.", !action.isChecked()); //$NON-NLS-1$
92
	}
93
	
94
	public static MenuItem getMenuItem(MenuItem[] menuItems, String text) {
95
		for (int i = 0; i < menuItems.length; i++) {
96
			if (menuItems[i].getText().equals(text)) {
97
				return menuItems[i];
98
			}
99
		}
100
		
101
		return null;
102
	}
103
}
(-)Eclipse (+88 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ui.tests.keys;
13
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.graphics.Font;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Display;
19
import org.eclipse.swt.widgets.Shell;
20
import org.eclipse.swt.widgets.Text;
21
import org.eclipse.ui.tests.util.UITestCase;
22
23
/**
24
 * Tests Bug 43597
25
 * 
26
 * @since 3.0
27
 */
28
public class Bug43597Test extends UITestCase {
29
30
	/*
31
	 * @see TestCase#setUp()
32
	 */
33
	protected void setUp() throws Exception {
34
		super.setUp();
35
	}
36
37
	/*
38
	 * @see TestCase#tearDown()
39
	 */
40
	protected void tearDown() throws Exception {
41
		super.tearDown();
42
	}
43
44
	/**
45
	 * Constructor for Bug43597Test.
46
	 * 
47
	 * @param name
48
	 *           The name of the test
49
	 */
50
	public Bug43597Test(String name) {
51
		super(name);
52
	}
53
54
	/**
55
	 * Tests that setting the text on a text widget to an empty string does not
56
	 * reset the font.  This was a problem only on carbon.
57
	 */
58
	public void testFontReset() {
59
		String metaCharacter = "\u2325X"; //$NON-NLS-1$
60
61
		// Set up a working environment.
62
		Display display = Display.getCurrent();
63
		Shell shell = new Shell(display);
64
		GridLayout gridLayout = new GridLayout();
65
		shell.setLayout(gridLayout);
66
		Text text = new Text(shell, SWT.LEFT);
67
		text.setFont(new Font(text.getDisplay(), "Lucida Grande", 13, SWT.NORMAL)); //$NON-NLS-1$
68
		text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
69
		
70
		// Set the text once, and get the font.
71
		text.setText(metaCharacter); //$NON-NLS-1$
72
		Font fontBefore = text.getFont();
73
		
74
		// Set the font again, and get the font afterward.
75
		text.setText(""); //$NON-NLS-1$
76
		text.setText(metaCharacter);
77
		Font fontAfter = text.getFont();
78
		
79
		// Test.
80
		assertEquals("Clearing text resets font.", fontBefore.handle, fontAfter.handle); //$NON-NLS-1$
81
		
82
		// Clean up after myself.
83
		shell.pack();
84
		shell.open();
85
		shell.close();
86
		shell.dispose();
87
	}
88
}
(-)Eclipse (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ui.tests.keys;
13
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.widgets.Event;
16
import org.eclipse.ui.internal.keys.KeySupport;
17
import org.eclipse.ui.tests.util.UITestCase;
18
19
/**
20
 * Test for Bug 43800.
21
 * 
22
 * @since 3.0
23
 */
24
public class Bug43800Test extends UITestCase {
25
26
	/**
27
	 * Constructs a new instance of this test case.
28
	 * @param testName The name of the test
29
	 */
30
	public Bug43800Test(String testName) {
31
		super(testName);
32
	}
33
34
	/*
35
	 * @see TestCase#setUp()
36
	 */
37
	protected void setUp() throws Exception {
38
		super.setUp();
39
	}
40
41
	/*
42
	 * @see TestCase#tearDown()
43
	 */
44
	protected void tearDown() throws Exception {
45
		super.tearDown();
46
	}
47
48
	/**
49
	 * Tests that key pressed with key codes greater than 16 bits are correctly
50
	 * converted into accelerator values.
51
	 */
52
	public void testTruncatingCast() {
53
		/* Make an event representing a key stroke with a key code greater than
54
		 * 16 bits.
55
		 */
56
		Event event = new Event();
57
		event.keyCode = SWT.ARROW_LEFT;
58
		event.character = 0x00;
59
		event.stateMask = 0x00;
60
		
61
		// Convert the event, and test the resulting accelerator value.
62
		int accelerator = KeySupport.convertEventToUnmodifiedAccelerator(event);
63
		assertEquals("Arrow_Left key truncated", SWT.ARROW_LEFT, accelerator); //$NON-NLS-1$
64
	}
65
}
(-)Eclipse (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2003 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Common Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/cpl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.tests.keys;
12
13
import junit.framework.Test;
14
import junit.framework.TestSuite;
15
16
/**
17
 * Tests for all areas of the key support for the platform.
18
 */
19
public class KeysTestSuite extends TestSuite {
20
21
	/**
22
	 * Returns the suite. This is required to use the JUnit Launcher.
23
	 */
24
	public static Test suite() {
25
		return new KeysTestSuite();
26
	}
27
28
	/**
29
	 * Construct the test suite.
30
	 */
31
	public KeysTestSuite() {
32
		addTest(new TestSuite(Bug43321Test.class));
33
		addTest(new TestSuite(Bug43597Test.class));
34
		addTest(new TestSuite(Bug43800Test.class));
35
	}
36
}

Return to bug 43844