diff options
author | Mickael ADAM | 2017-04-19 14:24:16 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2017-04-24 14:04:35 +0000 |
commit | 898d12aabffb12562ea024d4bc9d6b543c40ca3b (patch) | |
tree | 163ea54392685c4518b7a1070b680acf32811ad6 /tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests | |
parent | 231fa453b8ad44b3c43a318bec3d0eb0266b63a2 (diff) | |
download | org.eclipse.papyrus-898d12aabffb12562ea024d4bc9d6b543c40ca3b.tar.gz org.eclipse.papyrus-898d12aabffb12562ea024d4bc9d6b543c40ca3b.tar.xz org.eclipse.papyrus-898d12aabffb12562ea024d4bc9d6b543c40ca3b.zip |
Bug 512343 - [Palette] Papyrus Palette framework should be refactored
- fix in genmodel: reload it to put ElemetTypesConfiguration model in
import gen model instead of root package.
- regenerate, model, edit, editor
-Replace test with another(more test will be done later)
Change-Id: Icf58d5c69abe5d69fb3ba91dbe115ce434664e73
Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
Diffstat (limited to 'tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests')
10 files changed, 141 insertions, 287 deletions
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.classpath b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.classpath index 098194ca4b7..eca7bdba8f0 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.classpath +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.classpath @@ -1,6 +1,6 @@ <?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.7"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.settings/org.eclipse.jdt.core.prefs b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.settings/org.eclipse.jdt.core.prefs index f08be2b06c4..b3aa6d60f94 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.settings/org.eclipse.jdt.core.prefs +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,10 +1,10 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/META-INF/MANIFEST.MF index 1fb09395f0d..183d83a69a4 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/META-INF/MANIFEST.MF @@ -4,19 +4,14 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.resources;bundle-version="3.8.0",
org.eclipse.papyrus.infra.types;bundle-version="[3.0.0,4.0.0)",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.8.0",
- org.eclipse.papyrus.uml.diagram.common;bundle-version="1.1.0",
- org.eclipse.papyrus.uml.diagram.tests;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.junit.utils;bundle-version="[2.0.100,3.0.0)",
org.eclipse.papyrus.junit.framework;bundle-version="[1.2.0,2.0.0)",
org.junit;bundle-version="4.11.0",
- org.eclipse.papyrus.uml.diagram.clazz;bundle-version="1.1.0",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.1.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)",
org.eclipse.papyrus.editor;bundle-version="1.1.0",
org.eclipse.papyrus.infra.core;bundle-version="1.1.0",
org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.1.0",
- org.eclipse.papyrus.uml.tools;bundle-version="1.1.0",
- org.eclipse.papyrus.uml.extensionpoints,
org.eclipse.papyrus.infra.ui;bundle-version="1.2.0"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
@@ -26,3 +21,5 @@ Bundle-ManifestVersion: 2 Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.Activator
Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests;singleton:=true
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Import-Package: com.google.common.base;version="21.0.0",
+ com.google.common.collect;version="21.0.0"
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/plugin.xml b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/plugin.xml index 9aa04cfdce1..7f2772728f2 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/plugin.xml +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/plugin.xml @@ -9,7 +9,7 @@ </elementTypeSet> </extension> <extension - point="org.eclipse.papyrus.uml.diagram.common.paletteDefinition"> + point="org.eclipse.papyrus.infra.gmfdiag.common.paletteDefinition"> <paletteDefinition ID="org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.paletteDefinition" class="org.eclipse.papyrus.infra.gmfdiag.common.service.palette.ExtendedPluginPaletteProvider" @@ -38,7 +38,7 @@ </elementTypeSet> </extension> <extension - point="org.eclipse.papyrus.uml.diagram.common.paletteDefinition"> + point="org.eclipse.papyrus.infra.gmfdiag.common.paletteDefinition"> <paletteDefinition ID="org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.fakepaletteDefinition" class="org.eclipse.papyrus.infra.gmfdiag.common.service.palette.ExtendedPluginPaletteProvider" @@ -51,7 +51,7 @@ </paletteDefinition> </extension> <extension - point="org.eclipse.papyrus.uml.diagram.common.paletteDefinition"> + point="org.eclipse.papyrus.infra.gmfdiag.common.paletteDefinition"> <paletteDefinition ID="org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.noProfilepaletteDefinition" class="org.eclipse.papyrus.infra.gmfdiag.common.service.palette.ExtendedPluginPaletteProvider" diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/FakeProfile.paletteconfiguration b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/FakeProfile.paletteconfiguration index 1a3dc71a1bc..54018dc8f02 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/FakeProfile.paletteconfiguration +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/FakeProfile.paletteconfiguration @@ -1,21 +1,11 @@ -<?xml version="1.0" encoding="ASCII"?> -<paletteconfiguration:PaletteConfiguration - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.7" - id="TestFakePaletteConfiguration" - label="Test Fake Palette Configuration"> - <drawerConfigurations - id="TestFakePaletteNodesDrawer" - label="TestFakePaletteConfigurationNodes" - description="Test Fake Paletteconfiguration Nodes"> - <ownedConfigurations - xsi:type="paletteconfiguration:ToolConfiguration" - id="testfakepalettemodel.StoOnClass" - label="FakeTool" - description="Create a Class With FAke Sto"> - <elementDescriptors - elementTypeId="org.eclipse.papyrus.uml.diagram.paletteconfiguration.fake.tests"/> - </ownedConfigurations> - </drawerConfigurations> - <requiredProfiles>FakeProfile</requiredProfiles> -</paletteconfiguration:PaletteConfiguration> +<?xml version="1.0" encoding="ASCII"?>
+<paletteconfiguration:PaletteConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.8" id="TestFakePaletteConfiguration" label="Test Fake Palette Configuration">
+ <drawerConfigurations id="TestFakePaletteNodesDrawer" label="TestFakePaletteConfigurationNodes" description="Test Fake Paletteconfiguration Nodes">
+ <ownedConfigurations xsi:type="paletteconfiguration:ToolConfiguration" id="testfakepalettemodel.StoOnClass" label="FakeTool" description="Create a Class With FAke Sto">
+ <elementDescriptors>
+ <elementType xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/FakeProfile.elementtypesconfigurations#_ubJcsaeUEeSUR5jX0TaAcA"/>
+ </elementDescriptors>
+ </ownedConfigurations>
+ </drawerConfigurations>
+ <requiredProfiles>FakeProfile</requiredProfiles>
+</paletteconfiguration:PaletteConfiguration>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/NoProfile.paletteconfiguration b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/NoProfile.paletteconfiguration index 3ee1221e7d3..a5e4904f7a3 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/NoProfile.paletteconfiguration +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/NoProfile.paletteconfiguration @@ -1,20 +1,10 @@ -<?xml version="1.0" encoding="ASCII"?> -<paletteconfiguration:PaletteConfiguration - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.7" - id="NoProfilePaletteConfiguration" - label="Test No Profile palette Configuration"> - <drawerConfigurations - id="TestNoProfilePaletteNodesDrawer" - label="TestNoProfilePaletteConfigurationNodes" - description="Test No Profile Paletteconfiguration Nodes"> - <ownedConfigurations - xsi:type="paletteconfiguration:ToolConfiguration" - id="testnoprofile.tool" - label="NoProfileCreationTool" - description="Create a Class With no rofile"> - <elementDescriptors - elementTypeId="org.eclipse.papyrus.uml.diagram.paletteconfiguration.fake.tests"/> - </ownedConfigurations> - </drawerConfigurations> -</paletteconfiguration:PaletteConfiguration> +<?xml version="1.0" encoding="ASCII"?>
+<paletteconfiguration:PaletteConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.8" id="NoProfilePaletteConfiguration" label="Test No Profile palette Configuration">
+ <drawerConfigurations id="TestNoProfilePaletteNodesDrawer" label="TestNoProfilePaletteConfigurationNodes" description="Test No Profile Paletteconfiguration Nodes">
+ <ownedConfigurations xsi:type="paletteconfiguration:ToolConfiguration" id="testnoprofile.tool" label="NoProfileCreationTool" description="Create a Class With no rofile">
+ <elementDescriptors>
+ <elementType xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/FakeProfile.elementtypesconfigurations#_ubJcsaeUEeSUR5jX0TaAcA"/>
+ </elementDescriptors>
+ </ownedConfigurations>
+ </drawerConfigurations>
+</paletteconfiguration:PaletteConfiguration>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/TestPalette.paletteconfiguration b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/TestPalette.paletteconfiguration index 1098a113b82..9aebd79a5b0 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/TestPalette.paletteconfiguration +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/TestPalette.paletteconfiguration @@ -1,21 +1,11 @@ -<?xml version="1.0" encoding="ASCII"?> -<paletteconfiguration:PaletteConfiguration - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.7" - id="TestPaletteConfiguration" - label="Test Palette Configuration"> - <drawerConfigurations - id="TestPaletteNodesDrawer" - label="TestPaletteConfigurationNodes" - description="Test Paletteconfiguration Nodes"> - <ownedConfigurations - xsi:type="paletteconfiguration:ToolConfiguration" - id="testpalettemodel.StoOnClass" - label="StoOnClass" - description="Create a Class With StoOnClass"> - <elementDescriptors - elementTypeId="org.eclipse.papyrus.uml.diagram.paletteconfiguration.tests"/> - </ownedConfigurations> - </drawerConfigurations> - <requiredProfiles>TestPaletteConfiguration</requiredProfiles> -</paletteconfiguration:PaletteConfiguration> +<?xml version="1.0" encoding="ASCII"?>
+<paletteconfiguration:PaletteConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmlns:paletteconfiguration="http://www.eclipse.org/papyrus/diagram/paletteconfiguration/0.8" id="TestPaletteConfiguration" label="Test Palette Configuration">
+ <drawerConfigurations id="TestPaletteNodesDrawer" label="TestPaletteConfigurationNodes" description="Test Paletteconfiguration Nodes">
+ <ownedConfigurations xsi:type="paletteconfiguration:ToolConfiguration" id="testpalettemodel.StoOnClass" label="StoOnClass" description="Create a Class With StoOnClass" toolClassName="">
+ <elementDescriptors>
+ <elementType xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/resources/TestPalette.elementtypesconfigurations#_ubJcsaeUEeSUR5jX0TaAcA"/>
+ </elementDescriptors>
+ </ownedConfigurations>
+ </drawerConfigurations>
+ <requiredProfiles>TestPaletteConfiguration</requiredProfiles>
+</paletteconfiguration:PaletteConfiguration>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/AllTests.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/AllTests.java index 602307a42c3..fc650917391 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/AllTests.java +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/AllTests.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010 CEA LIST. + * Copyright (c) 2017 CEA LIST. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,12 +8,13 @@ * * Contributors: * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Mickaƫl ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 512343 *****************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests; -import org.junit.runner.RunWith; -import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.regression.Bug457712PaletteConfigurationRequiredProfile; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.regression.PaletteConfigurationTest; import org.eclipse.papyrus.junit.framework.classification.ClassificationSuite; +import org.junit.runner.RunWith; import org.junit.runners.Suite.SuiteClasses; @@ -21,7 +22,7 @@ import org.junit.runners.Suite.SuiteClasses; * All tests for this fragment */ @RunWith(ClassificationSuite.class) -@SuiteClasses({ Bug457712PaletteConfigurationRequiredProfile.class, }) +@SuiteClasses({ PaletteConfigurationTest.class, }) public class AllTests { } diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/regression/Bug457712PaletteConfigurationRequiredProfile.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/regression/Bug457712PaletteConfigurationRequiredProfile.java deleted file mode 100644 index 132b90c4c65..00000000000 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/regression/Bug457712PaletteConfigurationRequiredProfile.java +++ /dev/null @@ -1,209 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * 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: - * CEA LIST - Initial API and implementation - *****************************************************************************/ -package org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.regression; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.palette.PaletteDrawer; -import org.eclipse.gef.ui.palette.PaletteViewer; -import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.commands.ICreationCommand; -import org.eclipse.papyrus.infra.core.resource.ModelSet; -import org.eclipse.papyrus.infra.core.resource.ModelUtils; -import org.eclipse.papyrus.infra.core.resource.NotFoundException; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.Activator; -import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.junit.utils.EditorUtils; -import org.eclipse.papyrus.junit.utils.PapyrusProjectUtils; -import org.eclipse.papyrus.junit.utils.rules.HouseKeeper; -import org.eclipse.papyrus.uml.diagram.clazz.CreateClassDiagramCommand; -import org.eclipse.papyrus.uml.tools.model.UmlModel; -import org.eclipse.papyrus.uml.tools.model.UmlUtils; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.Profile; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.osgi.framework.Bundle; - -/** - * Regression test for bug 457712 - */ -public class Bug457712PaletteConfigurationRequiredProfile implements ITestConstants { - - public static final String RESOURCES_FOLDER = "/resources/"; - - @ClassRule - public static HouseKeeper.Static houseKeeper = new HouseKeeper.Static(); - - protected static IProject createProject; - - protected static IMultiDiagramEditor openPapyrusEditor; - - protected static ModelSet modelset; - - protected static UmlModel umlIModel; - - protected static Model rootModel; - - protected static TransactionalEditingDomain transactionalEditingDomain; - - protected static IFile workspaceTestFile; - - private static IFile copyTestModel; - - private static Diagram classDiagram; - - private Profile testProfile; - - /** - * Init test class - */ - @BeforeClass - public static void initCreateElementTest() { - - // create Project - createProject = houseKeeper.createProject(BUG457712_PALETTE_CONFIGURATION); - - // import test model and profile - try { - Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); - PapyrusProjectUtils.copyPapyrusModel(createProject, bundle, RESOURCES_FOLDER, "TestPalette.profile"); - copyTestModel = PapyrusProjectUtils.copyPapyrusModel(createProject, bundle, RESOURCES_FOLDER, "Model"); - } catch (CoreException e) { - fail(e.getMessage()); - } catch (IOException e) { - fail(e.getMessage()); - } - - // open project - Display.getDefault().syncExec(new Runnable() { - - public void run() { - try { - openPapyrusEditor = houseKeeper.cleanUpLater(EditorUtils.openPapyrusEditor(copyTestModel)); - } catch (PartInitException e) { - fail(e.getMessage()); - } - } - }); - - transactionalEditingDomain = (TransactionalEditingDomain) openPapyrusEditor.getAdapter(TransactionalEditingDomain.class); - assertTrue("Impossible to init editing domain", transactionalEditingDomain instanceof TransactionalEditingDomain); - - // retrieve UML model from this editor - try { - modelset = ModelUtils.getModelSetChecked(openPapyrusEditor.getServicesRegistry()); - umlIModel = UmlUtils.getUmlModel(modelset); - rootModel = (Model) umlIModel.lookupRoot(); - - Assert.assertNotNull("root model should not be null", rootModel); - - ICreationCommand command = new CreateClassDiagramCommand(); - classDiagram = command.createDiagram(modelset, null, "DiagramToTest"); - modelset.save(new NullProgressMonitor()); - - assertNotNull("There should be a class diagram for test", classDiagram); - - } catch (ServiceException e) { - fail(e.getMessage()); - } catch (NotFoundException e) { - fail(e.getMessage()); - } catch (ClassCastException e) { - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Test - public void testNoProfileApplied() { - // check the palette. tool to create a class with stereotype StoOnClass should not be present - Display.getDefault().syncExec(new Runnable() { - - @Override - public void run() { - // check with profile applied (it is already applied in the model). The drawer should be visible - checkPaletteDrawer("TestPaletteNodesDrawer", true); - checkPaletteDrawer("TestFakePaletteNodesDrawer", false); - checkPaletteDrawer("TestNoProfilePaletteNodesDrawer", true); - } - }); - - } - - protected void checkPaletteDrawer(String identifier, boolean isVisible) { - IEditorPart part = openPapyrusEditor.getActiveEditor(); - if (part instanceof DiagramEditorWithFlyOutPalette) { - PaletteViewer paletteViewer = (PaletteViewer) ((DiagramEditorWithFlyOutPalette) part).getAdapter(PaletteViewer.class); - assertNotNull("There should be a palette viewer on active editor", paletteViewer); - - // will do a shortcut here, only test if test drawer is active or not. This may be enhanced by testing the tool itself - List<?> drawers = paletteViewer.getPaletteRoot().getChildren(); - boolean isDisplayed = false; - for (Object o : drawers) { - - if (o instanceof PaletteDrawer) { - // check it does not have id: TestPaletteNodesDrawer - if (identifier.equals(((PaletteDrawer) o).getId())) { - if (!isVisible) { - fail("the drawer for test palette should not be here as the profile TestPalette is not applied"); - } - isDisplayed = true; - } - } - - } - if (isVisible & !isDisplayed) { - fail("the drawer for test palette was not there whereas the profile TestPalette is applied"); - } - } else { - fail("impossible to adapt into a papyrus editor"); - } - - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception { - } - - -}
\ No newline at end of file diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/regression/PaletteConfigurationTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/regression/PaletteConfigurationTest.java new file mode 100644 index 00000000000..3b0a336b7fe --- /dev/null +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/tests/regression/PaletteConfigurationTest.java @@ -0,0 +1,95 @@ +/***************************************************************************** + * Copyright (c) 2017 CEA LIST 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ +package org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.tests.regression; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import org.eclipse.gef.palette.PaletteContainer; +import org.eclipse.gef.palette.PaletteEntry; +import org.eclipse.gef.palette.ToolEntry; +import org.eclipse.gef.ui.palette.PaletteViewer; +import org.eclipse.papyrus.junit.framework.classification.tests.AbstractPapyrusTest; +import org.eclipse.papyrus.junit.utils.rules.PapyrusEditorFixture; +import org.eclipse.papyrus.junit.utils.rules.PluginResource; +import org.junit.Rule; +import org.junit.Test; + +import com.google.common.collect.Iterables; + +/** + * Test cases checking the load of palette. + */ +@PluginResource("resources/Model.di") +public class PaletteConfigurationTest extends AbstractPapyrusTest { + + /** + * The fixture. + */ + @Rule + public final PapyrusEditorFixture editorFixture = new PapyrusEditorFixture(); + + /** + * Constructor. + */ + public PaletteConfigurationTest() { + super(); + } + + /** + * Verify that tool from palette configuration models is well loaded. + */ + @Test + public void testPaletteConfigurationLoad() { + final String diagramTitle = "TestPalette"; //$NON-NLS-1$ + final String StoOnClassTool = "StoOnClass"; //$NON-NLS-1$ + final String FakeTool = "FakeTool"; //$NON-NLS-1$ + final String NoProfileCreationTool = "NoProfileCreationTool"; //$NON-NLS-1$ + + PaletteViewer palette = editorFixture.openDiagram(diagramTitle).getPalette(); + + // Test the stereotype on class tool + palette.setActiveTool(find(palette.getPaletteRoot(), StoOnClassTool, ToolEntry.class)); + editorFixture.flushDisplayEvents(); + assertThat(palette.getActiveTool().getLabel(), is(StoOnClassTool)); + + // Test the fake tool + palette.setActiveTool(find(palette.getPaletteRoot(), FakeTool, ToolEntry.class)); + editorFixture.flushDisplayEvents(); + assertThat(palette.getActiveTool().getLabel(), is(FakeTool)); + + // Test the NoProfileCreationTool + palette.setActiveTool(find(palette.getPaletteRoot(), NoProfileCreationTool, ToolEntry.class)); + editorFixture.flushDisplayEvents(); + assertThat(palette.getActiveTool().getLabel(), is(NoProfileCreationTool)); + } + + private <P extends PaletteEntry> P find(PaletteContainer container, String label, Class<P> type) { + P result = null; + + for (P next : Iterables.filter(container.getChildren(), type)) { + if (label.equalsIgnoreCase(next.getLabel())) { + result = next; + break; + } + } + if (null == result) { + for (PaletteContainer next : Iterables.filter(container.getChildren(), PaletteContainer.class)) { + result = find(next, label, type); + if (result != null) { + break; + } + } + } + return result; + } +} |