aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Elder2014-02-14 11:07:27 (EST)
committerGerrit Code Review @ Eclipse.org2014-02-14 11:35:07 (EST)
commit292b5197d67fc653008b5d121f48c18add01616b (patch)
tree9b6471e9517771db110edb70c66be2ed3cff01b8
parent0c95c52f512149da62850d0933404d643f741d7d (diff)
downloadeclipse.platform.ui-292b5197d67fc653008b5d121f48c18add01616b.zip
eclipse.platform.ui-292b5197d67fc653008b5d121f48c18add01616b.tar.gz
eclipse.platform.ui-292b5197d67fc653008b5d121f48c18add01616b.tar.bz2
366608: [KeyBindings] [Compatibility] Failures in KeysTestSuiterefs/changes/18/22018/2
Integrate distinct e4 key binding tests into org.eclipse.ui.tests. Change-Id: Ic6b4f9d53f3e049b522819eb9e3803466f93ed6a
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/.classpath7
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/.project28
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.core.runtime.prefs2
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/META-INF/MANIFEST.MF29
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/build.properties15
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/forceQualifierUpdate.txt2
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/plugin.xml135
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/pom.xml24
-rw-r--r--tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Activator.java60
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingInteractionsTest.java767
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingManagerTest.java957
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingPersistenceTest.java599
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug189167Test.java45
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36420Test.java117
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36537Test.java125
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug40023Test.java114
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42024Test.java142
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42035Test.java185
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42627Test.java83
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43168Test.java60
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43321Test.java95
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43538Test.java69
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43597Test.java88
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43610Test.java68
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43800Test.java55
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug44460Test.java117
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug53489Test.java102
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysCsvTest.java37
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysPreferenceModelTest.java943
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysTestSuite.java62
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/PreferenceMutator.java83
-rwxr-xr-xtests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/TestBinding.java107
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java301
34 files changed, 295 insertions, 5336 deletions
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/.classpath b/tests/org.eclipse.e4.ui.keybinding.tests/.classpath
deleted file mode 100644
index ad32c83..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/.project b/tests/org.eclipse.e4.ui.keybinding.tests/.project
deleted file mode 100644
index 201e368..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.e4.ui.keybinding.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.core.runtime.prefs b/tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.core.runtime.prefs
deleted file mode 100644
index c522e1f..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.core.runtime.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-eclipse.preferences.version=1
-line.separator=\n
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 1e0fc07..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,8 +0,0 @@
-#Wed Apr 20 11:31:39 EDT 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.e4.ui.keybinding.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 2cafe4d..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,29 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: e4 Binding Tests
-Bundle-SymbolicName: org.eclipse.e4.ui.keybinding.tests;singleton:=true
-Bundle-Version: 0.11.0.qualifier
-Bundle-Activator: org.eclipse.e4.ui.keybinding.tests.Activator
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.e4.core.commands;bundle-version="0.9.0",
- org.eclipse.e4.core.contexts;bundle-version="0.9.0",
- org.eclipse.e4.core.di;bundle-version="0.9.0",
- org.eclipse.e4.core.services;bundle-version="0.9.1",
- org.eclipse.e4.ui.bindings;bundle-version="0.9.0",
- org.eclipse.e4.ui.di;bundle-version="0.9.0",
- org.eclipse.e4.ui.model.workbench;bundle-version="0.9.1",
- org.eclipse.e4.ui.services;bundle-version="0.9.1",
- org.eclipse.e4.ui.workbench;bundle-version="0.9.1",
- org.eclipse.e4.ui.workbench.addons.swt;bundle-version="0.9.0",
- org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.9.1",
- org.eclipse.e4.ui.workbench.swt;bundle-version="0.9.1",
- org.junit,
- org.eclipse.ui.ide;bundle-version="3.7.0",
- org.eclipse.ui.tests.harness;bundle-version="1.1.0",
- org.eclipse.core.resources;bundle-version="3.7.100",
- org.eclipse.ui.workbench.texteditor;bundle-version="3.7.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ActivationPolicy: lazy
-Import-Package: javax.annotation;version="1.0.0",
- javax.inject;version="1.0.0"
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/build.properties b/tests/org.eclipse.e4.ui.keybinding.tests/build.properties
deleted file mode 100644
index cd1b3ec..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2013 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/forceQualifierUpdate.txt b/tests/org.eclipse.e4.ui.keybinding.tests/forceQualifierUpdate.txt
deleted file mode 100644
index 56f1032..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/forceQualifierUpdate.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# To force a version qualifier update add the bug here
-Bug 403352 - Update all parent versions to match our build stream
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/plugin.xml b/tests/org.eclipse.e4.ui.keybinding.tests/plugin.xml
deleted file mode 100644
index 1868594a..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/plugin.xml
+++ /dev/null
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <!-- bindings for the platform tests -->
- <extension
- point="org.eclipse.ui.bindings">
- <key
- commandId="org.eclipse.ui.help.aboutAction"
- contextId="org.eclipse.ui.contexts.window"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+8 A">
- </key>
- <key
- contextId="org.eclipse.ui.contexts.window"
- platform="carbon"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+8 A">
- </key>
- <key
- commandId="org.eclipse.ui.help.aboutAction"
- contextId="org.eclipse.ui.contexts.window"
- platform="carbon"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+8 B">
- </key>
- </extension>
- <extension
- point="org.eclipse.ui.bindings">
- <sequenceModifier
- find="M1+8"
- platforms="carbon,cocoa,gtk,win32"
- replace="M2+8">
- </sequenceModifier>
- <key
- commandId="org.eclipse.ui.navigate.addToWorkingSet"
- contextId="org.eclipse.ui.contexts.window"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+8 W">
- </key>
- <key
- commandId="org.eclipse.ui.file.import"
- contextId="org.eclipse.ui.contexts.window"
- platform="carbon,cocoa,gtk,win32"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+8 I">
- </key>
- </extension>
- <extension
- point="org.eclipse.ui.bindings">
- <key
- commandId="org.eclipse.ui.file.export"
- contextId="org.eclipse.ui.contexts.window"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+8 E">
- </key>
- </extension>
- <extension
- point="org.eclipse.ui.bindings">
- <key
- commandId="org.eclipse.ui.navigate.back"
- contextId="org.eclipse.ui.contexts.window"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="M1+8 Q">
- </key>
- <sequenceModifier
- find="M1+8"
- platforms="photon"
- replace="M2+8">
- </sequenceModifier>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <category
- id="org.eclipse.ui.tests.category.keyModel"
- name="Key Model">
- </category>
- <command
- categoryId="org.eclipse.ui.tests.category.keyModel"
- id="org.eclipse.ui.tests.keyModel.conflict1"
- name="Conflict1">
- </command>
- <command
- categoryId="org.eclipse.ui.tests.category.keyModel"
- id="org.eclipse.ui.tests.keyModel.conflict2"
- name="Conflict2">
- </command>
- <command
- categoryId="org.eclipse.ui.tests.category.keyModel"
- id="org.eclipse.ui.tests.keyModel.conflict3"
- name="Conflict3">
- </command>
- <command
- categoryId="org.eclipse.ui.tests.category.keyModel"
- id="org.eclipse.ui.tests.keyModel.conflict4"
- name="ConflictNoKey4">
- </command>
- <command
- categoryId="org.eclipse.ui.tests.category.keyModel"
- id="org.eclipse.ui.tests.keyModel.conflict5"
- name="ConflictNoKey5">
- </command>
- <command
- categoryId="org.eclipse.ui.tests.category.keyModel"
- id="org.eclipse.ui.tests.keyModel.emacs1"
- name="emacsCommand1">
- </command>
- </extension>
- <extension
- point="org.eclipse.ui.bindings">
- <key
- commandId="org.eclipse.ui.tests.keyModel.conflict1"
- contextId="org.eclipse.ui.contexts.dialog"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="CTRL+5 K">
- </key>
- <key
- commandId="org.eclipse.ui.tests.keyModel.conflict2"
- contextId="org.eclipse.ui.contexts.dialog"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="CTRL+5 K">
- </key>
- <key
- commandId="org.eclipse.ui.tests.keyModel.conflict3"
- contextId="org.eclipse.ui.contexts.dialog"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="CTRL+5 K">
- </key>
- <key
- commandId="org.eclipse.ui.tests.keyModel.emacs1"
- contextId="org.eclipse.ui.contexts.window"
- schemeId="org.eclipse.ui.emacsAcceleratorConfiguration"
- sequence="CTRL+5 E">
- </key>
- </extension>
-</plugin>
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/pom.xml b/tests/org.eclipse.e4.ui.keybinding.tests/pom.xml
deleted file mode 100644
index 763b312..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2012, 2013 Eclipse Foundation and others.
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Distribution License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/org/documents/edl-v10.php
-
- Contributors:
- Igor Fedorenko - initial implementation
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>eclipse.platform.ui.tests</artifactId>
- <groupId>eclipse.platform.ui</groupId>
- <version>4.4.0-SNAPSHOT</version>
- </parent>
- <groupId>org.eclipse.e4</groupId>
- <artifactId>org.eclipse.e4.ui.keybinding.tests</artifactId>
- <version>0.11.0-SNAPSHOT</version>
- <packaging>eclipse-test-plugin</packaging>
-
-</project>
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Activator.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Activator.java
deleted file mode 100644
index 8c82d43..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Activator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.e4.ui.keybinding.tests"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingInteractionsTest.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingInteractionsTest.java
deleted file mode 100755
index b129cb3..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingInteractionsTest.java
+++ /dev/null
@@ -1,767 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-
-import org.eclipse.core.commands.CommandManager;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.commands.contexts.Context;
-import org.eclipse.core.commands.contexts.ContextManager;
-import org.eclipse.jface.bindings.Binding;
-import org.eclipse.jface.bindings.BindingManager;
-import org.eclipse.jface.bindings.Scheme;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.util.Util;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Test cases covering the various interaction between bindings. Bindings that
- * have been removed. Bindings that have been added. Inheritance of various
- * properties.
- *
- * @since 3.1
- */
-public final class BindingInteractionsTest extends UITestCase {
-
- /**
- * The binding manager to use in each test case. A new binding manager is
- * created for each test case, and it is disposed when the test is over.
- */
- private BindingManager bindingManager = null;
-
- /**
- * The context manager to use in each test case. A new context manager is
- * created for each test case, and it is disposed when the test is over.
- */
- private ContextManager contextManager = null;
-
- /**
- * Constructor for <code>BindingInteractionsTest</code>.
- *
- * @param name
- * The name of the test
- */
- public BindingInteractionsTest(final String name) {
- super(name);
- }
-
- /**
- * Creates a new context manager and a binding manager for use in the test
- * cases.
- */
- protected void doSetUp() {
- contextManager = new ContextManager();
- bindingManager = new BindingManager(contextManager,
- new CommandManager());
- }
-
- /**
- * Releases the context manager and binding manager for garbage collection.
- */
- protected void doTearDown() {
- contextManager = null;
- bindingManager = null;
- }
-
- /**
- * <p>
- * Tests whether two identical bindings lead to a conflict.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testConflict() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding("conflict1", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("conflict2", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
-
- TriggerSequence[] activeBindings = bindingManager
- .getActiveBindingsFor(binding1.getParameterizedCommand());
- assertFalse(binding1.equals(binding2));
- assertTrue("Neither binding should be active",
- activeBindings.length == 0);
- activeBindings = bindingManager.getActiveBindingsFor(binding2
- .getParameterizedCommand());
- assertTrue("Neither binding should be active",
- activeBindings.length == 0);
- }
-
- /**
- * <p>
- * Tests whether a plug-in developer can override a binding in a child
- * context.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testContextOverride() throws NotDefinedException {
- final Context parentContext = contextManager.getContext("parent");
- parentContext.define("parent", "parent context", null);
-
- final Context childContext = contextManager.getContext("child");
- childContext.define("child", "child context", "parent");
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
-
- final Binding binding1 = new TestBinding("parent", "na", "parent",
- null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("child", "na", "child", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
-
- // Only "parent"
- final Set activeContextIds = new HashSet();
- activeContextIds.add("parent");
- contextManager.setActiveContextIds(activeContextIds);
- assertEquals(
- "When only the parent context is active, only the parent binding is active.",
- binding1, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
-
- // Only "child"
- activeContextIds.clear();
- activeContextIds.add("child");
- contextManager.setActiveContextIds(activeContextIds);
- assertEquals(
- "When only the child context is active, only the child binding is active.",
- binding2, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
-
- // Both "parent" and "child"
- activeContextIds.add("parent");
- contextManager.setActiveContextIds(activeContextIds);
- assertEquals(
- "When both contexts are active, only the child binding is active.",
- binding2, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a user-defined deletion actually works.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testDeletedBinding() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding(null, "na", "na", null, null,
- Binding.USER, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("system", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- assertEquals("The user should be able to remove bindings", null,
- bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a user-defined deletion in one context will allow a binding
- * in a parent context to match. Bug 105655.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testDeletedBindingAllowsParent() throws NotDefinedException {
- final Context parentContext = contextManager.getContext("parent");
- parentContext.define("name", "description", null);
- final Context childContext = contextManager.getContext("child");
- childContext.define("name", "description", "parent");
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("parent");
- activeContextIds.add("child");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding childBinding = new TestBinding("childCommand", "na",
- "child", null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(childBinding);
- final Binding deletion = new TestBinding(null, "na", "child", null,
- null, Binding.USER, null);
- bindingManager.addBinding(deletion);
- final Binding parentBinding = new TestBinding("parentCommand", "na",
- "parent", null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(parentBinding);
- assertEquals(
- "The user should be able to remove bindings to allow a parent binding",
- "parentCommand", bindingManager.getPerfectMatch(
- TestBinding.TRIGGER_SEQUENCE).getParameterizedCommand()
- .getId());
- }
-
- /**
- * <p>
- * Tests a common case for binding deletion. The binding is defined on all
- * platforms, then deleted on a specific platform, and defined again as
- * something else.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testDeletedBindingPlatform() throws NotDefinedException {
- final String na = "na";
-
- final Context context = contextManager.getContext(na);
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme(na);
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding allPlatforms = new TestBinding("allPlatforms", na, na,
- null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(allPlatforms);
- final Binding deletion = new TestBinding(null, na, na, null, Util.getWS(),
- Binding.SYSTEM, null);
- bindingManager.addBinding(deletion);
- final Binding platformSpecific = new TestBinding("platformSpecific",
- na, na, null, Util.getWS(), Binding.SYSTEM, null);
- bindingManager.addBinding(platformSpecific);
- assertEquals(
- "We should be able to change a binding on a particular platform",
- platformSpecific, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a system deletion for a different locale or platform
- * actually works. It shouldn't. Deletions should only work if they specify
- * a matching locale or platform.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testDeletedBindingUnnecessarily() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding(null, "na", "na",
- "not the current locale", null, Binding.SYSTEM, null);
- final Binding binding2 = new TestBinding("system", "na", "na", null,
- null, Binding.SYSTEM, null);
- final Binding binding3 = new TestBinding(null, "na", "na", null,
- "not the current platform", Binding.SYSTEM, null);
- final Binding[] bindings = new Binding[3];
- bindings[0] = binding1;
- bindings[1] = binding2;
- bindings[2] = binding3;
- bindingManager.setBindings(bindings);
- assertEquals(
- "A binding should not cause a deletion if its locale or platform doesn't match",
- binding2, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a user can add a binding to the same conditions once
- * they've deleted the system binding.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testDeletedBindingWithAddition() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding(null, "na", "na", null, null,
- Binding.USER, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("system", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- final Binding binding3 = new TestBinding("user", "na", "na", null,
- null, Binding.USER, null);
- bindingManager.addBinding(binding3);
- assertEquals("The user redefine a particular binding", binding3,
- bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * This tests the case where a plug-in developer unbinds a key, and then a
- * user tries to bind to that key. The user should be allowed to bind.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testDeletedBindingWithUserOverride() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding generalBinding = new TestBinding("general", scheme
- .getId(), context.getId(), null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(generalBinding);
- final Binding cancelOnPlatform = new TestBinding(null, scheme.getId(),
- context.getId(), null, bindingManager.getPlatform(),
- Binding.SYSTEM, null);
- bindingManager.addBinding(cancelOnPlatform);
- final Binding userOverride = new TestBinding("user", scheme.getId(),
- context.getId(), null, bindingManager.getPlatform(),
- Binding.USER, null);
- bindingManager.addBinding(userOverride);
- assertEquals("The user redefine a binding deleted in the system",
- userOverride, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
-
- }
-
- /**
- * Tests that if more than one deletion is defined for the same binding,
- * that the deletion will still work. Bug 106574 points out a case where it
- * is possible for a deletion to clobber another deletion.
- *
- * @since 3.2
- */
- public void testDoubleDeletedBinding() {
- final String parent = "parent";
- final String child = "child";
-
- // Set-up the contexts
- final Context parentContext = contextManager.getContext(parent);
- parentContext.define(parent, parent, null);
- final Context childContext = contextManager.getContext(child);
- childContext.define(child, child, parent);
- final Set activeContextIds = new HashSet();
- activeContextIds.add(parent);
- activeContextIds.add(child);
- contextManager.setActiveContextIds(activeContextIds);
-
- // Set-up the schemes.
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define(parent, parent, null);
-
- /*
- * Set-up a binding, with two deletions. The first deletion matches the
- * context, but the second does not.
- */
- final Binding binding = new TestBinding("command", "na", parent, null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding);
- final Binding correctDeletion = new TestBinding(null, "na", parent,
- null, null, Binding.USER, null);
- bindingManager.addBinding(correctDeletion);
- final Binding wrongDeletion = new TestBinding(null, "na", child, null,
- null, Binding.USER, null);
- bindingManager.addBinding(wrongDeletion);
-
- // Test that the deletion worked.
- assertEquals("The parent should not be active", null, bindingManager
- .getPerfectMatch(binding.getTriggerSequence()));
- }
-
- /**
- * This tests a complicated scenario that arises with the Emacs key binding
- * set in the Eclipse workbench. The first binding belongs to a parent
- * context, but a child scheme. The trigger sequences are not the same.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testDoubleParent() throws NotDefinedException {
- final String parent = "parent";
- final String child = "child";
-
- // Set-up the contexts
- final Context parentContext = contextManager.getContext(parent);
- parentContext.define(parent, parent, null);
- final Context childContext = contextManager.getContext(child);
- childContext.define(child, child, parent);
- final Set activeContextIds = new HashSet();
- activeContextIds.add(parent);
- activeContextIds.add(child);
- contextManager.setActiveContextIds(activeContextIds);
-
- // Set-up the schemes.
- final Scheme parentScheme = bindingManager.getScheme(parent);
- parentScheme.define(parent, parent, null);
- final Scheme childScheme = bindingManager.getScheme(child);
- childScheme.define(child, child, parent);
- bindingManager.setActiveScheme(childScheme);
-
- // Add two bindings.
- final Binding parentBinding = new TestBinding(parent, parent, parent,
- null, null, Binding.SYSTEM, null);
- final Binding childBinding = new TestBinding(child, child, child, null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(parentBinding);
- bindingManager.addBinding(childBinding);
-
- // Test to see that only the child is active.
- assertTrue("The parent should not be active",
- bindingManager.getActiveBindingsFor(parentBinding
- .getParameterizedCommand()).length == 0);
- assertTrue("The child should be active",
- bindingManager.getActiveBindingsFor(childBinding
- .getParameterizedCommand()).length != 0);
- }
-
- /**
- * <p>
- * Tests whether a plug-in developer can override a binding for a particular
- * locale.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testLocaleOverride() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding("base", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding(null, "na", "na", Locale
- .getDefault().toString(), null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- final Binding binding3 = new TestBinding("locale-specific", "na", "na",
- Locale.getDefault().toString(), null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding3);
- assertEquals(
- "A plug-in developer should be able to change a binding for a locale",
- binding3, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a plug-in developer can override a binding for a particular
- * platform.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testPlatformOverride() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding("base", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding(null, "na", "na", null, Util.getWS(),
- Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- final Binding binding3 = new TestBinding("platform-specific", "na",
- "na", null, Util.getWS(), Binding.SYSTEM, null);
- bindingManager.addBinding(binding3);
- assertEquals(
- "A plug-in developer should be able to change a binding for a platform",
- binding3, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a binding in a child scheme will override a binding in a
- * parent scheme. The test is set-up as follows:
- * </p>
- * <ul>
- * <li>Binding1(commandId="child",schemeId="child",contextId="na",locale=null,platform=null,type=SYSTEM)</li>
- * <li>Binding2(commandId="parent",schemeId="parent",contextId="na",locale=null,platform=null,type=SYSTEM)</li>
- * </ul>
- * <p>
- * Binding1 should win.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testSchemeOverride() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme parentScheme = bindingManager.getScheme("parent");
- parentScheme.define("parent", "parent scheme", null);
-
- final Scheme childScheme = bindingManager.getScheme("child");
- childScheme.define("child", "child scheme", "parent");
-
- bindingManager.setActiveScheme(childScheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding("child", "child", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("parent", "parent", "na",
- null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- assertEquals("The binding from the child scheme should be active",
- binding1, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * This tests a Emacs-style scenario. In this scenario a child scheme
- * defines a binding in a parent context. The parent scheme bindings the
- * same trigger sequence in a child context. The child scheme definition
- * should win.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testSchemeOverrideDifferentContexts()
- throws NotDefinedException {
- final String parent = "parent";
- final String child = "child";
-
- final Context parentContext = contextManager.getContext(parent);
- parentContext.define("parent", "description", null);
- final Context childContext = contextManager.getContext(child);
- childContext.define("child", "description", parent);
-
- final Scheme parentScheme = bindingManager.getScheme(parent);
- parentScheme.define("parent", "parent scheme", null);
- final Scheme childScheme = bindingManager.getScheme(child);
- childScheme.define("child", "child scheme", parent);
-
- bindingManager.setActiveScheme(childScheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add(parentContext.getId());
- activeContextIds.add(childContext.getId());
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding("parent",
- parentScheme.getId(), childContext.getId(), null, null,
- Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("child", childScheme.getId(),
- parentContext.getId(), null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- assertEquals("The binding from the child scheme should be active",
- binding2, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a binding in a child scheme will override a binding in a
- * parent scheme -- regardless of their type. The test is set-up as follows:
- * </p>
- * <ul>
- * <li>Binding1(commandId="child",schemeId="child",contextId="na",locale=null,platform=null,type=SYSTEM)</li>
- * <li>Binding2(commandId="parent",schemeId="parent",contextId="na",locale=null,platform=null,type=USER)</li>
- * </ul>
- * <p>
- * Binding1 should win.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testSchemeOverrideDifferentTypes() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme parentScheme = bindingManager.getScheme("parent");
- parentScheme.define("parent", "parent scheme", null);
-
- final Scheme childScheme = bindingManager.getScheme("child");
- childScheme.define("child", "child scheme", "parent");
-
- bindingManager.setActiveScheme(childScheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding("child", "child", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("parent", "parent", "na",
- null, null, Binding.USER, null);
- bindingManager.addBinding(binding2);
- assertEquals("The binding from the child scheme should be active",
- binding1, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether two bindings defined for sibling active contexts leads to a
- * conflict.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testSiblingContextConflict() throws NotDefinedException {
- final Context context1 = contextManager.getContext("sibling1");
- context1.define("sibling1", "first sibling context", null);
-
- final Context context2 = contextManager.getContext("sibling2");
- context2.define("sibling2", "second sibling context", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
-
- final Binding binding1 = new TestBinding("sibling1", "na", "sibling1",
- null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("sibling2", "na", "sibling2",
- null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
-
- // One sibling active
- final Set activeContextIds = new HashSet();
- activeContextIds.add("sibling1");
- contextManager.setActiveContextIds(activeContextIds);
- assertEquals(
- "When only the first sibling is active, only the first binding is active",
- binding1, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
-
- // Other sibling active
- activeContextIds.clear();
- activeContextIds.add("sibling2");
- contextManager.setActiveContextIds(activeContextIds);
- assertEquals(
- "When only the second sibling is active, only the second binding is active",
- binding2, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
-
- // Both siblings are active
- activeContextIds.add("sibling1");
- contextManager.setActiveContextIds(activeContextIds);
- assertEquals("When both contexts are active, a conflict should occur",
- null, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * <p>
- * Tests whether a user-defined binding will override the exact same binding
- * defined in the system.
- * </p>
- * <ul>
- * <li>Binding1(commandId="user",schemeId="na",contextId="na",locale=null,platform=null,type=USER)</li>
- * <li>Binding2(commandId="system",schemeId="na",contextId="na",locale=null,platform=null,type=SYSTEM)</li>
- * </ul>
- * <p>
- * Binding1 should win.
- * </p>
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public void testUserOverride() throws NotDefinedException {
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final Binding binding1 = new TestBinding("user", "na", "na", null,
- null, Binding.USER, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("system", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- assertEquals("The user-defined binding should be active", binding1,
- bindingManager.getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingManagerTest.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingManagerTest.java
deleted file mode 100755
index 2084a00..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingManagerTest.java
+++ /dev/null
@@ -1,957 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.commands.Category;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.CommandManager;
-import org.eclipse.core.commands.IParameter;
-import org.eclipse.core.commands.IParameterValues;
-import org.eclipse.core.commands.ParameterValuesException;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.core.commands.contexts.Context;
-import org.eclipse.core.commands.contexts.ContextManager;
-import org.eclipse.jface.bindings.Binding;
-import org.eclipse.jface.bindings.BindingManager;
-import org.eclipse.jface.bindings.Scheme;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.bindings.keys.KeyBinding;
-import org.eclipse.jface.bindings.keys.KeySequence;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * <p>
- * This test case covers the general functionality of the binding manager's API
- * methods. This is not intended to test the interactions between bindings
- * themselves (e.g., solving a binding set). For tests dealing with
- * interactions, please look at <code>BindingInteractionsTest</code>.
- * </p>
- * <p>
- * The listener code is tested throughout the various tests. There is no
- * individual test method for the listener code.
- * </p>
- *
- * @see org.eclipse.ui.tests.keys.BindingInteractionsTest
- * @since 3.1
- */
-public final class BindingManagerTest extends UITestCase {
-
- /**
- * The binding manager to use in each test case. A new binding manager is
- * created for each test case, and it is disposed when the test is over.
- */
- private BindingManager bindingManager = null;
-
- /**
- * The command manager for the currently running test. <code>null</code>
- * if no test is running.
- */
- private CommandManager commandManager = null;
-
- /**
- * The context manager to use in each test case. A new context manager is
- * created for each test case, and it is disposed when the test is over.
- */
- private ContextManager contextManager = null;
-
- /**
- * Constructor for <code>BindingInteractionsTest</code>.
- *
- * @param name
- * The name of the test
- */
- public BindingManagerTest(final String name) {
- super(name);
- }
-
- /**
- * Creates a new context manager and a binding manager for use in the test
- * cases.
- */
- protected final void doSetUp() {
- commandManager = new CommandManager();
- contextManager = new ContextManager();
- bindingManager = new BindingManager(contextManager, commandManager);
- }
-
- /**
- * Releases the context manager and binding manager for garbage collection.
- */
- protected final void doTearDown() {
- bindingManager = null;
- contextManager = null;
- commandManager = null;
- }
-
- /**
- * Tests that the constructor disallows a null context manager.
- */
- public final void testConstructor() {
- try {
- new BindingManager(null, null);
- fail("A binding manager cannot be constructed with a null context manager");
- } catch (final NullPointerException e) {
- // Success
- }
- }
-
- /**
- * Tests that it is not possible to add a null binding. Tests that adding a
- * binding forces a recomputation.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public final void testAddBinding() throws NotDefinedException {
- // Set up a state in which a binding may become active.
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // Try to add a null binding.
- try {
- bindingManager.addBinding(null);
- fail("It should not be possible to add a null binding");
- } catch (final NullPointerException e) {
- // Success.
- }
-
- // Try to add a binding that should become active.
- final Binding binding = new TestBinding("conflict1", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding);
- assertSame("The binding should be active", binding, bindingManager
- .getPerfectMatch(TestBinding.TRIGGER_SEQUENCE));
- }
-
- /**
- * Tests that <code>getActiveBindingsDisregardingContext()</code> never
- * returns <code>null</code>. The rest of the functionality is tested in
- * <code>BindingInteractionsTest</code>.
- *
- * @see BindingInteractionsTest
- */
- public final void testGetActiveBindingsDisregardingContext() {
- final Map activeBindings = bindingManager
- .getActiveBindingsDisregardingContext();
- assertNotNull("The active bindings should never be null",
- activeBindings);
- assertTrue("The active bindings should start empty", activeBindings
- .isEmpty());
- }
-
- /**
- * Tests that <code>getActiveBindingsDisregardingContextFlat()</code>
- * never returns <code>null</code>. The rest of the functionality is
- * tested in <code>BindingInteractionsTest</code>.
- *
- * @see BindingInteractionsTest
- */
- public final void testGetActiveBindingsDisregardingContextFlat() {
- final Collection activeBindings = bindingManager
- .getActiveBindingsDisregardingContextFlat();
- assertNotNull("The active bindings should never be null",
- activeBindings);
- assertTrue("The active bindings should start empty", activeBindings
- .isEmpty());
- }
-
- /**
- * Tests whether the method works with a null argument. Tests that it works
- * in a simple case.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public final void testGetActiveBindingsFor() throws NotDefinedException {
- // Test with a null argument.
- final TriggerSequence[] activeBindingsForNull = bindingManager
- .getActiveBindingsFor((ParameterizedCommand) null);
- assertNotNull("The active bindings for a command should never be null",
- activeBindingsForNull);
- assertTrue(
- "The active binding for a null command should always be empty",
- activeBindingsForNull.length == 0);
-
- // Test a simple case.
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final String commandId = "commandId";
- final Binding binding = new TestBinding(commandId, "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding);
-
- final TriggerSequence[] bindings = bindingManager
- .getActiveBindingsFor(binding.getParameterizedCommand());
- assertEquals("There should be one binding", 1, bindings.length);
- assertSame("The binding should match", TestBinding.TRIGGER_SEQUENCE,
- bindings[0]);
- }
-
- /**
- * Tests that the active scheme starts off <code>null</code>. The rest of
- * the active scheme testing happens in <code>testSetActiveScheme()</code>.
- *
- * @see BindingManagerTest#testSetActiveScheme()
- */
- public final void testGetActiveScheme() {
- assertNull("The active scheme should start null", bindingManager
- .getActiveScheme());
- }
-
- /**
- * Tests that <code>getBindings</code> first returns <code>null</code>.
- * It then verifies that an added binding is return from this method.
- */
- public final void testGetBindings() {
- // Check the starting condition.
- assertNull("The bindings should start off null", bindingManager
- .getBindings());
-
- // Check that an added binding is included.
- final Binding binding = new TestBinding(null, "schemeId", "contextId",
- null, null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding);
- final Binding[] bindings = bindingManager.getBindings();
- assertEquals("There should be one binding", 1, bindings.length);
- assertSame("The binding should be the same", binding, bindings[0]);
-
- /*
- * Check that modifying this set does not modify the internal data
- * structures.
- */
- bindings[0] = null;
- assertNotNull("There should be no change",
- bindingManager.getBindings()[0]);
- }
-
- /**
- * Tests that the list of defined schemes stays up-to-date
- */
- public final void testGetDefinedSchemeIds() {
- // Starting condition.
- assertTrue("The set of defined schemes should start empty",
- bindingManager.getDefinedSchemes().length == 0);
-
- // Retrieving a scheme shouldn't change anything.
- final Scheme scheme = bindingManager.getScheme("schemeId");
- assertTrue(
- "The set of defined schemes should still be empty after a get",
- bindingManager.getDefinedSchemes().length == 0);
-
- // Defining the scheme should change things.
- scheme.define("name", "description", null);
- Scheme[] definedSchemes = bindingManager.getDefinedSchemes();
- assertEquals("There should be one defined scheme id", 1,
- definedSchemes.length);
- assertSame("The defined scheme id should match", scheme,
- definedSchemes[0]);
-
- definedSchemes[0] = null;
- definedSchemes = bindingManager.getDefinedSchemes();
- assertSame("The API should not expose internal collections", scheme,
- definedSchemes[0]);
-
- // Undefining the scheme should also change things.
- scheme.undefine();
- assertTrue(
- "The set of defined schemes should be empty after an undefine",
- bindingManager.getDefinedSchemes().length == 0);
- }
-
- /**
- * Tests that the active locale is never <code>null</code>.
- */
- public final void testGetLocale() {
- assertNotNull("The locale should never be null", bindingManager
- .getLocale());
- }
-
- /**
- * Tests that this method returns the expected list of sequences for a
- * couple of scenarios. In the first scenario, there is one perfect match
- * bindings and a partial match binding. In the second scenario, there are
- * two partial match bindings. In the third scenario, we are checking that
- * all bindings match an empty trigger sequence.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- * @throws ParseException
- * If the hard-coded strings aren't constructed properly.
- */
- public final void testGetPartialMatches() throws NotDefinedException,
- ParseException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // SCENARIO 1
- final KeySequence perfectMatch = KeySequence.getInstance("CTRL+F");
- final Command perfectCommand = commandManager.getCommand("perfect");
- final ParameterizedCommand perfectParameterizedCommand = new ParameterizedCommand(
- perfectCommand, null);
- final Binding perfectMatchBinding = new KeyBinding(perfectMatch,
- perfectParameterizedCommand, "na", "na", null, null, null,
- Binding.SYSTEM);
- final KeySequence partialMatch1 = KeySequence
- .getInstance("CTRL+F CTRL+F");
- final Command partialCommand1 = commandManager.getCommand("partial1");
- final ParameterizedCommand partialParameterizedCommand1 = new ParameterizedCommand(
- partialCommand1, null);
- final Binding partialMatchBinding1 = new KeyBinding(partialMatch1,
- partialParameterizedCommand1, "na", "na", null, null, null,
- Binding.SYSTEM);
- final Binding[] bindings = new Binding[2];
- bindings[0] = perfectMatchBinding;
- bindings[1] = partialMatchBinding1;
- bindingManager.setBindings(bindings);
- Map partialMatches = bindingManager.getPartialMatches(perfectMatch);
- assertTrue("A partial match should override a perfect match",
- !partialMatches.isEmpty());
- assertTrue("A partial match should override a perfect match",
- partialMatches.containsKey(partialMatch1));
-
- // SCENARIO 2
- final KeySequence partialMatch2 = KeySequence
- .getInstance("CTRL+F CTRL+F CTRL+F");
- final Command partialCommand2 = commandManager.getCommand("partial2");
- final ParameterizedCommand partialParameterizedCommand2 = new ParameterizedCommand(
- partialCommand2, null);
- final Binding partialMatchBinding2 = new KeyBinding(partialMatch2,
- partialParameterizedCommand2, "na", "na", null, null, null,
- Binding.SYSTEM);
- bindings[0] = partialMatchBinding1;
- bindings[1] = partialMatchBinding2;
- bindingManager.setBindings(bindings);
- partialMatches = bindingManager.getPartialMatches(perfectMatch);
- assertEquals("There should be two partial matches", 2, partialMatches
- .size());
- assertSame("The partial match should be the one defined",
- partialMatchBinding1, partialMatches.get(partialMatch1));
- assertSame("The partial match should be the one defined",
- partialMatchBinding2, partialMatches.get(partialMatch2));
-
- // SCENARIO 3
- bindingManager.addBinding(perfectMatchBinding);
- partialMatches = bindingManager.getPartialMatches(KeySequence
- .getInstance());
- assertEquals("There should be three partial matches", 3, partialMatches
- .size());
- assertSame("The partial match should be the one defined",
- perfectMatchBinding, partialMatches.get(perfectMatch));
- assertSame("The partial match should be the one defined",
- partialMatchBinding1, partialMatches.get(partialMatch1));
- assertSame("The partial match should be the one defined",
- partialMatchBinding2, partialMatches.get(partialMatch2));
- }
-
- /**
- * Tests that this method returns the expected command identifier. In the
- * first scenario, there is one perfect match bindings and a partial match
- * binding. In the second scenario, there are two partial match bindings. In
- * the third scenario, we are checking that nothing matches an empty
- * sequence.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- * @throws ParseException
- * If the hard-coded strings aren't constructed properly.
- */
- public final void testGetPerfectMatch() throws NotDefinedException,
- ParseException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // SCENARIO 1
- final KeySequence perfectMatch = KeySequence.getInstance("CTRL+F");
- final Command perfectCommand = commandManager.getCommand("perfect");
- final ParameterizedCommand perfectParameterizedCommand = new ParameterizedCommand(
- perfectCommand, null);
- final Binding perfectMatchBinding = new KeyBinding(perfectMatch,
- perfectParameterizedCommand, "na", "na", null, null, null,
- Binding.SYSTEM);
- final KeySequence partialMatch1 = KeySequence
- .getInstance("CTRL+F CTRL+F");
- final Command partialCommand1 = commandManager.getCommand("partial1");
- final ParameterizedCommand partialParameterizedCommand1 = new ParameterizedCommand(
- partialCommand1, null);
- final Binding partialMatchBinding1 = new KeyBinding(partialMatch1,
- partialParameterizedCommand1, "na", "na", null, null, null,
- Binding.SYSTEM);
- final Binding[] bindings = new Binding[2];
- bindings[0] = perfectMatchBinding;
- bindings[1] = partialMatchBinding1;
- bindingManager.setBindings(bindings);
- Binding actualBinding = bindingManager.getPerfectMatch(perfectMatch);
- assertSame("This should be a perfect match", perfectMatchBinding,
- actualBinding);
-
- // SCENARIO 2
- final KeySequence partialMatch2 = KeySequence
- .getInstance("CTRL+F CTRL+F CTRL+F");
- final Command partialCommand2 = commandManager.getCommand("partial2");
- final ParameterizedCommand partialParameterizedCommand2 = new ParameterizedCommand(
- partialCommand2, null);
- final Binding partialMatchBinding2 = new KeyBinding(partialMatch2,
- partialParameterizedCommand2, "na", "na", null, null, null,
- Binding.SYSTEM);
- bindings[0] = partialMatchBinding1;
- bindings[1] = partialMatchBinding2;
- bindingManager.setBindings(bindings);
- actualBinding = bindingManager.getPerfectMatch(perfectMatch);
- assertNull("There should be no perfect matches", actualBinding);
-
- // SCENARIO 3
- bindingManager.addBinding(perfectMatchBinding);
- actualBinding = bindingManager.getPerfectMatch(KeySequence
- .getInstance());
- assertNull("This should be no perfect matches for an empty sequence",
- actualBinding);
- }
-
- /**
- * Tests that the platform is never <code>null</code>.
- */
- public final void testGetPlatform() {
- assertNotNull("The platform can never be null", bindingManager
- .getPlatform());
- }
-
- /**
- * Tests that when a scheme is first retrieved, it is undefined. Tests that
- * a second access to a scheme returns the same scheme.
- */
- public final void testGetScheme() {
- final String schemeId = "schemeId";
- final Scheme firstScheme = bindingManager.getScheme(schemeId);
- assertTrue("A scheme should start undefined", !firstScheme.isDefined());
- final Scheme secondScheme = bindingManager.getScheme(schemeId);
- assertSame("The two scheme should be the same", firstScheme,
- secondScheme);
- }
-
- /**
- * Tests that this method returns <code>true</code> when expected. In the
- * first scenario, there is one perfect match bindings and a partial match
- * binding. In the second scenario, there are two partial match bindings. In
- * the third scenario, we are checking that all bindings match an empty
- * trigger sequence.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- * @throws ParseException
- * If the hard-coded strings aren't constructed properly.
- */
- public final void testIsPartialMatch() throws NotDefinedException,
- ParseException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // SCENARIO 1
- final KeySequence perfectMatch = KeySequence.getInstance("CTRL+F");
- final Command perfectCommand = commandManager.getCommand("perfect");
- final ParameterizedCommand perfectParameterizedCommand = new ParameterizedCommand(
- perfectCommand, null);
- final Binding perfectMatchBinding = new KeyBinding(perfectMatch,
- perfectParameterizedCommand, "na", "na", null, null, null,
- Binding.SYSTEM);
- final KeySequence partialMatch1 = KeySequence
- .getInstance("CTRL+F CTRL+F");
- final Command partialCommand1 = commandManager.getCommand("partial1");
- final ParameterizedCommand partialParameterizedCommand1 = new ParameterizedCommand(
- partialCommand1, null);
- final Binding partialMatchBinding1 = new KeyBinding(partialMatch1,
- partialParameterizedCommand1, "na", "na", null, null, null,
- Binding.SYSTEM);
- final Binding[] bindings = new Binding[2];
- bindings[0] = perfectMatchBinding;
- bindings[1] = partialMatchBinding1;
- bindingManager.setBindings(bindings);
- assertTrue("A perfect match should be overridden by a partial",
- bindingManager.isPartialMatch(perfectMatch));
-
- // SCENARIO 2
- final KeySequence partialMatch2 = KeySequence
- .getInstance("CTRL+F CTRL+F CTRL+F");
- final Command partialCommand2 = commandManager.getCommand("partial2");
- final ParameterizedCommand partialParameterizedCommand2 = new ParameterizedCommand(
- partialCommand2, null);
- final Binding partialMatchBinding2 = new KeyBinding(partialMatch2,
- partialParameterizedCommand2, "na", "na", null, null, null,
- Binding.SYSTEM);
- bindings[0] = partialMatchBinding1;
- bindings[1] = partialMatchBinding2;
- bindingManager.setBindings(bindings);
- assertTrue("Two partial matches should count as a partial",
- bindingManager.isPartialMatch(perfectMatch));
-
- // SCENARIO 3
- bindingManager.addBinding(perfectMatchBinding);
- bindingManager.setBindings(bindings);
- assertTrue("An empty sequence matches everything partially",
- bindingManager.isPartialMatch(KeySequence.getInstance()));
- }
-
- /**
- * Tests that this method returns <code>true</code> when expected. In the
- * first scenario, there is one perfect match bindings and a partial match
- * binding. In the second scenario, there are two partial match bindings. In
- * the third scenario, we are checking that nothing matches an empty
- * sequence.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- * @throws ParseException
- * If the hard-coded strings aren't constructed properly.
- */
- public final void testIsPerfectMatch() throws NotDefinedException,
- ParseException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // SCENARIO 1
- final KeySequence perfectMatch = KeySequence.getInstance("CTRL+F");
- final Command perfectCommand = commandManager.getCommand("perfect");
- final ParameterizedCommand perfectParameterizedCommand = new ParameterizedCommand(
- perfectCommand, null);
- final Binding perfectMatchBinding = new KeyBinding(perfectMatch,
- perfectParameterizedCommand, "na", "na", null, null, null,
- Binding.SYSTEM);
- final KeySequence partialMatch1 = KeySequence
- .getInstance("CTRL+F CTRL+F");
- final Command partialCommand1 = commandManager.getCommand("partial1");
- final ParameterizedCommand partialParameterizedCommand1 = new ParameterizedCommand(
- partialCommand1, null);
- final Binding partialMatchBinding1 = new KeyBinding(partialMatch1,
- partialParameterizedCommand1, "na", "na", null, null, null,
- Binding.SYSTEM);
- final Binding[] bindings = new Binding[2];
- bindings[0] = perfectMatchBinding;
- bindings[1] = partialMatchBinding1;
- bindingManager.setBindings(bindings);
- assertTrue("This should be a perfect match", bindingManager
- .isPerfectMatch(perfectMatch));
-
- // SCENARIO 2
- final KeySequence partialMatch2 = KeySequence
- .getInstance("CTRL+F CTRL+F CTRL+F");
- final Command partialCommand2 = commandManager.getCommand("perfect");
- final ParameterizedCommand partialParameterizedCommand2 = new ParameterizedCommand(
- partialCommand2, null);
- final Binding partialMatchBinding2 = new KeyBinding(partialMatch2,
- partialParameterizedCommand2, "na", "na", null, null, null,
- Binding.SYSTEM);
- bindings[0] = partialMatchBinding1;
- bindings[1] = partialMatchBinding2;
- bindingManager.setBindings(bindings);
- assertTrue("This should be no perfect matches", !bindingManager
- .isPerfectMatch(perfectMatch));
-
- // SCENARIO 3
- bindingManager.addBinding(perfectMatchBinding);
- assertTrue("This should be no perfect matches", !bindingManager
- .isPerfectMatch(KeySequence.getInstance()));
- }
-
- /**
- * Tests that you can remove binding, and that it will change the active
- * bindings as well.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public final void testRemoveBindings() throws NotDefinedException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // ADD SOME BINDINGS
- final Binding binding1 = new TestBinding("command1", "na", "na", null,
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding1);
- final Binding binding2 = new TestBinding("command2", "na", "na", "zh",
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding2);
- final Binding binding3 = new TestBinding("command3", "na", "na", null,
- "gtk", Binding.SYSTEM, null);
- bindingManager.addBinding(binding3);
- final Binding binding4 = new TestBinding("command4", "na", "na", null,
- "gtk", Binding.USER, null);
- bindingManager.addBinding(binding4);
- final Binding binding5 = new TestBinding("command5", "na", "na", "zh",
- "gtk", Binding.USER, null);
- bindingManager.addBinding(binding5);
- assertNotNull("There should be three active bindings", bindingManager
- .getActiveBindingsFor(binding1.getParameterizedCommand()));
- assertNotNull("There should be three active bindings", bindingManager
- .getActiveBindingsFor(binding2.getParameterizedCommand()));
- assertNotNull("There should be three active bindings", bindingManager
- .getActiveBindingsFor(binding4.getParameterizedCommand()));
-
- // REMOVE SOME BINDINGS
- bindingManager.removeBindings(TestBinding.TRIGGER_SEQUENCE, "na", "na",
- "zh", "gtk", null, Binding.USER);
- assertEquals("There should be four bindings left", 4, bindingManager
- .getBindings().length);
- assertNotNull("There should be four active bindings", bindingManager
- .getActiveBindingsFor(binding1.getParameterizedCommand()));
- assertNotNull("There should be four active bindings", bindingManager
- .getActiveBindingsFor(binding2.getParameterizedCommand()));
- assertNotNull("There should be four active bindings", bindingManager
- .getActiveBindingsFor(binding3.getParameterizedCommand()));
- assertNotNull("There should be four active bindings", bindingManager
- .getActiveBindingsFor(binding4.getParameterizedCommand()));
- }
-
- /**
- * Verifies that selecting an undefimned scheme doesn't work. Verifies that
- * selecting a scheme works. Verifies that undefining scheme removes it as
- * the active scheme.
- */
- public final void testSetActiveScheme() {
- // SELECT UNDEFINED
- final String schemeId = "schemeId";
- final Scheme scheme = bindingManager.getScheme(schemeId);
- try {
- bindingManager.setActiveScheme(scheme);
- fail("Cannot activate an undefined scheme");
- } catch (final NotDefinedException e) {
- // Success
- }
-
- // SELECT DEFINED
- scheme.define("name", "description", null);
- try {
- bindingManager.setActiveScheme(scheme);
- assertSame("The schemes should match", scheme, bindingManager
- .getActiveScheme());
- } catch (final NotDefinedException e) {
- fail("Should be able to activate a scheme");
- }
-
- // UNDEFINE SELECTED
- scheme.undefine();
- assertNull("The scheme should have become unselected", bindingManager
- .getActiveScheme());
- }
-
- public void testGetCurrentConflicts() throws NotDefinedException, ParseException {
-
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- contextManager.setActiveContextIds(null);
-
- Command command1 = commandManager.getCommand("conflictCommand1");
- ParameterizedCommand parameterizedCommand1 = ParameterizedCommand.generateCommand(command1, null);
- Command command2 = commandManager.getCommand("conflictCommand2");
- ParameterizedCommand parameterizedCommand2 = ParameterizedCommand.generateCommand(command2, null);
- Command command3 = commandManager.getCommand("conflictCommand3");
- ParameterizedCommand parameterizedCommand3 = ParameterizedCommand.generateCommand(command3, null);
- KeySequence conflict = KeySequence.getInstance("M1+M2+9");
- KeySequence noConflict = KeySequence.getInstance("M1+M2+8");
- Binding binding1 = new KeyBinding(conflict, parameterizedCommand1, "na", "na", null, null, null,
- Binding.SYSTEM);
- Binding binding2 = new KeyBinding(conflict, parameterizedCommand2, "na", "na", null, null, null,
- Binding.SYSTEM);
- Binding binding3 = new KeyBinding(noConflict, parameterizedCommand3, "na", "na", null, null, null,
- Binding.SYSTEM);
- final Binding[] bindings = new Binding[] {binding1, binding2, binding3};
- bindingManager.setBindings(bindings);
-
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- Map activeBindingsDisregardingContext = bindingManager.getActiveBindingsDisregardingContext();// force a recompute
- assertNotNull(activeBindingsDisregardingContext);
-
- Map currentConflicts = bindingManager.getCurrentConflicts();
- assertEquals(1, currentConflicts.size()); // we have only one conflict
-
- Collection conflictsCollection = bindingManager.getConflictsFor(noConflict);
- assertNull(conflictsCollection); // no conflict for this keybinding
-
- conflictsCollection = bindingManager.getConflictsFor(conflict);
- assertNotNull(conflictsCollection); // this has one conflict with 2 commands
- assertEquals(2, conflictsCollection.size());
-
- }
-
- /**
- * Verifies that you can set the bindings to null. Verifies that setting the
- * bindings clears the cache.
- *
- * @throws NotDefinedException
- * If this test doesn't properly define a scheme.
- */
- public final void testSetBindings() throws NotDefinedException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // SET NULL
- bindingManager.setBindings(null);
- assertTrue("There should be no active bindings", bindingManager
- .getActiveBindingsFor((ParameterizedCommand) null).length == 0);
-
- // ADD BINDING
- final String commandId = "commandId";
- final Binding binding = new TestBinding(commandId, "na", "na", null,
- null, Binding.SYSTEM, null);
- final Binding[] bindings = new Binding[1];
- bindings[0] = binding;
- bindingManager.setBindings(bindings);
- final TriggerSequence[] activeBindings = bindingManager
- .getActiveBindingsFor(binding.getParameterizedCommand());
- assertEquals("There should be one active binding", 1,
- activeBindings.length);
- assertSame("The binding should be the one we set",
- TestBinding.TRIGGER_SEQUENCE, activeBindings[0]);
- }
-
- /**
- * Verifies that it cannot be set to <code>null</code>. Verifies that it
- * clears the cache.
- *
- * @throws NotDefinedException
- * If this test doesn't properly define a scheme.
- */
- public final void testSetLocale() throws NotDefinedException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // SET TO NULL
- try {
- bindingManager.setLocale(null);
- fail("Cannot set the locale to null");
- } catch (final NullPointerException e) {
- // Success
- }
-
- // SET TO SOMETHING
- final String commandId = "commandId";
- final Binding binding = new TestBinding(commandId, "na", "na", "xx",
- null, Binding.SYSTEM, null);
- bindingManager.addBinding(binding);
- assertTrue("The binding shouldn't be active",
- bindingManager.getActiveBindingsFor(binding
- .getParameterizedCommand()).length == 0);
- bindingManager.setLocale("xx_XX");
- final TriggerSequence[] activeBindings = bindingManager
- .getActiveBindingsFor(binding.getParameterizedCommand());
- assertEquals("The binding should become active", 1,
- activeBindings.length);
- assertSame("The binding should be the same",
- TestBinding.TRIGGER_SEQUENCE, activeBindings[0]);
- }
-
- /**
- * Verifies that it cannot be set to <code>null</code>. Verifies that it
- * clears the cache.
- *
- * @throws NotDefinedException
- * If this test doesn't properly define a scheme.
- */
- public final void testSetPlatform() throws NotDefinedException {
- // GENERAL SET-UP
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- // SET TO NULL
- try {
- bindingManager.setPlatform(null);
- fail("Cannot set the platform to null");
- } catch (final NullPointerException e) {
- // Success
- }
-
- // SET TO SOMETHING
- final String commandId = "commandId";
- final Binding binding = new TestBinding(commandId, "na", "na", null,
- "atari", Binding.SYSTEM, null);
- bindingManager.addBinding(binding);
- assertTrue("The binding shouldn't be active",
- bindingManager.getActiveBindingsFor(binding
- .getParameterizedCommand()).length == 0);
- bindingManager.setPlatform("atari");
- final TriggerSequence[] activeBindings = bindingManager
- .getActiveBindingsFor(binding.getParameterizedCommand());
- assertEquals("The binding should become active", 1,
- activeBindings.length);
- assertSame("The binding should be the same",
- TestBinding.TRIGGER_SEQUENCE, activeBindings[0]);
- }
-
- /**
- * Tests whether the method works with a null argument. Tests that it works
- * in a simple case.
- *
- * @throws NotDefinedException
- * If the scheme we try to activate is not defined.
- */
- public final void testGetBestActiveBindingFor() throws Exception {
- // Test with a null argument.
- final TriggerSequence[] activeBindingsForNull = bindingManager
- .getActiveBindingsFor((ParameterizedCommand) null);
- assertNotNull("The active bindings for a command should never be null",
- activeBindingsForNull);
- assertTrue(
- "The active binding for a null command should always be empty",
- activeBindingsForNull.length == 0);
-
- // Test a simple case.
- final Context context = contextManager.getContext("na");
- context.define("name", "description", null);
-
- final Scheme scheme = bindingManager.getScheme("na");
- scheme.define("name", "description", null);
-
- bindingManager.setActiveScheme(scheme);
- final Set activeContextIds = new HashSet();
- activeContextIds.add("na");
- contextManager.setActiveContextIds(activeContextIds);
-
- final String commandId = "commandId";
- final String categoryId = "cat";
- Category cat = commandManager.getCategory(categoryId);
- cat.define("cat", "cat");
- Command cmd = commandManager.getCommand(commandId);
- IParameter[] parms = new IParameter[1];
- parms[0] = new IParameter() {
- public String getId() {
- return "viewId";
- }
-
- public String getName() {
- return "View Id";
- }
-
- public IParameterValues getValues() throws ParameterValuesException {
- return null;
- }
-
- public boolean isOptional() {
- return false;
- }
- };
- cmd.define("na", "NA", cat, parms);
- Map map = new HashMap();
- map.put("viewId", "outline");
- ParameterizedCommand outline = ParameterizedCommand.generateCommand(
- cmd, map);
- map = new HashMap();
- map.put("viewId", "console");
- ParameterizedCommand console = ParameterizedCommand.generateCommand(
- cmd, map);
- assertFalse(outline.equals(console));
-
- final Binding b2 = new KeyBinding(KeySequence.getInstance("M1+M2+V"),
- outline, "na", "na", null, null, null, Binding.SYSTEM);
- bindingManager.addBinding(b2);
-
- final Binding binding = new KeyBinding(KeySequence.getInstance("M1+V"),
- outline, "na", "na", null, null, null, Binding.SYSTEM);
- bindingManager.addBinding(binding);
-
- final Binding b3 = new KeyBinding(KeySequence.getInstance("M1+M2+C"),
- console, "na", "na", null, null, null, Binding.SYSTEM);
- bindingManager.addBinding(b3);
-
- // - above is all done as part of startup
-
- final TriggerSequence[] bindings = bindingManager
- .getActiveBindingsFor(binding.getParameterizedCommand());
- assertEquals(2, bindings.length);
-
- final TriggerSequence bestBinding = bindingManager.getBestActiveBindingFor(outline);
- assertEquals(binding.getTriggerSequence(), bestBinding);
-
- final TriggerSequence bestBinding2 = bindingManager.getBestActiveBindingFor(console);
- assertEquals(b3.getTriggerSequence(), bestBinding2);
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingPersistenceTest.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingPersistenceTest.java
deleted file mode 100755
index 924e407..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/BindingPersistenceTest.java
+++ /dev/null
@@ -1,599 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.util.HashMap;
-
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.e4.ui.bindings.EBindingService;
-import org.eclipse.jface.bindings.Binding;
-import org.eclipse.jface.bindings.Scheme;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.bindings.keys.KeyBinding;
-import org.eclipse.jface.bindings.keys.KeySequence;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.Util;
-import org.eclipse.swt.SWT;
-import org.eclipse.ui.IWorkbenchCommandConstants;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.keys.BindingService;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Test cases covering the various interaction between bindings. Bindings that
- * have been removed. Bindings that have been added. Inheritance of various
- * properties.
- *
- * @since 3.1
- */
-public final class BindingPersistenceTest extends UITestCase {
-
- private final String EMACS_SCHEME_ID = "org.eclipse.ui.emacsAcceleratorConfiguration";
-
- /**
- * Constructor for <code>BindingPersistenceTest</code>.
- *
- * @param name
- * The name of the test
- */
- public BindingPersistenceTest(final String name) {
- super(name);
- }
-
- /**
- * <p>
- * Tests whether the preference store will be read automatically when a
- * change to the preference store is made.
- * </p>
- *
- * @throws ParseException
- * If "ALT+SHIFT+Q A" cannot be parsed by KeySequence.
- */
- public final void testAutoLoad() throws ParseException {
- // Get the services.
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
- bindingService.readRegistryAndPreferences(commandService);
-
- // Check the pre-conditions.
- final String emacsSchemeId = EMACS_SCHEME_ID;
- assertFalse("The active scheme should be Emacs yet",
- emacsSchemeId.equals(bindingService.getActiveScheme().getId()));
- final KeySequence formalKeySequence = KeySequence
- .getInstance("ALT+SHIFT+Q A");
- final String commandId = "org.eclipse.ui.views.showView";
- Binding[] bindings = bindingService.getBindings();
- int i;
- for (i = 0; i < bindings.length; i++) {
- final Binding binding = bindings[i];
- if ((binding.getType() == Binding.USER)
- && (formalKeySequence.equals(binding.getTriggerSequence()))) {
- final ParameterizedCommand command = binding
- .getParameterizedCommand();
- final String actualCommandId = (command == null) ? null
- : command.getCommand().getId();
- assertFalse("The command should not yet be bound",
- commandId.equals(actualCommandId));
- break;
- }
- }
- assertEquals("There shouldn't be a matching command yet",
- bindings.length, i);
-
- // Modify the preference store.
- final IPreferenceStore store = WorkbenchPlugin.getDefault()
- .getPreferenceStore();
- store.setValue(
- "org.eclipse.ui.commands",
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><org.eclipse.ui.commands><activeKeyConfiguration keyConfigurationId=\""
- + emacsSchemeId
- + "\"/><keyBinding commandId=\""
- + commandId
- + "\" contextId=\"org.eclipse.ui.contexts.window\" keyConfigurationId=\"org.eclipse.ui.defaultAcceleratorConfiguration\" keySequence=\""
- + formalKeySequence + "\"/></org.eclipse.ui.commands>");
-
- // Check that the values have changed.
- assertEquals("The active scheme should now be Emacs", emacsSchemeId,
- bindingService.getActiveScheme().getId());
- bindings = bindingService.getBindings();
- for (i = 0; i < bindings.length; i++) {
- final Binding binding = bindings[i];
- if ((binding.getType() == Binding.USER)
- && (formalKeySequence.equals(binding.getTriggerSequence()))) {
- final ParameterizedCommand command = binding
- .getParameterizedCommand();
- final String actualCommandId = (command == null) ? null
- : command.getCommand().getId();
- assertEquals("The command should be bound to 'ALT+SHIFT+Q A'",
- commandId, actualCommandId);
- break;
- }
- }
- assertFalse("There should be a matching command now",
- (bindings.length == i));
- }
-
- public final void testSinglePlatform() throws Exception {
- // Get the services.
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- ParameterizedCommand about = new ParameterizedCommand(
- commandService.getCommand("org.eclipse.ui.help.aboutAction"),
- null);
- KeySequence m18A = KeySequence.getInstance("M1+8 A");
- KeySequence m18B = KeySequence.getInstance("M1+8 B");
- int numAboutBindings = 0;
-
- Binding[] bindings = bindingService.getBindings();
- for (int i = 0; i < bindings.length; i++) {
- final Binding binding = bindings[i];
- if (binding.getType() == Binding.SYSTEM) {
- String platform = binding.getPlatform();
- int idx = (platform == null ? -1 : platform.indexOf(','));
- assertEquals(binding.toString(), -1, idx);
- if (about.equals(binding.getParameterizedCommand())) {
- if (m18A.equals(binding.getTriggerSequence())) {
- numAboutBindings++;
- assertNull("M+8 A", binding.getPlatform());
- } else if (m18B.equals(binding.getTriggerSequence())) {
- numAboutBindings++;
- // assertEquals(Util.WS_CARBON, binding.getPlatform());
- // temp work around for honouring carbon bindings
- assertTrue(
- "failure for platform: "
- + binding.getPlatform(),
- Util.WS_CARBON.equals(binding.getPlatform())
- || Util.WS_COCOA.equals(binding
- .getPlatform()));
- }
- }
- }
- }
- if (Util.WS_CARBON.equals(SWT.getPlatform())
- || Util.WS_COCOA.equals(SWT.getPlatform())) {
- assertEquals(2, numAboutBindings);
- } else {
- assertEquals(1, numAboutBindings);
- }
- }
-
- public final void testBindingTransform() throws Exception {
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- ParameterizedCommand addWS = new ParameterizedCommand(
- commandService
- .getCommand("org.eclipse.ui.navigate.addToWorkingSet"),
- null);
- KeySequence m18w = KeySequence.getInstance("M1+8 W");
- KeySequence m28w = KeySequence.getInstance("M2+8 W");
- boolean foundDeleteMarker = false;
- int numOfMarkers = 0;
- Binding[] bindings = bindingService.getBindings();
- for (int i = 0; i < bindings.length; i++) {
- final Binding binding = bindings[i];
- if (binding.getType() == Binding.SYSTEM) {
- String platform = binding.getPlatform();
- int idx = (platform == null ? -1 : platform.indexOf(','));
- assertEquals(binding.toString(), -1, idx);
- if (addWS.equals(binding.getParameterizedCommand())) {
- if (m18w.equals(binding.getTriggerSequence())) {
- numOfMarkers++;
- assertNull(m18w.format(), binding.getPlatform());
- } else if (m28w.equals(binding.getTriggerSequence())) {
- numOfMarkers++;
- assertTrue(platform, Util.WS_CARBON.equals(platform)
- || Util.WS_COCOA.equals(platform)
- || Util.WS_GTK.equals(platform)
- || Util.WS_WIN32.equals(platform));
- }
- } else if (binding.getParameterizedCommand() == null
- && m18w.equals(binding.getTriggerSequence())) {
- assertTrue(
- platform,
- Util.WS_CARBON.equals(platform)
- || Util.WS_COCOA.equals(platform)
- || Util.WS_GTK.equals(platform)
- || Util.WS_WIN32.equals(platform));
- numOfMarkers++;
- foundDeleteMarker = true;
- }
- }
- }
- assertEquals(3, numOfMarkers);
- assertTrue("Unable to find delete marker", foundDeleteMarker);
- TriggerSequence[] activeBindingsFor = bindingService
- .getActiveBindingsFor(addWS);
- assertEquals(1, activeBindingsFor.length);
- }
-
- public void testModifierWithPlatform() throws Exception {
-
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
- ParameterizedCommand importCmd = new ParameterizedCommand(
- commandService.getCommand("org.eclipse.ui.file.import"), null);
- Binding[] bindings = bindingService.getBindings();
- int numOfMarkers = 0;
- for (int i = 0; i < bindings.length; i++) {
- final Binding binding = bindings[i];
- if (binding.getType() != Binding.SYSTEM)
- continue;
-
- if (importCmd.equals(binding.getParameterizedCommand())) {
- // make sure the modifier is applied
- assertEquals(KeySequence.getInstance("M2+8 I"),
- binding.getTriggerSequence());
- numOfMarkers++;
- }
- }
-
- // only one binding, if the platform matches
- assertEquals(numOfMarkers, 1);
- }
-
- public void testModifierNotApplied() throws Exception {
-
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
- ParameterizedCommand exportCmd = new ParameterizedCommand(
- commandService.getCommand("org.eclipse.ui.file.export"), null);
- Binding[] bindings = bindingService.getBindings();
- for (int i = 0; i < bindings.length; i++) {
- final Binding binding = bindings[i];
- if (binding.getType() != Binding.SYSTEM)
- continue;
-
- if (exportCmd.equals(binding.getParameterizedCommand())) {
- // make sure the modifier is NOT applied
- assertEquals(KeySequence.getInstance("M1+8 E"),
- binding.getTriggerSequence());
- break;
- }
- }
- }
-
- public void testDifferentPlatform() throws Exception {
-
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
- ParameterizedCommand backCmd = new ParameterizedCommand(
- commandService.getCommand("org.eclipse.ui.navigate.back"), null);
- Binding[] bindings = bindingService.getBindings();
- for (int i = 0; i < bindings.length; i++) {
- final Binding binding = bindings[i];
- if (binding.getType() != Binding.SYSTEM)
- continue;
-
- if (backCmd.equals(binding.getParameterizedCommand())) {
- // make sure the modifier is NOT applied
- // this will fail on Photon (but Paul thinks we'll never run the
- // test suite on that platform :-)
- assertEquals(KeySequence.getInstance("M1+8 Q"),
- binding.getTriggerSequence());
- // and the platform should be null
- assertNull(binding.getPlatform());
- break;
- }
- }
- }
-
- public void testAboutBinding() throws Exception {
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- final Scheme activeScheme = bindingService.getActiveScheme();
- final Binding[] originalBindings = bindingService.getBindings();
-
- ParameterizedCommand aboutCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.HELP_ABOUT),
- null);
- ParameterizedCommand activateEditorCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.WINDOW_ACTIVATE_EDITOR),
- null);
-
- final KeySequence keyF12 = KeySequence.getInstance("F12");
- final KeySequence keyAltCtrlShiftI = KeySequence
- .getInstance("ALT+CTRL+SHIFT+I");
- final Binding editorBinding = bindingService.getPerfectMatch(keyF12);
- assertNotNull(editorBinding);
- assertEquals(activateEditorCmd, editorBinding.getParameterizedCommand());
-
- EBindingService ebs = (EBindingService) fWorkbench
- .getService(EBindingService.class);
- HashMap<String, String> attrs = new HashMap<String, String>();
- attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
- final Binding localAboutBinding = ebs.createBinding(keyF12, aboutCmd,
- IContextService.CONTEXT_ID_WINDOW, attrs);
- assertEquals(Binding.USER, localAboutBinding.getType());
-
- // test unbinding a system binding and adding a user binding (same
- // triggers and context)
- final Binding[] bindings = originalBindings;
- Binding[] added = new Binding[bindings.length + 2];
- System.arraycopy(bindings, 0, added, 0, bindings.length);
-
- Binding del = new KeyBinding(keyF12, null,
- IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID,
- IContextService.CONTEXT_ID_WINDOW, null, null, null,
- Binding.USER);
- added[bindings.length] = del;
- added[bindings.length + 1] = localAboutBinding;
- bindingService.savePreferences(activeScheme, added);
-
- // the match should be the user binding that we just added
- final Binding secondMatch = bindingService.getPerfectMatch(keyF12);
- assertNotNull(secondMatch);
- assertEquals(aboutCmd, secondMatch.getParameterizedCommand());
-
- // go back to the defaults
- bindingService.savePreferences(activeScheme, originalBindings);
- final Binding thirdMatch = bindingService.getPerfectMatch(keyF12);
- assertNotNull(thirdMatch);
- assertEquals(activateEditorCmd, thirdMatch.getParameterizedCommand());
-
- // try assigning alt-ctrl-shift-i (no other binding uses this for this
- // context) to the 'about' command
- final Binding localAboutBinding1 = ebs.createBinding(keyAltCtrlShiftI,
- aboutCmd, IContextService.CONTEXT_ID_WINDOW, attrs);
- assertEquals(Binding.USER, localAboutBinding1.getType());
- Binding[] added1 = new Binding[bindings.length + 1];
- System.arraycopy(bindings, 0, added1, 0, bindings.length);
- added1[bindings.length] = localAboutBinding1;
-
- bindingService.savePreferences(activeScheme, added1);
- final Binding fourthMatch = bindingService
- .getPerfectMatch(keyAltCtrlShiftI);
- assertNotNull(fourthMatch);
- assertEquals(aboutCmd, fourthMatch.getParameterizedCommand());
- }
-
- public void testAboutBindingIn3x() throws Exception {
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- final Scheme activeScheme = bindingService.getActiveScheme();
-
- ParameterizedCommand aboutCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.HELP_ABOUT),
- null);
- ParameterizedCommand activateEditorCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.WINDOW_ACTIVATE_EDITOR),
- null);
-
- final KeySequence keyF12 = KeySequence.getInstance("F12");
- final Binding editorBinding = bindingService.getPerfectMatch(keyF12);
- assertNotNull(editorBinding);
- assertEquals(activateEditorCmd, editorBinding.getParameterizedCommand());
-
- EBindingService ebs = (EBindingService) fWorkbench
- .getService(EBindingService.class);
- HashMap<String, String> attrs = new HashMap<String, String>();
- attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
- final Binding localAboutBinding = ebs.createBinding(keyF12, aboutCmd,
- IContextService.CONTEXT_ID_WINDOW, attrs);
- assertEquals(Binding.USER, localAboutBinding.getType());
-
- final Binding[] bindings = bindingService.getBindings();
- Binding[] added = new Binding[bindings.length + 1];
- System.arraycopy(bindings, 0, added, 0, bindings.length);
-
- added[bindings.length] = localAboutBinding;
- bindingService.savePreferences(activeScheme, added);
-
- final Binding secondMatch = bindingService.getPerfectMatch(keyF12);
- // fails
- assertNotNull(secondMatch);
- assertEquals(aboutCmd, secondMatch.getParameterizedCommand());
- }
-
- public void testAboutBindingEmacs() throws Exception {
-
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- final Scheme emacsScheme = bindingService.getScheme(EMACS_SCHEME_ID);
- assertNotNull(emacsScheme);
- final Binding[] originalBindings = bindingService.getBindings();
- bindingService.savePreferences(emacsScheme, originalBindings);
-
- ParameterizedCommand findAndReplaceCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE),
- null);
- ParameterizedCommand aboutCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.HELP_ABOUT),
- null);
-
- final KeySequence keyAltR = KeySequence.getInstance("ALT+R");
- final KeySequence keyAltCtrlShiftI = KeySequence
- .getInstance("ALT+CTRL+SHIFT+I");
- final Binding findAndReplaceBinding = bindingService
- .getPerfectMatch(keyAltR);
-
- assertNotNull(findAndReplaceBinding);
- assertEquals(findAndReplaceCmd,
- findAndReplaceBinding.getParameterizedCommand());
- assertEquals(EMACS_SCHEME_ID, findAndReplaceBinding.getSchemeId());
-
- EBindingService ebs = (EBindingService) fWorkbench
- .getService(EBindingService.class);
- HashMap<String, String> attrs = new HashMap<String, String>();
- attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
- attrs.put(EBindingService.SCHEME_ID_ATTR_TAG, EMACS_SCHEME_ID);
- final Binding localAboutBinding = ebs.createBinding(keyAltR, aboutCmd,
- IContextService.CONTEXT_ID_WINDOW, attrs);
- assertNotNull(localAboutBinding);
- assertEquals(Binding.USER, localAboutBinding.getType());
- assertEquals(EMACS_SCHEME_ID, localAboutBinding.getSchemeId());
-
- final Binding[] bindings = originalBindings;
- Binding[] added = new Binding[bindings.length + 2];
- System.arraycopy(bindings, 0, added, 0, bindings.length);
-
- Binding del = new KeyBinding(keyAltR, null, EMACS_SCHEME_ID,
- IContextService.CONTEXT_ID_WINDOW, null, null, null,
- Binding.USER);
- added[bindings.length] = del;
- added[bindings.length + 1] = localAboutBinding;
- bindingService.savePreferences(emacsScheme, added);
-
- // the match should be the user binding that we just added
- final Binding secondMatch = bindingService.getPerfectMatch(keyAltR);
- assertNotNull(secondMatch);
- assertEquals(aboutCmd, secondMatch.getParameterizedCommand());
-
- // go back to the defaults
- bindingService.savePreferences(emacsScheme, originalBindings);
- final Binding thirdMatch = bindingService.getPerfectMatch(keyAltR);
- assertNotNull(thirdMatch);
- assertEquals(findAndReplaceCmd, thirdMatch.getParameterizedCommand());
-
- // try assigning alt-ctrl-shift-i (no other binding uses this for this
- // context) to the 'about' command
- final Binding localAboutBinding1 = ebs.createBinding(keyAltCtrlShiftI,
- aboutCmd, IContextService.CONTEXT_ID_WINDOW, attrs);
- assertNotNull(localAboutBinding1);
- assertEquals(Binding.USER, localAboutBinding1.getType());
- assertEquals(EMACS_SCHEME_ID, localAboutBinding.getSchemeId());
-
- Binding[] added1 = new Binding[bindings.length + 1];
- System.arraycopy(bindings, 0, added1, 0, bindings.length);
- added1[bindings.length] = localAboutBinding1;
-
- bindingService.savePreferences(emacsScheme, added1);
- final Binding fourthMatch = bindingService
- .getPerfectMatch(keyAltCtrlShiftI);
- assertNotNull(fourthMatch);
- assertEquals(aboutCmd, fourthMatch.getParameterizedCommand());
- assertEquals(EMACS_SCHEME_ID, fourthMatch.getSchemeId());
- }
-
- // the 'paste' key binding overrides the 'redo' key binding on Windows
- // platforms
- public void testPasteAndRedoBindingEmacs() throws Exception {
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- final Scheme emacsScheme = bindingService.getScheme(EMACS_SCHEME_ID);
- assertNotNull(emacsScheme);
- final Scheme defaultScheme = bindingService
- .getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID);
- assertNotNull(defaultScheme);
-
- final Binding[] originalBindings = bindingService.getBindings();
- bindingService.savePreferences(emacsScheme, originalBindings);
-
- ParameterizedCommand pasteCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.EDIT_PASTE),
- null);
- ParameterizedCommand redoCmd = new ParameterizedCommand(
- commandService.getCommand(IWorkbenchCommandConstants.EDIT_REDO),
- null);
-
- final KeySequence keyCtrlY = KeySequence.getInstance("CTRL+Y");
-
- final Binding pasteBinding = bindingService.getPerfectMatch(keyCtrlY);
- assertNotNull(pasteBinding);
- assertEquals(pasteCmd, pasteBinding.getParameterizedCommand());
- assertEquals(EMACS_SCHEME_ID, pasteBinding.getSchemeId());
-
- // reset the scheme
- bindingService.savePreferences(defaultScheme, originalBindings);
- final Binding redoBinding = bindingService.getPerfectMatch(keyCtrlY);
- assertNotNull(redoBinding);
- assertEquals(redoCmd, redoBinding.getParameterizedCommand());
- assertEquals(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID,
- redoBinding.getSchemeId());
- }
-
- // the 'paste' key binding overrides the 'redo' key binding and can be
- // put back
- public void testPasteBindingEmacs() throws Exception {
- ICommandService commandService = (ICommandService) fWorkbench
- .getAdapter(ICommandService.class);
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- final Scheme emacsScheme = bindingService.getScheme(EMACS_SCHEME_ID);
- assertNotNull(emacsScheme);
- final Binding[] originalBindings = bindingService.getBindings();
- bindingService.savePreferences(emacsScheme, originalBindings);
-
- ParameterizedCommand pasteCmd = new ParameterizedCommand(
- commandService
- .getCommand(IWorkbenchCommandConstants.EDIT_PASTE),
- null);
-
- final KeySequence keyCtrlY = KeySequence.getInstance("CTRL+Y");
-
- final Binding pasteBinding = bindingService.getPerfectMatch(keyCtrlY);
- assertNotNull(pasteBinding);
- assertEquals(pasteCmd, pasteBinding.getParameterizedCommand());
- assertEquals(EMACS_SCHEME_ID, pasteBinding.getSchemeId());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.tests.harness.util.UITestCase#doTearDown()
- */
- protected void doTearDown() throws Exception {
- final IPreferenceStore store = WorkbenchPlugin.getDefault()
- .getPreferenceStore();
- store.setValue(
- "org.eclipse.ui.commands",
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><org.eclipse.ui.commands><activeKeyConfiguration keyConfigurationId=\""
- + IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID
- + "\"/></org.eclipse.ui.commands>");
- IBindingService bindingService = (IBindingService) fWorkbench
- .getAdapter(IBindingService.class);
-
- // reset keybindings
- bindingService.readRegistryAndPreferences(null);
- final Scheme activeScheme = bindingService
- .getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID);
- final Binding[] originalBindings = bindingService.getBindings();
- bindingService.savePreferences(activeScheme, originalBindings);
- super.doTearDown();
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug189167Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug189167Test.java
deleted file mode 100755
index 67bcafd..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug189167Test.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jface.bindings.Binding;
-
-/**
- * Tests Bug 189167
- *
- * @since 3.4
- */
-public class Bug189167Test extends TestCase {
-
- private Binding createTestBinding() {
- return new TestBinding("commandId", "schemeId", "contextId", "locale", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- "platform", 0, null); //$NON-NLS-1$
- }
-
- public void testBindingsEqual() {
- Binding one = createTestBinding();
- Binding two = createTestBinding();
- assertEquals(one, two);
- }
-
- public void testHashCodeEquals(){
- Binding one = createTestBinding();
- Binding two = createTestBinding();
- Binding b3 = new TestBinding("commandID", "schemeID", "contextID", "locale", "platform", 1, null);
- assertEquals(one, two);
- assertEquals(one.hashCode(), two.hashCode());
-
- assertFalse(one.equals(b3));
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36420Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36420Test.java
deleted file mode 100755
index 04f7538..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36420Test.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.ui.commands.ICommandManager;
-import org.eclipse.ui.internal.IWorkbenchConstants;
-import org.eclipse.ui.keys.KeySequence;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests Bug 36420
- *
- * @since 3.0
- */
-public class Bug36420Test extends UITestCase {
-
- /**
- * Constructor for Bug36420Test.
- *
- * @param name
- * The name of the test
- */
- public Bug36420Test(String name) {
- super(name);
- }
-
- /**
- * Tests that importing key preferences actually has an effect.
- *
- * @throws CoreException
- * If the preferences can't be imported.
- * @throws FileNotFoundException
- * If the temporary file is removed after it is created, but
- * before it is opened. (Wow)
- * @throws IOException
- * If something fails during output of the preferences file.
- */
- public void testImportKeyPreferences() throws CoreException,
- FileNotFoundException, IOException {
- String commandId = "org.eclipse.ui.window.nextView"; //$NON-NLS-1$
- String keySequenceText = "F S C K"; //$NON-NLS-1$
-
- /*
- * DO NOT USE PreferenceMutator for this section. This test case must
- * use these exact steps, while PreferenceMutator might use something
- * else in the future.
- */
- // Set up the preferences.
- Properties preferences = new Properties();
- String key = "org.eclipse.ui.workbench/org.eclipse.ui.commands"; //$NON-NLS-1$
- String value = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<org.eclipse.ui.commands><activeKeyConfiguration keyConfigurationId=\"" + IWorkbenchConstants.DEFAULT_ACCELERATOR_CONFIGURATION_ID + "\"></activeKeyConfiguration><keyBinding keyConfigurationId=\"org.eclipse.ui.defaultAcceleratorConfiguration\" commandId=\"" + commandId + "\" keySequence=\"" + keySequenceText + "\"/></org.eclipse.ui.commands>"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- preferences.put(key, value);
-
- // This is the first pass way to "walk" through the list
- // of bundles
- String[] pluginIds = Platform.getExtensionRegistry().getNamespaces();
- for (int i = 0; i < pluginIds.length; i++) {
- preferences.put(pluginIds[i], new PluginVersionIdentifier(
- (String) Platform.getBundle(pluginIds[i]).getHeaders().get(
- org.osgi.framework.Constants.BUNDLE_VERSION)));
- }
-
- // Export the preferences.
- File file = File.createTempFile("preferences", ".txt"); //$NON-NLS-1$//$NON-NLS-2$
- file.deleteOnExit();
- BufferedOutputStream bos = new BufferedOutputStream(
- new FileOutputStream(file));
- preferences.store(bos, null);
- bos.close();
-
- // Attempt to import the key binding.
- Preferences.importPreferences(new Path(file.getAbsolutePath()));
- /*
- * END SECTION
- */
-
- // Check to see that the key binding for the given command matches.
- ICommandManager manager = fWorkbench.getCommandSupport()
- .getCommandManager();
- List keyBindings = manager.getCommand(commandId)
- .getKeySequenceBindings();
- Iterator keyBindingItr = keyBindings.iterator();
- boolean found = false;
- while (keyBindingItr.hasNext()) {
- KeySequence keyBinding = (KeySequence) keyBindingItr.next();
- String currentText = keyBinding.toString();
- if (keySequenceText.equals(currentText)) {
- found = true;
- }
- }
-
- assertTrue("Key binding not imported.", found); //$NON-NLS-1$
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36537Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36537Test.java
deleted file mode 100755
index 6923e3b..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug36537Test.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.jface.bindings.Binding;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests Bug 36537
- *
- * @since 3.0
- */
-public class Bug36537Test extends UITestCase {
-
- /**
- * Constructor for Bug36537Test.
- *
- * @param name
- * The name of the test
- */
- public Bug36537Test(String name) {
- super(name);
- }
-
- /**
- * Tests that there are no redundant key bindings defined in the
- * application.
- */
- public void testForRedundantKeySequenceBindings() {
- final IWorkbenchWindow window = openTestWindow();
- final IWorkbench workbench = window.getWorkbench();
- final IBindingService bindingService = (IBindingService) workbench
- .getAdapter(IBindingService.class);
- final Binding[] bindings = bindingService.getBindings();
- final int bindingCount = bindings.length;
- Map keySequenceBindingsByKeySequence = new HashMap();
-
- for (int i = 0; i < bindingCount; i++) {
- // Retrieve the key binding.
- final Binding binding = bindings[i];
-
- // Find the point the bindings with matching key sequences.
- TriggerSequence triggerSequence = binding.getTriggerSequence();
- List matches = (List) keySequenceBindingsByKeySequence
- .get(triggerSequence);
- if (matches == null) {
- matches = new ArrayList();
- keySequenceBindingsByKeySequence.put(triggerSequence, matches);
- }
-
- // Check that we don't have any redundancy or other wackiness.
- Iterator matchItr = matches.iterator();
- while (matchItr.hasNext()) {
- final Binding matchedBinding = (Binding) matchItr.next();
- ParameterizedCommand commandA = binding
- .getParameterizedCommand();
- ParameterizedCommand commandB = matchedBinding
- .getParameterizedCommand();
- String contextA = binding.getContextId();
- String contextB = matchedBinding.getContextId();
- String keyConfA = binding.getSchemeId();
- String keyConfB = matchedBinding.getSchemeId();
- String localeA = binding.getLocale();
- String localeB = matchedBinding.getLocale();
- String platformA = binding.getPlatform();
- String platformB = matchedBinding.getPlatform();
-
- boolean same = true;
- int nullMatches = 0;
- same &= (commandA == null) ? (commandB == null) : (commandA
- .equals(commandB));
- same &= (contextA == null) || (contextB == null)
- || (contextA.equals(contextB));
- if (((contextA == null) || (contextB == null))
- && (contextA != contextB)) {
- nullMatches++;
- }
- same &= (keyConfA == null) || (keyConfB == null)
- || (keyConfA.equals(keyConfB));
- if (((keyConfA == null) || (keyConfB == null))
- && (keyConfA != keyConfB)) {
- nullMatches++;
- }
- same &= (localeA == null) || (localeB == null)
- || (localeA.equals(localeB));
- if (((localeA == null) || (localeB == null))
- && (localeA != localeB)) {
- nullMatches++;
- }
- same &= (platformA == null) || (platformB == null)
- || (platformA.equals(platformB));
- if (((platformA == null) || (platformB == null))
- && (platformA != platformB)) {
- nullMatches++;
- }
-
- assertFalse(
- "Redundant key bindings: " + binding + ", " + matchedBinding, same && (nullMatches < 1)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Add the key binding.
- matches.add(binding);
- }
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug40023Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug40023Test.java
deleted file mode 100755
index b947b3a..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug40023Test.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.common.CommandException;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.Workbench;
-import org.eclipse.ui.internal.keys.BindingService;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests Bug 40023
- *
- * @since 3.0
- */
-public class Bug40023Test extends UITestCase {
-
- /**
- * Retrieves a menu item matching or starting with the given name from an
- * array of menu items.
- *
- * @param menuItems
- * The array of menu items to search; must not be <code>null</code>
- * @param text
- * The text to look for; may be <code>null</code>.
- * @return The menu item, if any is found; <code>null</code> otherwise.
- */
- public static MenuItem getMenuItem(MenuItem[] menuItems, String text) {
- for (int i = 0; i < menuItems.length; i++) {
- if (menuItems[i].getText().startsWith(text)) {
- return menuItems[i];
- }
- }
-
- return null;
- }
-
- /**
- * Constructor for Bug40023Test.
- *
- * @param name
- * The name of the test
- */
- public Bug40023Test(String name) {
- super(name);
- }
-
- /**
- * Tests that check box items on the menu are checked when activated from
- * the keyboard.
- *
- * @throws CommandException
- * If execution of the handler fails.
- * @throws CoreException
- * If the exported preferences file is invalid for some reason.
- * @throws FileNotFoundException
- * If the temporary file is removed before it can be read in.
- * (Wow)
- * @throws IOException
- * If the creation of or the writing to the temporary file
- * fails for some reason.
- * @throws ParseException
- * If the key binding cannot be parsed.
- */
- public void testCheckOnCheckbox() throws CoreException, CommandException,
- FileNotFoundException, IOException, ParseException {
- // Open a window to run the test.
- IWorkbenchWindow window = openTestWindow();
- Workbench workbench = (Workbench) window.getWorkbench();
-
- // Set up a key binding for "Lock Toolbars".
- String commandId = "org.eclipse.ui.window.lockToolBar"; //$NON-NLS-1$
- String keySequenceText = "CTRL+ALT+L"; //$NON-NLS-1$
- PreferenceMutator.setKeyBinding(commandId, keySequenceText);
-
- // Press "CTRL+ALT+L" to lock the toolbars.
- List keyStrokes = new ArrayList();
- keyStrokes.add(KeyStroke.getInstance(keySequenceText));
- Event event = new Event();
- BindingService support = (BindingService) workbench
- .getAdapter(IBindingService.class);
- support.getKeyboard().press(keyStrokes, event);
-
- // Check that the "Lock Toolbars" menu item is now checked.
- Shell shell = window.getShell();
- MenuItem windowMenu = getMenuItem(shell.getMenuBar().getItems(),
- "&Window"); //$NON-NLS-1$
- MenuItem lockToolBarsMenuItem = getMenuItem(windowMenu.getMenu()
- .getItems(), "Lock the &Toolbars"); //$NON-NLS-1$
- assertTrue("Checkbox menu item is not checked.", lockToolBarsMenuItem //$NON-NLS-1$
- .getSelection());
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42024Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42024Test.java
deleted file mode 100755
index c846363..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42024Test.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.jface.bindings.keys.KeySequence;
-import org.eclipse.jface.bindings.keys.KeySequenceText;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests Bug 42024
- *
- * @since 3.0
- */
-public class Bug42024Test extends UITestCase {
-
- /** The shell on which the <code>KeySequenceText</code> is placed. */
- private Shell shell = null;
-
- /** The instance of <code>KeySequenceText</code> we should tinker with. */
- private KeySequenceText text = null;
-
- /**
- * Constructor for Bug42024Test.
- *
- * @param name
- * The name of the test
- */
- public Bug42024Test(String name) {
- super(name);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void doSetUp() throws Exception {
- super.doSetUp();
-
- // Create a window with a KeySequenceText
- Display display = Display.getCurrent();
- shell = new Shell(display);
- shell.setLayout(new RowLayout());
- text = new KeySequenceText(new Text(shell, SWT.BORDER));
-
- // Open it
- shell.pack();
- shell.open();
- }
-
- protected void doTearDown() throws Exception {
- super.doTearDown();
-
- // Close and destroy the window
- shell.close();
- shell.dispose();
-
- // Release the memory.
- shell = null;
- text = null;
- }
-
- /**
- * Tests that the limiting facility on KeySequenceText allows an arbitrary
- * number of key strokes, when the the limit is set to "infinite". In this
- * case, we will use a six stroke sequence.
- *
- * @throws ParseException
- * If the test sequence cannot be parsed.
- */
- public void testInfiniteStrokes() throws ParseException {
- String keySequenceText = "A B C D E F"; //$NON-NLS-1$
- KeySequence keySequence = KeySequence.getInstance(keySequenceText);
- text.setKeyStrokeLimit(KeySequenceText.INFINITE);
- text.setKeySequence(keySequence);
- assertEquals(
- "Infinite limit but sequence changed.", keySequence, text.getKeySequence()); //$NON-NLS-1$
- }
-
- /**
- * Tests that inserting a key sequence of matching length causes no change,
- * but inserted a key sequence of one greater does cause a change --
- * specifically truncation.
- *
- * @throws ParseException
- * If the test sequences cannot be parsed.
- */
- public void testTruncation() throws ParseException {
- final int length = 4;
- text.setKeyStrokeLimit(length);
-
- // Test matching length.
- String matchingKeySequenceText = "1 2 3 4"; //$NON-NLS-1$
- KeySequence matchingKeySequence = KeySequence
- .getInstance(matchingKeySequenceText);
- text.setKeySequence(matchingKeySequence);
- assertEquals(
- "Limit of four change four stroke sequence.", matchingKeySequence, text.getKeySequence()); //$NON-NLS-1$
-
- // Test one greater than length.
- String longerKeySequenceText = "1 2 3 4 5"; //$NON-NLS-1$
- KeySequence longerKeySequence = KeySequence
- .getInstance(longerKeySequenceText);
- text.setKeySequence(longerKeySequence);
- assertEquals(
- "Limit of four did not truncate to four.", length, text.getKeySequence().getKeyStrokes().length); //$NON-NLS-1$
- }
-
- /**
- * Tests that a zero-length stroke can be inserted into the KeySequenceText --
- * regardless of whether the stroke limit is some positive integer or
- * infinite.
- */
- public void testZeroStroke() {
- KeySequence zeroStrokeSequence = KeySequence.getInstance();
-
- // Test with a limit of four.
- text.setKeyStrokeLimit(4);
- text.setKeySequence(zeroStrokeSequence);
- assertEquals(
- "Limit of four changed zero stroke sequence.", zeroStrokeSequence, text.getKeySequence()); //$NON-NLS-1$
-
- // Test with an infinite limit.
- text.setKeyStrokeLimit(KeySequenceText.INFINITE);
- text.setKeySequence(zeroStrokeSequence);
- assertEquals(
- "Infinite limit changed zero stroke sequence.", zeroStrokeSequence, text.getKeySequence()); //$NON-NLS-1$
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42035Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42035Test.java
deleted file mode 100755
index d264bc6..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42035Test.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.keys.KeyStroke;
-import org.eclipse.ui.keys.ParseException;
-import org.eclipse.ui.keys.SWTKeySupport;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Test for Bug 42035.
- *
- * @since 3.0
- */
-public class Bug42035Test extends UITestCase {
-
- /**
- * Tests the given key event to see if generates the three key strokes
- * represented by the strings.
- *
- * @param keyEvent
- * The key event to generate key strokes from; must not be
- * <code>null</code>
- * @param firstMatch
- * The text format of the first match; must not be <code>null</code>.
- * @param secondMatch
- * The text format of the second match; must not be <code>null</code>.
- * @param thirdMatch
- * The text format of the third match; must not be <code>null</code>.
- * @throws ParseException
- * If anyone of the text formats provided cannot be parsed.
- */
- private static void testKeyEvent(Event keyEvent, String firstMatch,
- String secondMatch, String thirdMatch) throws ParseException {
- KeyStroke desiredKeyStroke = null;
- KeyStroke actualKeyStroke = null;
-
- // Test the first-level match.
- desiredKeyStroke = KeyStroke.getInstance(firstMatch); //$NON-NLS-1$
- actualKeyStroke = SWTKeySupport
- .convertAcceleratorToKeyStroke(SWTKeySupport
- .convertEventToUnmodifiedAccelerator(keyEvent));
- assertEquals(
- "Unmodified character with all modifiers doesn't match.", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$
-
- // Test the second-level match.
- desiredKeyStroke = KeyStroke.getInstance(secondMatch); //$NON-NLS-1$
- actualKeyStroke = SWTKeySupport
- .convertAcceleratorToKeyStroke(SWTKeySupport
- .convertEventToUnshiftedModifiedAccelerator(keyEvent));
- assertEquals(
- "Modified character with no shift doesn't match.", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$
-
- // Test the third-level match.
- desiredKeyStroke = KeyStroke.getInstance(thirdMatch); //$NON-NLS-1$
- actualKeyStroke = SWTKeySupport
- .convertAcceleratorToKeyStroke(SWTKeySupport
- .convertEventToModifiedAccelerator(keyEvent));
- assertEquals(
- "Modified character with all modifiers doesn't match.", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$
- }
-
- /**
- * Constructs a new instance of this test case.
- *
- * @param testName
- * The name of the test
- */
- public Bug42035Test(String testName) {
- super(testName);
- }
-
- /**
- * Tests that "Ctrl+" generates "Ctrl+", "Ctrl+" and "Ctrl+".
- *
- * @throws ParseException
- * If "CTRL+" cannot be processed.
- */
- public void testCtrl() throws ParseException {
- Event keyEvent = new Event();
- keyEvent.keyCode = 0x40000;
- keyEvent.character = 0x00;
- keyEvent.stateMask = SWT.NONE;
-
- KeyStroke desiredKeyStroke = KeyStroke.getInstance("CTRL+"); //$NON-NLS-1$
- KeyStroke actualKeyStroke = SWTKeySupport
- .convertAcceleratorToKeyStroke(SWTKeySupport
- .convertEventToUnmodifiedAccelerator(keyEvent));
- assertEquals(
- "Unmodified character with all modifiers doesn't match", desiredKeyStroke, actualKeyStroke); //$NON-NLS-1$
- }
-
- /**
- * Tests that "Ctrl+Enter" generates "Ctrl+Enter", "Ctrl+Enter" and
- * "Ctrl+Enter".
- *
- * @throws ParseException
- * If "CTRL+ENTER" cannot be processed.
- */
- public void testCtrlEnter() throws ParseException {
- Event keyEvent = new Event();
- keyEvent.keyCode = 0x0D;
- keyEvent.character = 0x0D;
- keyEvent.stateMask = SWT.CTRL;
-
- testKeyEvent(keyEvent, "CTRL+CR", "CTRL+CR", "CTRL+CR"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-
- /**
- * Tests that "Ctrl+J" generates "Ctrl+M", "Ctrl+M" and "Ctrl+M".
- *
- * @throws ParseException
- * If "CTRL+M" cannot be processed.
- */
- public void testCtrlM() throws ParseException {
- Event keyEvent = new Event();
- keyEvent.keyCode = 0x6D;
- keyEvent.character = 0x0D;
- keyEvent.stateMask = SWT.CTRL;
-
- testKeyEvent(keyEvent, "CTRL+M", "CTRL+M", "CTRL+M"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-
- /**
- * Tests that "Ctrl+Shift+2" generates "Ctrl+Shift+2", "Ctrl+@" and
- * "Ctrl+Shift+@". This simulates a U.S. keyboard layout.
- *
- * @throws ParseException
- * If "CTRL+SHIFT+2", "CTRL+@" or "CTRL+SHIFT+@" cannot be
- * processed.
- */
- public void testCtrlShift2() throws ParseException {
- Event keyEvent = new Event();
- keyEvent.keyCode = '2';
- keyEvent.character = 0x00;
- keyEvent.stateMask = SWT.CTRL | SWT.SHIFT;
-
- testKeyEvent(keyEvent, "CTRL+SHIFT+2", "CTRL+@", "CTRL+SHIFT+@"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-
- /**
- * Tests that "Ctrl+Shift+7" generates "Ctrl+Shift+7", "Ctrl+/" and
- * "Ctrl+Shift+/". This simulates a Swiss-German keyboard layout.
- *
- * @throws ParseException
- * If "CTRL+SHIFT+7", "CTRL+/" or "CTRL+SHIFT+/" cannot be
- * processed.
- */
- public void testCtrlShift7_SwissGerman() throws ParseException {
- Event keyEvent = new Event();
- keyEvent.keyCode = '7';
- keyEvent.character = '/';
- keyEvent.stateMask = SWT.CTRL | SWT.SHIFT;
-
- testKeyEvent(keyEvent, "CTRL+SHIFT+7", "CTRL+/", "CTRL+SHIFT+/"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-
- /**
- * Tests that "Ctrl+Shift+7" generates "Ctrl+Shift+7", "Ctrl+&" and
- * "Ctrl+Shift+&". This simulates a US keyboard layout.
- *
- * @throws ParseException
- * If "CTRL+SHIFT+7", "CTRL+&" or "CTRL+SHIFT+&" cannot be
- * processed.
- */
- public void testCtrlShift7_US() throws ParseException {
- Event keyEvent = new Event();
- keyEvent.keyCode = '7';
- keyEvent.character = '&';
- keyEvent.stateMask = SWT.CTRL | SWT.SHIFT;
-
- testKeyEvent(keyEvent, "CTRL+SHIFT+7", "CTRL+&", "CTRL+SHIFT+&"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42627Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42627Test.java
deleted file mode 100755
index 3e0d2ed..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug42627Test.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests Bug 42627
- *
- * @since 3.0
- */
-public class Bug42627Test extends UITestCase {
-
- // TODO See if this is needed for anything.
- // private class DummyView extends ViewPart {
- // public void createPartControl(Composite composite) {
- // // Do nothing
- // }
- //
- // public void setFocus() {
- // // Do nothing
- // }
- // }
-
- /**
- * A dummy implementation of an <code>Action</code>.
- *
- * @since 3.0
- */
- // private class DummyAction extends Action {
- // // Nothing to implement
- // }
- // private boolean logged;
- /**
- * Constructor for Bug42627Test.
- *
- * @param name
- * The name of the test
- */
- public Bug42627Test(String name) {
- super(name);
- }
-
- protected void doSetUp() throws Exception {
- super.doSetUp();
- // logged = false;
- }
-
- /**
- * Tests that actions with no defined command ID are logged.
- *
- * @throws CoreException
- * If something fails when trying to open a new project.
- */
- public void testLogUndefined() /*throws CoreException*/{
- // TODO No log is being generated. What was Chris' fix?
- // IWorkbenchWindow window = openTestWindow();
- // ResourcesPlugin.getPlugin().getLog().addLogListener(new ILogListener() {
- // public void logging(IStatus status, String string) {
- // logged = true;
- // }
- // });
- // IWorkspace workspace = ResourcesPlugin.getWorkspace();
- // IProject testProject = workspace.getRoot().getProject("Bug42627Project"); //$NON-NLS-1$
- // testProject.create(null);
- // testProject.open(null);
- // AbstractTextEditor editor = (AbstractTextEditor) window.getActivePage().openEditor(testProject.getFile(".project")); //$NON-NLS-1$
- // editor.selectAndReveal(0, 1);
- // EditorSite site = (EditorSite) editor.getSite();
- // site.getActionBars().setGlobalActionHandler("Bogus action name that hopefully will not exist", new DummyAction()); //$NON-NLS-1$
- // window.getShell().setFocus();
- // assertTrue("Nothing has been logged.", logged); //$NON-NLS-1$
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43168Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43168Test.java
deleted file mode 100755
index 3740529..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43168Test.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.jface.bindings.keys.KeySequence;
-import org.eclipse.jface.bindings.keys.KeySequenceText;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests Bug 43168
- *
- * @since 3.0
- */
-public class Bug43168Test extends UITestCase {
-
- /**
- * Constructor for Bug43168Test.
- *
- * @param name
- * The name of the test
- */
- public Bug43168Test(String name) {
- super(name);
- }
-
- /**
- * Tests that a <code>StackOverflowError</code> does not occur when
- * trying to set the key sequence in a key sequence entry widget.
- *
- * @throws ParseException
- * If "CTRL+" is not recognized as a key sequence.
- */
- public void testStackOverflow() throws ParseException {
- Display display = Display.getCurrent();
- Shell shell = new Shell(display);
- shell.setLayout(new RowLayout());
- Text text = new Text(shell, SWT.BORDER);
- KeySequenceText keySequenceText = new KeySequenceText(text);
-
- shell.pack();
- shell.open();
- keySequenceText.setKeySequence(KeySequence.getInstance("CTRL+")); //$NON-NLS-1$
- shell.close();
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43321Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43321Test.java
deleted file mode 100755
index 9299ea6..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43321Test.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.common.CommandException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.internal.Workbench;
-import org.eclipse.ui.internal.keys.BindingService;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-
-/**
- * Tests Bug 43321
- *
- * @since 3.0
- */
-public class Bug43321Test extends UITestCase {
-
- /**
- * Constructor for Bug43321Test.
- *
- * @param name
- * The name of the test
- */
- public Bug43321Test(String name) {
- super(name);
- }
-
- /**
- * Tests that non-check box items on the menu are not checked when activated
- * from the keyboard.
- *
- * @throws CommandException
- * If execution of the handler fails.
- * @throws CoreException
- * If the test project cannot be created and opened.
- * @throws ParseException
- * If "CTRL+C" isn't a valid key stroke.
- */
- public void testNoCheckOnNonCheckbox() throws CommandException,
- CoreException, ParseException {
- IWorkbenchWindow window = openTestWindow();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IProject testProject = workspace.getRoot().getProject("TestProject"); //$NON-NLS-1$
- testProject.create(null);
- testProject.open(null);
- IFile textFile = testProject.getFile("A.txt"); //$NON-NLS-1$
- String contents = "A blurb"; //$NON-NLS-1$
- ByteArrayInputStream inputStream = new ByteArrayInputStream(contents
- .getBytes());
- textFile.create(inputStream, true, null);
- AbstractTextEditor editor = (AbstractTextEditor) IDE.openEditor(window
- .getActivePage(), textFile, true);
- editor.selectAndReveal(0, 1);
-
- // Press "Ctrl+C" to perform a copy.
- List keyStrokes = new ArrayList();
- keyStrokes.add(KeyStroke.getInstance("CTRL+C")); //$NON-NLS-1$
- Event event = new Event();
- Workbench workbench = ((Workbench) window.getWorkbench());
- BindingService support = (BindingService) workbench
- .getAdapter(IBindingService.class);
- support.getKeyboard().press(keyStrokes, event);
-
- // Get the menu item we've just selected.
- IAction action = editor.getEditorSite().getActionBars()
- .getGlobalActionHandler(ActionFactory.COPY.getId());
- assertTrue("Non-checkbox menu item is checked.", !action.isChecked()); //$NON-NLS-1$
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43538Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43538Test.java
deleted file mode 100755
index 56ed754..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43538Test.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.tests.harness.util.AutomationUtil;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Test for Bug 43538.
- *
- * @since 3.0
- */
-public class Bug43538Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- *
- * @param testName
- * The name of the test
- */
- public Bug43538Test(String testName) {
- super(testName);
- }
-
- /**
- * Tests that if "Ctrl+Space" is pressed only one key down event with the
- * "CTRL" mask is received.
- */
- public void testCtrlSpace() {
- // Set up a working environment.
- Display display = Display.getCurrent();
- Listener listener = new Listener() {
- int count = 0;
-
- public void handleEvent(Event event) {
- if (event.stateMask == SWT.CTRL) {
- assertEquals(
- "Multiple key down events for 'Ctrl+Space'", 0, count++); //$NON-NLS-1$
- }
- }
- };
- display.addFilter(SWT.KeyDown, listener);
-
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.CONTROL);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, Action.findKeyCode("SPACE")); //$NON-NLS-1$
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, Action.findKeyCode("SPACE")); //$NON-NLS-1$
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.CONTROL);
-
- while (display.readAndDispatch())
- ;
-
- // Clean up the working environment.
- display.removeFilter(SWT.KeyDown, listener);
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43597Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43597Test.java
deleted file mode 100755
index e24a211..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43597Test.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests Bug 43597
- *
- * @since 3.0
- */
-public class Bug43597Test extends UITestCase {
-
- private Font textFont;
-
- /**
- * Constructor for Bug43597Test.
- *
- * @param name
- * The name of the test
- */
- public Bug43597Test(String name) {
- super(name);
- }
-
- /**
- * Tests that setting the text on a text widget to an empty string does not
- * reset the font. This was a problem only on carbon.
- */
- public void testFontReset() {
- String metaCharacter = "\u2325X"; //$NON-NLS-1$
-
- // Set up a working environment.
- Display display = Display.getCurrent();
- Shell shell = new Shell(display);
- GridLayout gridLayout = new GridLayout();
- shell.setLayout(gridLayout);
- Text text = new Text(shell, SWT.LEFT);
- textFont = new Font(text.getDisplay(),
- "Lucida Grande", 13, SWT.NORMAL);
- text.setFont(textFont); //$NON-NLS-1$
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- shell.pack();
- shell.open();
-
- // Set the text once, and get the font.
- text.setText(metaCharacter); //$NON-NLS-1$
- Font fontBefore = text.getFont();
-
- // Set the font again, and get the font afterward.
- text.setText(""); //$NON-NLS-1$
- text.setText(metaCharacter);
- Font fontAfter = text.getFont();
-
- // Test.
- assertEquals("Clearing text resets font.", fontBefore, fontAfter); //$NON-NLS-1$
-
- // Clean up after myself.
- shell.close();
- shell.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.tests.harness.util.UITestCase#doTearDown()
- */
- protected void doTearDown() throws Exception {
- if (textFont != null) {
- textFont.dispose();
- }
- super.doTearDown();
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43610Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43610Test.java
deleted file mode 100755
index c1b11c1..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43610Test.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.tests.harness.util.AutomationUtil;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Test for Bug 43610.
- *
- * @since 3.0
- */
-public class Bug43610Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- *
- * @param testName
- * The name of the test
- */
- public Bug43610Test(String testName) {
- super(testName);
- }
-
- /**
- * Tests that if "Shift+Alt+" is pressed, then the key code should
- * represent the "Alt+" key press.
- */
- public void testShiftAlt() {
- // Set up a working environment.
- Display display = Display.getCurrent();
- Listener listener = new Listener() {
- public void handleEvent(Event event) {
- if (event.stateMask == SWT.SHIFT) {
- assertEquals(
- "Incorrect key code for 'Shift+Alt+'", SWT.ALT, event.keyCode); //$NON-NLS-1$
- }
- }
- };
- display.addFilter(SWT.KeyDown, listener);
-
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.SHIFT);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.ALT);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.ALT);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.SHIFT);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.ESC);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.ESC);
-
- while (display.readAndDispatch())
- ;
-
- // Clean up the working environment.
- display.removeFilter(SWT.KeyDown, listener);
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43800Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43800Test.java
deleted file mode 100755
index ed63228..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug43800Test.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.keys.SWTKeySupport;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Test for Bug 43800.
- *
- * @since 3.0
- */
-public class Bug43800Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- *
- * @param testName
- * The name of the test
- */
- public Bug43800Test(String testName) {
- super(testName);
- }
-
- /**
- * Tests that key pressed with key codes greater than 16 bits are correctly
- * converted into accelerator values.
- */
- public void testTruncatingCast() {
- /*
- * Make an event representing a key stroke with a key code greater than
- * 16 bits.
- */
- Event event = new Event();
- event.keyCode = SWT.ARROW_LEFT;
- event.character = 0x00;
- event.stateMask = 0x00;
-
- // Convert the event, and test the resulting accelerator value.
- int accelerator = SWTKeySupport
- .convertEventToUnmodifiedAccelerator(event);
- assertEquals("Arrow_Left key truncated.", SWT.ARROW_LEFT, accelerator); //$NON-NLS-1$
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug44460Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug44460Test.java
deleted file mode 100755
index 96174c4..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug44460Test.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.io.ByteArrayInputStream;
-import java.util.List;
-
-import org.eclipse.core.commands.common.CommandException;
-import org.eclipse.core.internal.events.BuildCommand;
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IPerspectiveRegistry;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.internal.Workbench;
-import org.eclipse.ui.internal.WorkbenchPage;
-import org.eclipse.ui.internal.keys.BindingService;
-import org.eclipse.ui.internal.keys.WorkbenchKeyboard;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Test for Bug 44460.
- *
- * @since 3.0
- */
-public class Bug44460Test extends UITestCase {
-
- /**
- * Constructs a new instance of this test case.
- *
- * @param testName
- * The name of the test
- */
- public Bug44460Test(String testName) {
- super(testName);
- }
-
- /**
- * Test that pressing "Ctrl+Shift+T" in the Team Synchronizing perspective
- * does not match anything.
- *
- * @throws CommandException
- * If execution of the handler fails.
- * @throws CoreException
- * If the project cannot be created or opened.
- */
- public void testCtrlShiftT() throws CommandException, CoreException {
- // Open a new test window.
- IWorkbenchWindow window = openTestWindow();
-
- // Open a new Java project, with a new class.
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IProject testProject = workspace.getRoot().getProject(
- "Bug 44460 Project"); //$NON-NLS-1$
- testProject.create(null);
- testProject.open(null);
- IProjectDescription projectDescription = testProject.getDescription();
- String[] natureIds = { "org.eclipse.jdt.core.javanature" }; //$NON-NLS-1$
- projectDescription.setNatureIds(natureIds);
- ICommand buildCommand = new BuildCommand();
- buildCommand.setBuilderName("org.eclipse.jdt.core.javabuilder"); //$NON-NLS-1$
- projectDescription.setBuildSpec(new ICommand[] { buildCommand });
- testProject.setDescription(projectDescription, null);
- IFile javaFile = testProject.getFile("A.java"); //$NON-NLS-1$
- String classContents = "public class Main { public static main(String[] args) { ; } }"; //$NON-NLS-1$
- ByteArrayInputStream inputStream = new ByteArrayInputStream(
- classContents.getBytes());
- javaFile.create(inputStream, true, null);
- IDE.openEditor(window.getActivePage(), javaFile, true);
-
- // Switch to the team synchronizing perspective.
- IPerspectiveRegistry registry = PlatformUI.getWorkbench()
- .getPerspectiveRegistry();
- IPerspectiveDescriptor perspectiveDescriptor = registry
- .findPerspectiveWithId("org.eclipse.team.ui.TeamSynchronizingPerspective"); //$NON-NLS-1$
- WorkbenchPage page = (WorkbenchPage) window.getActivePage();
- page.setPerspective(perspectiveDescriptor);
-
- // Press "Ctrl+Shift+T".
- Event ctrlShiftT = new Event();
- ctrlShiftT.stateMask = SWT.SHIFT | SWT.CTRL;
- ctrlShiftT.character = 'T';
- ctrlShiftT.keyCode = 't';
- List keyStrokes = WorkbenchKeyboard
- .generatePossibleKeyStrokes(ctrlShiftT);
- Workbench workbench = (Workbench) window.getWorkbench();
- BindingService support = (BindingService) workbench
- .getAdapter(IBindingService.class);
- support.getKeyboard().press(keyStrokes, null);
-
- // Test that only two child shells are open (default).
- Shell windowShell = window.getShell();
- Shell[] childShells = windowShell.getShells();
- assertTrue(
- "Type hierarchy dialog opened inappropriately on 'Ctrl+Shift+T'", (childShells.length == 2)); //$NON-NLS-1$
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug53489Test.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug53489Test.java
deleted file mode 100755
index 46a20e5..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/Bug53489Test.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.commands.CommandException;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.tests.harness.util.AutomationUtil;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * Tests that pressing delete in a styled text widget does not cause a double
- * delete situation.
- *
- * @since 3.0
- */
-public class Bug53489Test extends UITestCase {
-
- /**
- * Constructor for Bug53489Test.
- *
- * @param name
- * The name of the test
- */
- public Bug53489Test(String name) {
- super(name);
- }
-
- /**
- * Tests that pressing delete in a styled text widget (in a running
- * Eclipse) does not cause a double delete.
- *
- * @throws AWTException
- * If the creation of robot
- * @throws CommandException
- * If execution of the handler fails.
- * @throws CoreException
- * If the test project cannot be created and opened.
- * @throws IOException
- * If the file cannot be read.
- */
- public void testDoubleDelete() throws CommandException,
- CoreException, IOException {
- IWorkbenchWindow window = openTestWindow();
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IProject testProject = workspace.getRoot().getProject(
- "DoubleDeleteestProject"); //$NON-NLS-1$
- testProject.create(null);
- testProject.open(null);
- IFile textFile = testProject.getFile("A.txt"); //$NON-NLS-1$
- String originalContents = "A blurb"; //$NON-NLS-1$
- ByteArrayInputStream inputStream = new ByteArrayInputStream(
- originalContents.getBytes());
- textFile.create(inputStream, true, null);
- IDE.openEditor(window.getActivePage(), textFile,
- true);
-
- // Allow the editor to finish opening.
- Display display = Display.getCurrent();
- while (display.readAndDispatch())
- ;
-
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.DEL);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.DEL);
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyDown, SWT.CTRL);
- AutomationUtil.performCharacterEvent(display, SWT.KeyDown,'S');
- AutomationUtil.performCharacterEvent(display, SWT.KeyUp,'S');
- AutomationUtil.performKeyCodeEvent(display, SWT.KeyUp, SWT.CTRL);
-
- // Spin the event loop.
- while (display.readAndDispatch())
- ;
-
- // Test the text is only one character different.
- LineNumberReader reader = new LineNumberReader(new InputStreamReader(
- textFile.getContents()));
- String currentContents = reader.readLine();
- assertTrue("'DEL' deleted more than one key.", (originalContents //$NON-NLS-1$
- .length() == (currentContents.length() + 1)));
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysCsvTest.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysCsvTest.java
deleted file mode 100755
index fd993ec..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysCsvTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.ui.internal.util.Util;
-
-import junit.framework.TestCase;
-
-/**
- * @since 3.3
- *
- */
-public class KeysCsvTest extends TestCase {
-
- public void testReplace() throws Exception {
- final String src = "Test the \"replaceAll\"";
- final String dest = "Test the \"\"replaceAll\"\"";
- String val = Util.replaceAll(src, "\"", "\"\"");
- assertEquals(dest, val);
- }
-
- public void testReplaceFirst() throws Exception {
- final String src = "\"Hello world!";
- final String dest = "\"\"Hello world!";
- String val = Util.replaceAll(src, "\"", "\"\"");
- assertEquals(dest, val);
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysPreferenceModelTest.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysPreferenceModelTest.java
deleted file mode 100755
index 7bafb73..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysPreferenceModelTest.java
+++ /dev/null
@@ -1,943 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.jface.bindings.Binding;
-import org.eclipse.jface.bindings.keys.KeyBinding;
-import org.eclipse.jface.bindings.keys.KeySequence;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.internal.keys.model.BindingElement;
-import org.eclipse.ui.internal.keys.model.BindingModel;
-import org.eclipse.ui.internal.keys.model.CommonModel;
-import org.eclipse.ui.internal.keys.model.ConflictModel;
-import org.eclipse.ui.internal.keys.model.ContextElement;
-import org.eclipse.ui.internal.keys.model.ContextModel;
-import org.eclipse.ui.internal.keys.model.KeyController;
-import org.eclipse.ui.internal.keys.model.ModelElement;
-import org.eclipse.ui.internal.keys.model.SchemeElement;
-import org.eclipse.ui.internal.keys.model.SchemeModel;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.tests.harness.util.UITestCase;
-
-/**
- * @since 3.4
- *
- */
-public class KeysPreferenceModelTest extends UITestCase {
-
- private static final String ID_QUICK_SWITCH = "org.eclipse.ui.window.openEditorDropDown";
- private static final String SCHEME_EMACS_ID = "org.eclipse.ui.emacsAcceleratorConfiguration";
- private static final String ID_QUICK_ACCESS = "org.eclipse.ui.window.quickAccess";
- private static final String ID_ACTIVATE_EDITOR = "org.eclipse.ui.window.activateEditor";
- private static final String ID_ABOUT = "org.eclipse.ui.help.aboutAction";
- private static final String ID_CMD_CONFLICT1 = "org.eclipse.ui.tests.keyModel.conflict1";
- private static final String ID_CMD_CONFLICT2 = "org.eclipse.ui.tests.keyModel.conflict2";
- private static final String ID_CMD_CONFLICT3 = "org.eclipse.ui.tests.keyModel.conflict3";
- private static final String ID_CMD_CONFLICT4 = "org.eclipse.ui.tests.keyModel.conflict4";
- private static final String ID_CMD_EMACS1 = "org.eclipse.ui.tests.keyModel.emacs1";
-
- /**
- * @param testName
- */
- public KeysPreferenceModelTest(String testName) {
- super(testName);
- }
-
- public void testDefaults() throws Exception {
- KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- ContextModel cm = controller.getContextModel();
- boolean foundWindow = false;
- boolean foundDialog = false;
- Iterator i = cm.getContexts().iterator();
- while (i.hasNext()) {
- ContextElement elem = (ContextElement) i.next();
- if (elem.getId().equals(IContextService.CONTEXT_ID_WINDOW)) {
- foundWindow = true;
- } else if (elem.getId().equals(IContextService.CONTEXT_ID_DIALOG)) {
- foundDialog = true;
- }
- }
- assertTrue("No window context", foundWindow);
- assertTrue("No dialog context", foundDialog);
- assertNull(cm.getSelectedElement());
- assertNotNull(cm.getContextIdToElement().get(
- IContextService.CONTEXT_ID_DIALOG_AND_WINDOW));
-
- SchemeModel sm = controller.getSchemeModel();
- boolean foundDefault = false;
- i = sm.getSchemes().iterator();
- while (i.hasNext()) {
- SchemeElement e = (SchemeElement) i.next();
- if (e.getId().equals(
- IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID)) {
- foundDefault = true;
- }
- }
- assertTrue("No default scheme", foundDefault);
- assertEquals(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID, sm
- .getSelectedElement().getId());
-
- ConflictModel cf = controller.getConflictModel();
- assertNull("There should not be any conflicts", cf.getConflicts());
- assertNull(cf.getSelectedElement());
-
- BindingModel bm = controller.getBindingModel();
- BindingElement quickAccess = getBindingElement(bm, ID_QUICK_ACCESS);
- assertNotNull(quickAccess);
- assertNull(bm.getSelectedElement());
- }
-
- public void testContexts() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- ContextModel cm = controller.getContextModel();
- ContextElement dialog = (ContextElement) cm.getContextIdToElement()
- .get(IContextService.CONTEXT_ID_DIALOG);
- assertNull(cm.getSelectedElement());
- assertNotNull(dialog);
-
- final ArrayList events = new ArrayList();
- // test setup vars
- controller.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- events.add(event);
- }
- });
- cm.setSelectedElement(dialog);
-
- assertTrue(cm.getSelectedElement() == dialog);
-
- assertEquals(1, events.size());
-
- ContextElement window = (ContextElement) cm.getContextIdToElement()
- .get(IContextService.CONTEXT_ID_WINDOW);
- assertNotNull(window);
-
- cm.setSelectedElement(window);
- assertEquals(2, events.size());
-
- cm.setSelectedElement(null);
- assertEquals(3, events.size());
-
- PropertyChangeEvent[] expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(controller.getContextModel(),
- CommonModel.PROP_SELECTED_ELEMENT, null, dialog),
- new PropertyChangeEvent(controller.getContextModel(),
- CommonModel.PROP_SELECTED_ELEMENT, dialog, window),
- new PropertyChangeEvent(controller.getContextModel(),
- CommonModel.PROP_SELECTED_ELEMENT, window, null) };
- assertChanges(expected, events);
- }
-
- public void testBindings() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- ContextModel cm = controller.getContextModel();
- BindingModel bm = controller.getBindingModel();
- BindingElement activateEditor = getBindingElement(bm,
- ID_ACTIVATE_EDITOR);
- assertNotNull(activateEditor);
- assertNotNull(activateEditor.getContext());
- assertNull(bm.getSelectedElement());
-
- // test setup vars
- final ArrayList events = new ArrayList();
- controller.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- events.add(event);
- }
- });
-
- bm.setSelectedElement(activateEditor);
-
- assertTrue(bm.getSelectedElement() == activateEditor);
- assertNotNull(cm.getSelectedElement());
- assertTrue(cm.getSelectedElement().getId().equals(
- activateEditor.getContext().getId()));
-
- PropertyChangeEvent[] expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(controller.getConflictModel(),
- CommonModel.PROP_SELECTED_ELEMENT, null, activateEditor),
- new PropertyChangeEvent(controller.getContextModel(),
- CommonModel.PROP_SELECTED_ELEMENT, null, activateEditor
- .getContext()),
- new PropertyChangeEvent(controller.getBindingModel(),
- CommonModel.PROP_SELECTED_ELEMENT, null, activateEditor), };
- assertChanges(expected, events);
-
- events.clear();
- bm.setSelectedElement(null);
- assertNull(bm.getSelectedElement());
- assertTrue(cm.getSelectedElement().getId().equals(
- activateEditor.getContext().getId()));
-
- expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(controller.getConflictModel(),
- CommonModel.PROP_SELECTED_ELEMENT, activateEditor, null),
- new PropertyChangeEvent(controller.getBindingModel(),
- CommonModel.PROP_SELECTED_ELEMENT, activateEditor, null) };
- assertChanges(expected, events);
- }
-
- public void testBasicConflicts() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ConflictModel cf = controller.getConflictModel();
- final BindingModel bm = controller.getBindingModel();
- final BindingElement conflict1 = getBindingElement(bm, ID_CMD_CONFLICT1);
- assertNotNull(conflict1);
- assertEquals(Boolean.TRUE, conflict1.getConflict());
- final BindingElement activateEditor = getBindingElement(bm,
- ID_ACTIVATE_EDITOR);
- assertNotNull(activateEditor);
- assertEquals(Boolean.FALSE, activateEditor.getConflict());
-
- // test setup vars
- final ArrayList events = new ArrayList();
- controller.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- events.add(event);
- }
- });
-
- bm.setSelectedElement(conflict1);
- assertEquals(conflict1, bm.getSelectedElement());
- assertEquals(conflict1, cf.getSelectedElement());
-
- final Collection conflicts = cf.getConflicts();
- assertEquals(3, conflicts.size());
-
- PropertyChangeEvent[] expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(controller.getConflictModel(),
- ConflictModel.PROP_CONFLICTS, null, conflicts),
- new PropertyChangeEvent(controller.getConflictModel(),
- CommonModel.PROP_SELECTED_ELEMENT, null, conflict1),
- new PropertyChangeEvent(controller.getContextModel(),
- CommonModel.PROP_SELECTED_ELEMENT, null, conflict1
- .getContext()),
- new PropertyChangeEvent(controller.getBindingModel(),
- CommonModel.PROP_SELECTED_ELEMENT, null, conflict1) };
-
- assertChanges(expected, events);
-
- events.clear();
- bm.setSelectedElement(activateEditor);
- assertEquals(activateEditor, bm.getSelectedElement());
-
- expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(controller.getConflictModel(),
- ConflictModel.PROP_CONFLICTS, conflicts, null),
- new PropertyChangeEvent(controller.getConflictModel(),
- CommonModel.PROP_SELECTED_ELEMENT, conflict1,
- activateEditor),
- new PropertyChangeEvent(controller.getContextModel(),
- CommonModel.PROP_SELECTED_ELEMENT, conflict1
- .getContext(), activateEditor.getContext()),
- new PropertyChangeEvent(controller.getBindingModel(),
- CommonModel.PROP_SELECTED_ELEMENT, conflict1,
- activateEditor) };
-
- assertChanges(expected, events);
- }
-
- public void testConflictSelection() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ConflictModel cf = controller.getConflictModel();
- final BindingModel bm = controller.getBindingModel();
- final BindingElement conflict1 = getBindingElement(bm, ID_CMD_CONFLICT1);
- final BindingElement conflict3 = getBindingElement(bm, ID_CMD_CONFLICT3);
-
- // test setup vars
- final ArrayList events = new ArrayList();
- controller.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- events.add(event);
- }
- });
-
- bm.setSelectedElement(conflict1);
- assertEquals(conflict1, bm.getSelectedElement());
- assertEquals(conflict1, cf.getSelectedElement());
-
- assertEquals(4, events.size());
-
- events.clear();
-
- cf.setSelectedElement(conflict3);
- assertEquals(conflict3, bm.getSelectedElement());
- assertEquals(conflict3, cf.getSelectedElement());
-
- PropertyChangeEvent[] expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(controller.getBindingModel(),
- CommonModel.PROP_SELECTED_ELEMENT, conflict1, conflict3),
- new PropertyChangeEvent(controller.getConflictModel(),
- CommonModel.PROP_SELECTED_ELEMENT, conflict1, conflict3) };
- assertChanges(expected, events);
- }
-
- public void failsOnCocoatestCreateConflict() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ConflictModel cf = controller.getConflictModel();
- final BindingModel bm = controller.getBindingModel();
- BindingElement about = getBindingElement(bm, ID_ABOUT);
- assertNotNull(about);
- assertNotNull(about.getTrigger());
-
- BindingElement active = getBindingElement(bm, ID_ACTIVATE_EDITOR);
- assertNotNull(active);
- assertNotNull(active.getTrigger());
- assertEquals(Boolean.FALSE, active.getConflict());
-
- bm.setSelectedElement(about);
-
- about.setTrigger(KeySequence.getInstance("F12"));
- assertEquals(Boolean.TRUE, about.getConflict());
- assertEquals(Boolean.TRUE, active.getConflict());
- assertEquals(about, cf.getSelectedElement());
-
- about.setTrigger(KeySequence.getInstance("F12 A"));
- assertEquals(Boolean.FALSE, about.getConflict());
- assertEquals(Boolean.FALSE, active.getConflict());
- assertEquals(about, cf.getSelectedElement());
- assertNull(cf.getConflicts());
-
- about.setTrigger(null);
- assertEquals(Boolean.FALSE, about.getConflict());
- assertEquals(Boolean.FALSE, active.getConflict());
- assertEquals(about, cf.getSelectedElement());
- assertNull(cf.getConflicts());
- }
-
- public void failsOnMacCocoatestConflictRemove() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ConflictModel cf = controller.getConflictModel();
- final BindingModel bm = controller.getBindingModel();
- BindingElement about = getBindingElement(bm, ID_ABOUT);
- assertNotNull(about);
- assertNotNull(about.getTrigger());
-
- BindingElement active = getBindingElement(bm, ID_ACTIVATE_EDITOR);
- assertNotNull(active);
- assertNotNull(active.getTrigger());
- assertEquals(Boolean.FALSE, active.getConflict());
-
- bm.setSelectedElement(about);
-
- about.setTrigger(KeySequence.getInstance("F12"));
- assertEquals(Boolean.TRUE, about.getConflict());
- assertEquals(Boolean.TRUE, active.getConflict());
- assertEquals(about, cf.getSelectedElement());
-
- bm.remove();
- assertEquals(Boolean.FALSE, about.getConflict());
- assertEquals(Boolean.FALSE, active.getConflict());
- assertEquals(about, cf.getSelectedElement());
- assertNull(cf.getConflicts());
- }
-
- public void failsOnMacCocoatestConflictRestore() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ConflictModel cf = controller.getConflictModel();
- final BindingModel bm = controller.getBindingModel();
- BindingElement about = getBindingElement(bm, ID_ABOUT);
- assertNotNull(about);
- assertNotNull(about.getTrigger());
-
- BindingElement active = getBindingElement(bm, ID_ACTIVATE_EDITOR);
- assertNotNull(active);
- assertNotNull(active.getTrigger());
- assertEquals(Boolean.FALSE, active.getConflict());
-
- bm.setSelectedElement(about);
-
- about.setTrigger(KeySequence.getInstance("F12"));
- assertEquals(Boolean.TRUE, about.getConflict());
- assertEquals(Boolean.TRUE, active.getConflict());
- assertEquals(about, cf.getSelectedElement());
-
- bm.restoreBinding(controller.getContextModel());
-
- active = getBindingElement(bm, ID_ACTIVATE_EDITOR);
- about = getBindingElement(bm, ID_ABOUT);
-
- assertEquals(Boolean.FALSE, about.getConflict());
- assertEquals(Boolean.FALSE, active.getConflict());
- assertEquals(bm.getSelectedElement(), cf.getSelectedElement());
- assertNull(cf.getConflicts());
- }
-
- public void testUpdateContext() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ContextModel cm = controller.getContextModel();
- final ContextElement dialog = (ContextElement) cm
- .getContextIdToElement().get(IContextService.CONTEXT_ID_DIALOG);
- final ContextElement window = (ContextElement) cm
- .getContextIdToElement().get(IContextService.CONTEXT_ID_WINDOW);
-
- final BindingModel bm = controller.getBindingModel();
- final BindingElement conflict2 = getBindingElement(bm, ID_CMD_CONFLICT2);
- final Binding c2model = (Binding) conflict2.getModelObject();
- assertEquals(dialog, conflict2.getContext());
-
- bm.setSelectedElement(conflict2);
- assertEquals(dialog, cm.getSelectedElement());
-
- // test setup vars
- final ArrayList events = new ArrayList();
- controller.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- events.add(event);
- }
- });
-
- cm.setSelectedElement(window);
- assertEquals(window, ((BindingElement) bm.getSelectedElement())
- .getContext());
- assertNotSame(c2model, conflict2.getModelObject());
-
- PropertyChangeEvent[] expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(conflict2,
- BindingElement.PROP_CONFLICT, Boolean.TRUE,
- Boolean.FALSE),
- new PropertyChangeEvent(conflict2, BindingElement.PROP_CONTEXT,
- dialog, window),
- new PropertyChangeEvent(conflict2,
- BindingElement.PROP_USER_DELTA, new Integer(
- Binding.SYSTEM), new Integer(Binding.USER)),
- new PropertyChangeEvent(conflict2,
- ModelElement.PROP_MODEL_OBJECT, c2model, conflict2
- .getModelObject()),
- new PropertyChangeEvent(cm, CommonModel.PROP_SELECTED_ELEMENT,
- dialog, window), };
- assertChanges(expected, events);
- }
-
- public void failsOnWinAndLinuxWith16VMtestUpdateKeySequence() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ContextModel cm = controller.getContextModel();
- final ContextElement dialog = (ContextElement) cm
- .getContextIdToElement().get(IContextService.CONTEXT_ID_DIALOG);
-
- final BindingModel bm = controller.getBindingModel();
- final BindingElement conflict1 = getBindingElement(bm, ID_CMD_CONFLICT1);
- final BindingElement conflict2 = getBindingElement(bm, ID_CMD_CONFLICT2);
- final BindingElement conflict3 = getBindingElement(bm, ID_CMD_CONFLICT3);
- final Binding c2model = (Binding) conflict2.getModelObject();
- final Binding c3model = (Binding) conflict3.getModelObject();
- final ParameterizedCommand c3parameterized = c3model
- .getParameterizedCommand();
- assertEquals(dialog, conflict2.getContext());
- assertTrue(c2model instanceof KeyBinding);
- bm.setSelectedElement(conflict2);
- assertEquals(dialog, cm.getSelectedElement());
-
- // test setup vars
- final ArrayList events = new ArrayList();
- controller.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- events.add(event);
- }
- });
-
- KeySequence oldKeySequence = (KeySequence) conflict2.getTrigger();
- KeySequence ctrl5 = KeySequence.getInstance("CTRL+5 N");
- Object bindingConflict1 = conflict1.getModelObject();
- conflict2.setTrigger(ctrl5);
- ConflictModel conflictModel = controller.getConflictModel();
- ArrayList oldValue = new ArrayList();
- oldValue.add(conflict3);
-
- assertEquals(dialog, ((BindingElement) bm.getSelectedElement())
- .getContext());
- assertTrue(conflict2.getModelObject() instanceof KeyBinding);
- PropertyChangeEvent[] expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(conflict2,
- BindingElement.PROP_CONFLICT, Boolean.TRUE,
- Boolean.FALSE),
- new PropertyChangeEvent(conflict2,
- BindingElement.PROP_USER_DELTA, new Integer(
- Binding.SYSTEM), new Integer(Binding.USER)),
- new PropertyChangeEvent(controller.getConflictModel(),
- ConflictModel.PROP_CONFLICTS_REMOVE, null, conflict2),
- new PropertyChangeEvent(conflict2,
- ModelElement.PROP_MODEL_OBJECT, c2model, conflict2
- .getModelObject()),
- new PropertyChangeEvent(conflict1,
- BindingElement.PROP_CONFLICT, Boolean.TRUE,
- Boolean.FALSE),
- new PropertyChangeEvent(
- conflict1,
- BindingElement.PROP_CONTEXT,
- ((BindingElement) bm.getSelectedElement()).getContext(),
- null),
- new PropertyChangeEvent(conflictModel,
- ConflictModel.PROP_CONFLICTS_REMOVE, null, conflict1),
- new PropertyChangeEvent(conflict3,
- BindingElement.PROP_CONFLICT, Boolean.TRUE,
- Boolean.FALSE),
- new PropertyChangeEvent(conflictModel,
- ConflictModel.PROP_CONFLICTS, oldValue, null),
- new PropertyChangeEvent(conflict1,
- ModelElement.PROP_MODEL_OBJECT, bindingConflict1,
- conflict1.getModelObject()),
- new PropertyChangeEvent(conflict1, BindingElement.PROP_TRIGGER,
- oldKeySequence, null),
- new PropertyChangeEvent(conflict3, BindingElement.PROP_CONTEXT,
- dialog, null),
- new PropertyChangeEvent(conflict3,
- ModelElement.PROP_MODEL_OBJECT, c3model,
- c3parameterized),
- new PropertyChangeEvent(conflict3,
- BindingElement.PROP_TRIGGER, oldKeySequence, null),
- new PropertyChangeEvent(bm,
- BindingModel.PROP_CONFLICT_ELEMENT_MAP, null, conflict3),
- new PropertyChangeEvent(conflict2, BindingElement.PROP_TRIGGER,
- oldKeySequence, ctrl5), };
- assertChanges(expected, events);
- }
-
- public void testCreateKeyBinding() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ContextModel cm = controller.getContextModel();
- final ContextElement window = (ContextElement) cm
- .getContextIdToElement().get(IContextService.CONTEXT_ID_WINDOW);
-
- final BindingModel bm = controller.getBindingModel();
- final BindingElement conflict4 = getBindingElement(bm, ID_CMD_CONFLICT4);
- assertNull(conflict4.getContext());
- Object c4model = conflict4.getModelObject();
- assertTrue(c4model instanceof ParameterizedCommand);
-
- bm.setSelectedElement(conflict4);
- assertNull(cm.getSelectedElement());
-
- // test setup vars
- final ArrayList events = new ArrayList();
- controller.addPropertyChangeListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- events.add(event);
- }
- });
-
- KeySequence ctrl5 = KeySequence.getInstance("CTRL+5 N");
- conflict4.setTrigger(ctrl5);
- assertEquals(window, ((BindingElement) bm.getSelectedElement())
- .getContext());
- assertTrue(conflict4.getModelObject() instanceof KeyBinding);
- assertEquals(cm.getSelectedElement(), conflict4.getContext());
-
- PropertyChangeEvent[] expected = new PropertyChangeEvent[] {
- new PropertyChangeEvent(conflict4, BindingElement.PROP_CONTEXT,
- null, window),
- new PropertyChangeEvent(conflict4,
- BindingElement.PROP_USER_DELTA, new Integer(
- Binding.SYSTEM), new Integer(Binding.USER)),
- new PropertyChangeEvent(cm, CommonModel.PROP_SELECTED_ELEMENT,
- null, conflict4.getContext()),
- new PropertyChangeEvent(conflict4,
- ModelElement.PROP_MODEL_OBJECT, c4model, conflict4
- .getModelObject()),
- new PropertyChangeEvent(conflict4, BindingElement.PROP_TRIGGER,
- null, ctrl5), };
- assertChanges(expected, events);
- }
-
- public void testChangeSchemes() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- SchemeModel sm = controller.getSchemeModel();
- SchemeElement emacsScheme = null;
- Iterator i = sm.getSchemes().iterator();
- while (i.hasNext()) {
- SchemeElement e = (SchemeElement) i.next();
- if (e.getId().equals(SCHEME_EMACS_ID)) {
- emacsScheme = e;
- }
- }
- assertNotNull(emacsScheme);
-
- BindingModel bm = controller.getBindingModel();
- BindingElement quickSwitch = null;
- int quickCount = 0;
- i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement e = (BindingElement) i.next();
- if (e.getId().equals(ID_QUICK_SWITCH)) {
- quickSwitch = e;
- quickCount++;
- }
- }
- assertNotNull(quickSwitch);
- assertEquals(1, quickCount);
-
- sm.setSelectedElement(emacsScheme);
-
- i = bm.getBindings().iterator();
- ArrayList quick2 = new ArrayList();
- boolean foundOriginal = false;
- while (i.hasNext()) {
- BindingElement e = (BindingElement) i.next();
- if (e.getId().equals(ID_QUICK_SWITCH)) {
- quick2.add(e);
- if (e == quickSwitch) {
- foundOriginal = true;
- }
- }
- }
- assertEquals(2, quick2.size());
- assertTrue(foundOriginal);
- }
-
- public void testChangeSchemesTwice() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- SchemeModel sm = controller.getSchemeModel();
- SchemeElement emacsScheme = null;
- SchemeElement defaultScheme = null;
- Iterator i = sm.getSchemes().iterator();
- while (i.hasNext()) {
- SchemeElement e = (SchemeElement) i.next();
- if (e.getId().equals(SCHEME_EMACS_ID)) {
- emacsScheme = e;
- } else if (e.getId().equals(
- IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID)) {
- defaultScheme = e;
- }
- }
- assertNotNull(emacsScheme);
- assertNotNull(defaultScheme);
-
- BindingModel bm = controller.getBindingModel();
- BindingElement quickSwitch = null;
- int quickCount = 0;
- i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement e = (BindingElement) i.next();
- if (e.getId().equals(ID_QUICK_SWITCH)) {
- quickSwitch = e;
- quickCount++;
- }
- }
- assertNotNull(quickSwitch);
- assertEquals(1, quickCount);
-
- sm.setSelectedElement(emacsScheme);
-
- i = bm.getBindings().iterator();
- ArrayList quick2 = new ArrayList();
- boolean foundOriginal = false;
- while (i.hasNext()) {
- BindingElement e = (BindingElement) i.next();
- if (e.getId().equals(ID_QUICK_SWITCH)) {
- quick2.add(e);
- if (e == quickSwitch) {
- foundOriginal = true;
- }
- }
- }
- assertEquals(2, quick2.size());
- assertTrue(foundOriginal);
-
- sm.setSelectedElement(defaultScheme);
-
- i = bm.getBindings().iterator();
- quick2.clear();
- foundOriginal = false;
- while (i.hasNext()) {
- BindingElement e = (BindingElement) i.next();
- if (e.getId().equals(ID_QUICK_SWITCH)) {
- quick2.add(e);
- if (e == quickSwitch) {
- foundOriginal = true;
- }
- }
- }
- assertEquals(1, quick2.size());
- assertTrue(foundOriginal);
- }
-
- public void testSchemesWithNoDefaultBinding() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final SchemeModel sm = controller.getSchemeModel();
- SchemeElement emacsScheme = null;
- SchemeElement defaultScheme = null;
- Iterator i = sm.getSchemes().iterator();
- while (i.hasNext()) {
- SchemeElement e = (SchemeElement) i.next();
- if (e.getId().equals(SCHEME_EMACS_ID)) {
- emacsScheme = e;
- } else if (e.getId().equals(
- IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID)) {
- defaultScheme = e;
- }
- }
- assertNotNull(emacsScheme);
- assertNotNull(defaultScheme);
-
- final BindingModel bm = controller.getBindingModel();
- BindingElement emacsElement = getBindingElement(bm, ID_CMD_EMACS1);
- assertNotNull(emacsElement);
- assertTrue(emacsElement.getModelObject() instanceof ParameterizedCommand);
-
- sm.setSelectedElement(emacsScheme);
-
- emacsElement = getBindingElement(bm, ID_CMD_EMACS1);
- assertTrue(emacsElement.getModelObject() instanceof KeyBinding);
-
- sm.setSelectedElement(defaultScheme);
-
- emacsElement = getBindingElement(bm, ID_CMD_EMACS1);
- assertTrue(emacsElement.getModelObject() instanceof ParameterizedCommand);
- }
-
- public void testCopyBinding() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- BindingModel bm = controller.getBindingModel();
- BindingElement activateEditor = null;
- ArrayList activates = new ArrayList();
- Iterator i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement be = (BindingElement) i.next();
- if (be.getId().equals(ID_ACTIVATE_EDITOR)) {
- activates.add(be);
- if (be.getModelObject() instanceof KeyBinding) {
- activateEditor = be;
- }
- }
- }
- assertEquals(1, activates.size());
- assertNotNull(activateEditor);
-
- bm.setSelectedElement(activateEditor);
- bm.copy();
- activates.clear();
- i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement be = (BindingElement) i.next();
- if (be.getId().equals(ID_ACTIVATE_EDITOR)) {
- activates.add(be);
- }
- }
- assertEquals(2, activates.size());
- }
-
- public void testCopyCommand() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- BindingModel bm = controller.getBindingModel();
- BindingElement conflict4 = null;
- ArrayList activates = new ArrayList();
- Iterator i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement be = (BindingElement) i.next();
- if (be.getId().equals(ID_CMD_CONFLICT4)) {
- activates.add(be);
- if (be.getModelObject() instanceof ParameterizedCommand) {
- conflict4 = be;
- }
- }
- }
- assertEquals(1, activates.size());
- assertNotNull(conflict4);
-
- bm.setSelectedElement(conflict4);
- bm.copy();
- activates.clear();
- i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement be = (BindingElement) i.next();
- if (be.getId().equals(ID_CMD_CONFLICT4)) {
- activates.add(be);
- }
- }
- assertEquals(1, activates.size());
- }
-
- public void testRemoveActiveEditor() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- BindingModel bm = controller.getBindingModel();
- BindingElement activateEditor = getBindingElement(bm,
- ID_ACTIVATE_EDITOR);
-
- assertNotNull(activateEditor);
- assertTrue(activateEditor.getModelObject() instanceof KeyBinding);
-
- bm.setSelectedElement(activateEditor);
- bm.remove();
-
- assertTrue(activateEditor.getModelObject() instanceof ParameterizedCommand);
- }
-
- public void testRestoreBinding() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- BindingModel bm = controller.getBindingModel();
- BindingElement activateEditor = getBindingElement(bm,
- ID_ACTIVATE_EDITOR);
-
- bm.setSelectedElement(activateEditor);
-
- KeySequence ctrl5 = KeySequence.getInstance("CTRL+5 N");
- activateEditor.setTrigger(ctrl5);
-
- assertEquals(new Integer(Binding.USER), activateEditor.getUserDelta());
- bm.copy();
- BindingElement activeTwo = (BindingElement) bm.getSelectedElement();
- assertFalse(activateEditor == activeTwo);
-
- activeTwo.setTrigger(KeySequence.getInstance("CTRL+5 M"));
- assertEquals(new Integer(Binding.USER), activeTwo.getUserDelta());
-
- ArrayList activates = new ArrayList();
- Iterator i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement be = (BindingElement) i.next();
- if (be.getId().equals(ID_ACTIVATE_EDITOR)) {
- activates.add(be);
- }
- }
- assertEquals(2, activates.size());
-
- bm.restoreBinding(controller.getContextModel());
-
- activates = new ArrayList();
- i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement be = (BindingElement) i.next();
- if (be.getId().equals(ID_ACTIVATE_EDITOR)) {
- activates.add(be);
- activateEditor = be;
- }
- }
- assertEquals(1, activates.size());
- assertEquals(new Integer(Binding.SYSTEM), activateEditor.getUserDelta());
- }
-
- public void testRestoreCommand() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ContextModel cm = controller.getContextModel();
- final ContextElement window = (ContextElement) cm
- .getContextIdToElement().get(IContextService.CONTEXT_ID_WINDOW);
-
- final BindingModel bm = controller.getBindingModel();
- BindingElement conflict4 = getBindingElement(bm, ID_CMD_CONFLICT4);
- assertNull(conflict4.getContext());
- Object c4model = conflict4.getModelObject();
- assertTrue(c4model instanceof ParameterizedCommand);
-
- bm.setSelectedElement(conflict4);
- assertNull(cm.getSelectedElement());
-
- KeySequence ctrl5 = KeySequence.getInstance("CTRL+5 N");
- conflict4.setTrigger(ctrl5);
- assertEquals(window, ((BindingElement) bm.getSelectedElement())
- .getContext());
- assertTrue(conflict4.getModelObject() instanceof KeyBinding);
-
- bm.setSelectedElement(conflict4);
- bm.restoreBinding(cm);
-
- conflict4 = getBindingElement(bm, ID_CMD_CONFLICT4);
- assertTrue(conflict4.getModelObject() instanceof ParameterizedCommand);
- }
-
- public void testRestoreContext() throws Exception {
- final KeyController controller = new KeyController();
- controller.init(getWorkbench());
-
- final ContextModel cm = controller.getContextModel();
- final ContextElement dialog = (ContextElement) cm
- .getContextIdToElement().get(IContextService.CONTEXT_ID_DIALOG);
-
- final BindingModel bm = controller.getBindingModel();
- BindingElement activateEditor = getBindingElement(bm,
- ID_ACTIVATE_EDITOR);
- activateEditor.setContext(dialog);
-
- bm.setSelectedElement(activateEditor);
- bm.restoreBinding(cm);
-
- activateEditor = getBindingElement(bm, ID_ACTIVATE_EDITOR);
- assertNotNull(activateEditor);
- }
-
- private void assertChangeEvent(int eventNum, PropertyChangeEvent expected,
- PropertyChangeEvent event) {
- assertEquals("source: " + eventNum, expected.getSource(), event
- .getSource());
- assertEquals("property: " + eventNum, expected.getProperty(), event
- .getProperty());
- assertEquals("old: " + eventNum, expected.getOldValue(), event
- .getOldValue());
- assertEquals("new: " + eventNum, expected.getNewValue(), event
- .getNewValue());
- }
-
- private void assertChanges(PropertyChangeEvent[] expected, List events) {
- assertEquals("events length", expected.length, events.size());
- for (int i = 0; i < expected.length; i++) {
- assertChangeEvent(i, expected[i], (PropertyChangeEvent) events
- .get(i));
- }
- }
-
- private BindingElement getBindingElement(BindingModel bm, String bindingId) {
- BindingElement quickAccess = null;
- Iterator i = bm.getBindings().iterator();
- while (i.hasNext()) {
- BindingElement e = (BindingElement) i.next();
- if (e.getId().equals(bindingId)) {
- quickAccess = e;
- }
- }
- return quickAccess;
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysTestSuite.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysTestSuite.java
deleted file mode 100755
index aee38a8..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/KeysTestSuite.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.ui.keybinding.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Tests for all areas of the key support for the platform.
- */
-public class KeysTestSuite extends TestSuite {
-
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- */
- public static Test suite() {
- return new KeysTestSuite();
- }
-
- /**
- * Construct the test suite.
- */
- public KeysTestSuite() {
- addTest(new TestSuite(BindingInteractionsTest.class));
- addTest(new TestSuite(BindingManagerTest.class));
- addTest(new TestSuite(BindingPersistenceTest.class));
- // TODO This no longer works due to focus issues related to key bindings
- //addTest(new TestSuite(Bug36420Test.class));
- // TODO This test is broken until JDT fixes Bug 44148
- // addTest(new TestSuite(Bug36537Test.class));
- // TODO Intermittent failure. SWT Bug 44344. XGrabPointer?
- // addTest(new TestSuite(Bug40023Test.class));
- addTest(new TestSuite(Bug42024Test.class));
- addTest(new TestSuite(Bug42035Test.class));
- // TODO Logging piece of fix did not go in M4.
- // addTest(new TestSuite(Bug42627Test.class));
- addTest(new TestSuite(Bug43168Test.class));
- addTest(new TestSuite(Bug43321Test.class));
- addTest(new TestSuite(Bug43538Test.class));
- addTest(new TestSuite(Bug43597Test.class));
- addTest(new TestSuite(Bug43610Test.class));
- addTest(new TestSuite(Bug43800Test.class));
- addTest(new TestSuite(KeysCsvTest.class));
- // TODO disabled since it refers to the Java builder and nature,
- // which are not available in an RCP build
- // addTest(new TestSuite(Bug44460Test.class));
- /* TODO disabled as it is causing failures in the nightly builds.
- * focus related?
- */
- //addTest(new TestSuite(Bug53489Test.class));
- addTest(new TestSuite(Bug189167Test.class));
- addTest(new TestSuite(KeysPreferenceModelTest.class));
- }
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/PreferenceMutator.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/PreferenceMutator.java
deleted file mode 100755
index 62f3f51..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/PreferenceMutator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.e4.ui.keybinding.tests;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.eclipse.core.runtime.Preferences;
-
-/**
- * A utility class for setting preferences related to key bindings. This class
- * currently uses the round-about procedure of manually writing a preferences
- * file, and then loading it back into the application. In the future, it might
- * use a direct API.
- *
- * @since 3.0
- */
-public abstract class PreferenceMutator {
- /**
- * Sets a key binding in the currently running Eclipse application. It
- * accomplishes this by writing out an exported preferences file by hand,
- * and then importing it back into the application.
- *
- * @param commandId
- * The command identifier to which the key binding should be
- * associated; should not be <code>null</code>.
- * @param keySequenceText
- * The text of the key sequence for this key binding; must not be
- * <code>null</code>.
- * @throws CoreException
- * If the exported preferences file is invalid for some reason.
- * @throws FileNotFoundException
- * If the temporary file is removed before it can be read in.
- * (Wow)
- * @throws IOException
- * If the creation of or the writing to the temporary file fails
- * for some reason.
- */
- static final void setKeyBinding(String commandId, String keySequenceText)
- throws CoreException, FileNotFoundException, IOException {
- // Set up the preferences.
- Properties preferences = new Properties();
- String key = "org.eclipse.ui.workbench/org.eclipse.ui.commands"; //$NON-NLS-1$
- String value = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<org.eclipse.ui.commands><activeKeyConfiguration/><keyBinding commandId=\"" + commandId + "\" keySequence=\"" + keySequenceText + "\"/></org.eclipse.ui.commands>"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- preferences.put(key, value);
-
- String[] pluginIds = Platform.getExtensionRegistry().getNamespaces();
- for (int i = 0; i < pluginIds.length; i++) {
- preferences.put(pluginIds[i], new PluginVersionIdentifier(
- (String) Platform.getBundle(pluginIds[i]).getHeaders().get(
- org.osgi.framework.Constants.BUNDLE_VERSION)));
- }
-
- // Export the preferences.
- File file = File.createTempFile("preferences", ".txt"); //$NON-NLS-1$//$NON-NLS-2$
- file.deleteOnExit();
- BufferedOutputStream bos = new BufferedOutputStream(
- new FileOutputStream(file));
- preferences.store(bos, null);
- bos.close();
-
- // Attempt to import the key binding.
- Preferences.importPreferences(new Path(file.getAbsolutePath()));
- }
-
-}
diff --git a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/TestBinding.java b/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/TestBinding.java
deleted file mode 100755
index 7fe7f01..0000000
--- a/tests/org.eclipse.e4.ui.keybinding.tests/src/org/eclipse/e4/ui/keybinding/tests/TestBinding.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.e4.ui.keybinding.tests;
-
-import org.eclipse.core.commands.CommandManager;
-import org.eclipse.core.commands.Parameterization;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.jface.bindings.Binding;
-import org.eclipse.jface.bindings.Trigger;
-import org.eclipse.jface.bindings.TriggerSequence;
-import org.eclipse.jface.util.Util;
-
-/**
- * A binding that can be used for testing purposes. This guarantees that the
- * properties tested are inherent to all bindings, and not just a specific type
- * of bindings.
- */
-final class TestBinding extends Binding {
-
- /**
- * A simple trigger sequence for this test.
- */
- static final class TestTriggerSequence extends TriggerSequence {
-
- /**
- * Constructs a new instance of <code>TestTriggerSequence</code>.
- *
- * @param myTriggers
- * The triggers to use in constructing this sequence; must
- * not be <code>null</code>.
- */
- public TestTriggerSequence() {
- super(new Trigger[0]);
- }
-
- public final String format() {
- return toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.bindings.TriggerSequence#getPrefixes()
- */
- public TriggerSequence[] getPrefixes() {
- return new TriggerSequence[0];
- }
- }
-
- /**
- * A command manager to use for creating commands.
- */
- private static final CommandManager commandManager = new CommandManager();
-
- /**
- * A trigger sequence to be used by all test bindings. This value is never
- * <code>null</code>.
- */
- static final TriggerSequence TRIGGER_SEQUENCE = new TestTriggerSequence();
-
- /**
- * Constructs a new instance of <code>TestBinding</code>
- *
- * @param commandId
- * The command id
- * @param schemeId
- * The scheme id
- * @param contextId
- * The context id
- * @param locale
- * The locale
- * @param platform
- * The platform
- * @param type
- * The type: SYSTEM or USER
- * @param paramaterizations
- * The parameters
- */
- TestBinding(final String commandId, final String schemeId,
- final String contextId, final String locale, final String platform,
- final int type, final Parameterization[] parameterizations) {
- super((commandId == null) ? null : new ParameterizedCommand(
- commandManager.getCommand(commandId), parameterizations),
- schemeId, contextId, locale, platform, null, type);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.bindings.Binding#getTriggerSequence()
- */
- public final TriggerSequence getTriggerSequence() {
- return TRIGGER_SEQUENCE;
- }
-
- public final String toString() {
- return Util.ZERO_LENGTH_STRING;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java
index 805c926..4378c4e 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/keys/BindingPersistenceTest.java
@@ -10,14 +10,20 @@
*******************************************************************************/
package org.eclipse.ui.tests.keys;
+import java.util.HashMap;
+
import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.e4.ui.bindings.EBindingService;
import org.eclipse.jface.bindings.Binding;
+import org.eclipse.jface.bindings.Scheme;
import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.bindings.keys.KeyBinding;
import org.eclipse.jface.bindings.keys.KeySequence;
import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.Util;
import org.eclipse.swt.SWT;
+import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.internal.WorkbenchPlugin;
@@ -28,14 +34,16 @@ import org.eclipse.ui.tests.harness.util.UITestCase;
* Test cases covering the various interaction between bindings. Bindings that
* have been removed. Bindings that have been added. Inheritance of various
* properties.
- *
+ *
* @since 3.1
*/
public final class BindingPersistenceTest extends UITestCase {
+ private final String EMACS_SCHEME_ID = "org.eclipse.ui.emacsAcceleratorConfiguration";
+
/**
* Constructor for <code>BindingPersistenceTest</code>.
- *
+ *
* @param name
* The name of the test
*/
@@ -48,7 +56,7 @@ public final class BindingPersistenceTest extends UITestCase {
* Tests whether the preference store will be read automatically when a
* change to the preference store is made.
* </p>
- *
+ *
* @throws ParseException
* If "ALT+SHIFT+Q A" cannot be parsed by KeySequence.
*/
@@ -61,7 +69,7 @@ public final class BindingPersistenceTest extends UITestCase {
bindingService.readRegistryAndPreferences(commandService);
// Check the pre-conditions.
- final String emacsSchemeId = "org.eclipse.ui.emacsAcceleratorConfiguration";
+ final String emacsSchemeId = EMACS_SCHEME_ID;
assertFalse("The active scheme should be Emacs yet", emacsSchemeId
.equals(bindingService.getActiveScheme().getId()));
final KeySequence formalKeySequence = KeySequence
@@ -268,7 +276,7 @@ public final class BindingPersistenceTest extends UITestCase {
}
}
}
-
+
public void testDifferentPlatform() throws Exception {
ICommandService commandService = (ICommandService) fWorkbench
@@ -295,9 +303,281 @@ public final class BindingPersistenceTest extends UITestCase {
}
}
- /* (non-Javadoc)
+ public void testAboutBinding() throws Exception {
+ ICommandService commandService = (ICommandService) fWorkbench
+ .getAdapter(ICommandService.class);
+ IBindingService bindingService = (IBindingService) fWorkbench
+ .getAdapter(IBindingService.class);
+
+ final Scheme activeScheme = bindingService.getActiveScheme();
+ final Binding[] originalBindings = bindingService.getBindings();
+
+ ParameterizedCommand aboutCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.HELP_ABOUT),
+ null);
+ ParameterizedCommand activateEditorCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.WINDOW_ACTIVATE_EDITOR),
+ null);
+
+ final KeySequence keyF12 = KeySequence.getInstance("F12");
+ final KeySequence keyAltCtrlShiftI = KeySequence
+ .getInstance("ALT+CTRL+SHIFT+I");
+ final Binding editorBinding = bindingService.getPerfectMatch(keyF12);
+ assertNotNull(editorBinding);
+ assertEquals(activateEditorCmd, editorBinding.getParameterizedCommand());
+
+ EBindingService ebs = (EBindingService) fWorkbench
+ .getService(EBindingService.class);
+ HashMap<String, String> attrs = new HashMap<String, String>();
+ attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
+ final Binding localAboutBinding = ebs.createBinding(keyF12, aboutCmd,
+ IContextService.CONTEXT_ID_WINDOW, attrs);
+ assertEquals(Binding.USER, localAboutBinding.getType());
+
+ // test unbinding a system binding and adding a user binding (same
+ // triggers and context)
+ final Binding[] bindings = originalBindings;
+ Binding[] added = new Binding[bindings.length + 2];
+ System.arraycopy(bindings, 0, added, 0, bindings.length);
+
+ Binding del = new KeyBinding(keyF12, null,
+ IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID,
+ IContextService.CONTEXT_ID_WINDOW, null, null, null,
+ Binding.USER);
+ added[bindings.length] = del;
+ added[bindings.length + 1] = localAboutBinding;
+ bindingService.savePreferences(activeScheme, added);
+
+ // the match should be the user binding that we just added
+ final Binding secondMatch = bindingService.getPerfectMatch(keyF12);
+ assertNotNull(secondMatch);
+ assertEquals(aboutCmd, secondMatch.getParameterizedCommand());
+
+ // go back to the defaults
+ bindingService.savePreferences(activeScheme, originalBindings);
+ final Binding thirdMatch = bindingService.getPerfectMatch(keyF12);
+ assertNotNull(thirdMatch);
+ assertEquals(activateEditorCmd, thirdMatch.getParameterizedCommand());
+
+ // try assigning alt-ctrl-shift-i (no other binding uses this for this
+ // context) to the 'about' command
+ final Binding localAboutBinding1 = ebs.createBinding(keyAltCtrlShiftI,
+ aboutCmd, IContextService.CONTEXT_ID_WINDOW, attrs);
+ assertEquals(Binding.USER, localAboutBinding1.getType());
+ Binding[] added1 = new Binding[bindings.length + 1];
+ System.arraycopy(bindings, 0, added1, 0, bindings.length);
+ added1[bindings.length] = localAboutBinding1;
+
+ bindingService.savePreferences(activeScheme, added1);
+ final Binding fourthMatch = bindingService
+ .getPerfectMatch(keyAltCtrlShiftI);
+ assertNotNull(fourthMatch);
+ assertEquals(aboutCmd, fourthMatch.getParameterizedCommand());
+ }
+
+ public void testAboutBindingIn3x() throws Exception {
+ ICommandService commandService = (ICommandService) fWorkbench
+ .getAdapter(ICommandService.class);
+ IBindingService bindingService = (IBindingService) fWorkbench
+ .getAdapter(IBindingService.class);
+
+ final Scheme activeScheme = bindingService.getActiveScheme();
+
+ ParameterizedCommand aboutCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.HELP_ABOUT),
+ null);
+ ParameterizedCommand activateEditorCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.WINDOW_ACTIVATE_EDITOR),
+ null);
+
+ final KeySequence keyF12 = KeySequence.getInstance("F12");
+ final Binding editorBinding = bindingService.getPerfectMatch(keyF12);
+ assertNotNull(editorBinding);
+ assertEquals(activateEditorCmd, editorBinding.getParameterizedCommand());
+
+ EBindingService ebs = (EBindingService) fWorkbench
+ .getService(EBindingService.class);
+ HashMap<String, String> attrs = new HashMap<String, String>();
+ attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
+ final Binding localAboutBinding = ebs.createBinding(keyF12, aboutCmd,
+ IContextService.CONTEXT_ID_WINDOW, attrs);
+ assertEquals(Binding.USER, localAboutBinding.getType());
+
+ final Binding[] bindings = bindingService.getBindings();
+ Binding[] added = new Binding[bindings.length + 1];
+ System.arraycopy(bindings, 0, added, 0, bindings.length);
+
+ added[bindings.length] = localAboutBinding;
+ bindingService.savePreferences(activeScheme, added);
+
+ final Binding secondMatch = bindingService.getPerfectMatch(keyF12);
+ // fails
+ assertNotNull(secondMatch);
+ assertEquals(aboutCmd, secondMatch.getParameterizedCommand());
+ }
+
+ public void testAboutBindingEmacs() throws Exception {
+
+ ICommandService commandService = (ICommandService) fWorkbench
+ .getAdapter(ICommandService.class);
+ IBindingService bindingService = (IBindingService) fWorkbench
+ .getAdapter(IBindingService.class);
+
+ final Scheme emacsScheme = bindingService.getScheme(EMACS_SCHEME_ID);
+ assertNotNull(emacsScheme);
+ final Binding[] originalBindings = bindingService.getBindings();
+ bindingService.savePreferences(emacsScheme, originalBindings);
+
+ ParameterizedCommand findAndReplaceCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE),
+ null);
+ ParameterizedCommand aboutCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.HELP_ABOUT),
+ null);
+
+ final KeySequence keyAltR = KeySequence.getInstance("ALT+R");
+ final KeySequence keyAltCtrlShiftI = KeySequence
+ .getInstance("ALT+CTRL+SHIFT+I");
+ final Binding findAndReplaceBinding = bindingService
+ .getPerfectMatch(keyAltR);
+
+ assertNotNull(findAndReplaceBinding);
+ assertEquals(findAndReplaceCmd,
+ findAndReplaceBinding.getParameterizedCommand());
+ assertEquals(EMACS_SCHEME_ID, findAndReplaceBinding.getSchemeId());
+
+ EBindingService ebs = (EBindingService) fWorkbench
+ .getService(EBindingService.class);
+ HashMap<String, String> attrs = new HashMap<String, String>();
+ attrs.put(EBindingService.TYPE_ATTR_TAG, "user");
+ attrs.put(EBindingService.SCHEME_ID_ATTR_TAG, EMACS_SCHEME_ID);
+ final Binding localAboutBinding = ebs.createBinding(keyAltR, aboutCmd,
+ IContextService.CONTEXT_ID_WINDOW, attrs);
+ assertNotNull(localAboutBinding);
+ assertEquals(Binding.USER, localAboutBinding.getType());
+ assertEquals(EMACS_SCHEME_ID, localAboutBinding.getSchemeId());
+
+ final Binding[] bindings = originalBindings;
+ Binding[] added = new Binding[bindings.length + 2];
+ System.arraycopy(bindings, 0, added, 0, bindings.length);
+
+ Binding del = new KeyBinding(keyAltR, null, EMACS_SCHEME_ID,
+ IContextService.CONTEXT_ID_WINDOW, null, null, null,
+ Binding.USER);
+ added[bindings.length] = del;
+ added[bindings.length + 1] = localAboutBinding;
+ bindingService.savePreferences(emacsScheme, added);
+
+ // the match should be the user binding that we just added
+ final Binding secondMatch = bindingService.getPerfectMatch(keyAltR);
+ assertNotNull(secondMatch);
+ assertEquals(aboutCmd, secondMatch.getParameterizedCommand());
+
+ // go back to the defaults
+ bindingService.savePreferences(emacsScheme, originalBindings);
+ final Binding thirdMatch = bindingService.getPerfectMatch(keyAltR);
+ assertNotNull(thirdMatch);
+ assertEquals(findAndReplaceCmd, thirdMatch.getParameterizedCommand());
+
+ // try assigning alt-ctrl-shift-i (no other binding uses this for this
+ // context) to the 'about' command
+ final Binding localAboutBinding1 = ebs.createBinding(keyAltCtrlShiftI,
+ aboutCmd, IContextService.CONTEXT_ID_WINDOW, attrs);
+ assertNotNull(localAboutBinding1);
+ assertEquals(Binding.USER, localAboutBinding1.getType());
+ assertEquals(EMACS_SCHEME_ID, localAboutBinding.getSchemeId());
+
+ Binding[] added1 = new Binding[bindings.length + 1];
+ System.arraycopy(bindings, 0, added1, 0, bindings.length);
+ added1[bindings.length] = localAboutBinding1;
+
+ bindingService.savePreferences(emacsScheme, added1);
+ final Binding fourthMatch = bindingService
+ .getPerfectMatch(keyAltCtrlShiftI);
+ assertNotNull(fourthMatch);
+ assertEquals(aboutCmd, fourthMatch.getParameterizedCommand());
+ assertEquals(EMACS_SCHEME_ID, fourthMatch.getSchemeId());
+ }
+
+ // the 'paste' key binding overrides the 'redo' key binding on Windows
+ // platforms
+ public void testPasteAndRedoBindingEmacs() throws Exception {
+ ICommandService commandService = (ICommandService) fWorkbench
+ .getAdapter(ICommandService.class);
+ IBindingService bindingService = (IBindingService) fWorkbench
+ .getAdapter(IBindingService.class);
+
+ final Scheme emacsScheme = bindingService.getScheme(EMACS_SCHEME_ID);
+ assertNotNull(emacsScheme);
+ final Scheme defaultScheme = bindingService
+ .getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID);
+ assertNotNull(defaultScheme);
+
+ final Binding[] originalBindings = bindingService.getBindings();
+ bindingService.savePreferences(emacsScheme, originalBindings);
+
+ ParameterizedCommand pasteCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.EDIT_PASTE),
+ null);
+ ParameterizedCommand redoCmd = new ParameterizedCommand(
+ commandService.getCommand(IWorkbenchCommandConstants.EDIT_REDO),
+ null);
+
+ final KeySequence keyCtrlY = KeySequence.getInstance("CTRL+Y");
+
+ final Binding pasteBinding = bindingService.getPerfectMatch(keyCtrlY);
+ assertNotNull(pasteBinding);
+ assertEquals(pasteCmd, pasteBinding.getParameterizedCommand());
+ assertEquals(EMACS_SCHEME_ID, pasteBinding.getSchemeId());
+
+ // reset the scheme
+ bindingService.savePreferences(defaultScheme, originalBindings);
+ final Binding redoBinding = bindingService.getPerfectMatch(keyCtrlY);
+ assertNotNull(redoBinding);
+ assertEquals(redoCmd, redoBinding.getParameterizedCommand());
+ assertEquals(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID,
+ redoBinding.getSchemeId());
+ }
+
+ // the 'paste' key binding overrides the 'redo' key binding and can be
+ // put back
+ public void testPasteBindingEmacs() throws Exception {
+ ICommandService commandService = (ICommandService) fWorkbench
+ .getAdapter(ICommandService.class);
+ IBindingService bindingService = (IBindingService) fWorkbench
+ .getAdapter(IBindingService.class);
+
+ final Scheme emacsScheme = bindingService.getScheme(EMACS_SCHEME_ID);
+ assertNotNull(emacsScheme);
+ final Binding[] originalBindings = bindingService.getBindings();
+ bindingService.savePreferences(emacsScheme, originalBindings);
+
+ ParameterizedCommand pasteCmd = new ParameterizedCommand(
+ commandService
+ .getCommand(IWorkbenchCommandConstants.EDIT_PASTE),
+ null);
+
+ final KeySequence keyCtrlY = KeySequence.getInstance("CTRL+Y");
+
+ final Binding pasteBinding = bindingService.getPerfectMatch(keyCtrlY);
+ assertNotNull(pasteBinding);
+ assertEquals(pasteCmd, pasteBinding.getParameterizedCommand());
+ assertEquals(EMACS_SCHEME_ID, pasteBinding.getSchemeId());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ui.tests.harness.util.UITestCase#doTearDown()
*/
+ @Override
protected void doTearDown() throws Exception {
final IPreferenceStore store = WorkbenchPlugin.getDefault()
.getPreferenceStore();
@@ -307,6 +587,15 @@ public final class BindingPersistenceTest extends UITestCase {
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><org.eclipse.ui.commands><activeKeyConfiguration keyConfigurationId=\""
+ IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID
+ "\"/></org.eclipse.ui.commands>");
+ IBindingService bindingService = (IBindingService) fWorkbench
+ .getAdapter(IBindingService.class);
+
+ // reset keybindings
+ bindingService.readRegistryAndPreferences(null);
+ final Scheme activeScheme = bindingService
+ .getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID);
+ final Binding[] originalBindings = bindingService.getBindings();
+ bindingService.savePreferences(activeScheme, originalBindings);
super.doTearDown();
}
}