diff options
author | Tom Schindl | 2013-04-17 22:06:32 +0000 |
---|---|---|
committer | Tom Schindl | 2013-04-17 22:06:32 +0000 |
commit | 6c87534faf9ff8a57e86281e6f60eeba9626fc92 (patch) | |
tree | 9dc0108111a66d0b0ca262a1cbd4aeacfbeb4f03 /demos | |
parent | 97aa76572c2ffca453d4ac5692047d8e79d50e4f (diff) | |
download | org.eclipse.efxclipse-6c87534faf9ff8a57e86281e6f60eeba9626fc92.tar.gz org.eclipse.efxclipse-6c87534faf9ff8a57e86281e6f60eeba9626fc92.tar.xz org.eclipse.efxclipse-6c87534faf9ff8a57e86281e6f60eeba9626fc92.zip |
initial check in
Diffstat (limited to 'demos')
11 files changed, 207 insertions, 6 deletions
diff --git a/demos/org.eclipse.fx.demo.contacts.edit.tests/.classpath b/demos/org.eclipse.fx.demo.contacts.edit.tests/.classpath new file mode 100755 index 000000000..098194ca4 --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/.classpath @@ -0,0 +1,7 @@ +<?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.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/demos/org.eclipse.fx.demo.contacts.edit.tests/.gitignore b/demos/org.eclipse.fx.demo.contacts.edit.tests/.gitignore new file mode 100644 index 000000000..5e56e040e --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/demos/org.eclipse.fx.demo.contacts.edit.tests/.project b/demos/org.eclipse.fx.demo.contacts.edit.tests/.project new file mode 100755 index 000000000..a157909ed --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.fx.demo.contacts.edit.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/demos/org.eclipse.fx.demo.contacts.edit.tests/.settings/org.eclipse.jdt.core.prefs b/demos/org.eclipse.fx.demo.contacts.edit.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..f42de363a --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +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.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/demos/org.eclipse.fx.demo.contacts.edit.tests/META-INF/MANIFEST.MF b/demos/org.eclipse.fx.demo.contacts.edit.tests/META-INF/MANIFEST.MF new file mode 100755 index 000000000..fe822a5e4 --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/META-INF/MANIFEST.MF @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Contacts Edit Tests +Bundle-SymbolicName: org.eclipse.fx.demo.contacts.edit.tests +Bundle-Version: 1.0.0.qualifier +Fragment-Host: org.eclipse.fx.demo.contacts.edit +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Require-Bundle: org.junit diff --git a/demos/org.eclipse.fx.demo.contacts.edit.tests/build.properties b/demos/org.eclipse.fx.demo.contacts.edit.tests/build.properties new file mode 100755 index 000000000..34d2e4d2d --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/demos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/ContactItemProviderTest.java b/demos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/ContactItemProviderTest.java new file mode 100755 index 000000000..a5c37e6b5 --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/ContactItemProviderTest.java @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2013 TESIS DYNAware GmbH 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: + * Torsten Sommer <torsten.sommer@tesis.de> - initial API and implementation + */ +package org.eclipse.fx.demo.contacts.edit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.net.URL; +import java.util.List; + +import org.eclipse.emf.edit.provider.ComposedImage; +import org.eclipse.fx.demo.contacts.Contact; +import org.eclipse.fx.demo.contacts.ContactsFactory; +import org.eclipse.fx.demo.contacts.provider.ContactItemProvider; +import org.eclipse.fx.demo.contacts.provider.ContactsItemProviderAdapterFactory; +import org.junit.Before; +import org.junit.Test; + +public class ContactItemProviderTest { + + static final String FIRST_NAME = "Hans"; + static final String LAST_NAME = "Wurst"; + Contact contact; + ContactItemProvider contactItemProvider; + + @Before + public void setUp() { + ContactsItemProviderAdapterFactory adapterFactory = new ContactsItemProviderAdapterFactory(); + contactItemProvider = new ContactItemProvider(adapterFactory); + contact = ContactsFactory.eINSTANCE.createContact(); + } + + @Test + public void getTextWithValidName() { + contact.setFirstName(FIRST_NAME); + contact.setLastName(LAST_NAME); + String text = contactItemProvider.getText(contact); + assertEquals("Text should be '<first name> <last name>' if set", FIRST_NAME + " " + LAST_NAME, text); + } + + @Test + public void getTextWithNullName() { + String text = contactItemProvider.getText(contact); + assertEquals(" ", text); + } + + @Test + public void getImageWithValidName() { + contact.setFirstName(FIRST_NAME); + contact.setLastName(LAST_NAME); + Object image = contactItemProvider.getImage(contact); + assertTrue("Image should be a URL", image instanceof URL); + URL imageURL = (URL) image; + assertTrue("Contacts should have a user icon", imageURL.getFile().endsWith("user.png")); + } + + @Test + public void getImageWithNullName() { + Object image = contactItemProvider.getImage(contact); + assertTrue("Image should be a URL", image instanceof ComposedImage); + ComposedImage composedImage = (ComposedImage) image; + List<Object> images = composedImage.getImages(); + assertEquals(2, images.size()); + + // check the base image + Object baseImage = images.get(0); + assertTrue("Image should be a URL", baseImage instanceof URL); + URL baseImageURL = (URL) baseImage; + assertTrue("Base image should be a contact icon", baseImageURL.getFile().endsWith("user.png")); + + // check the overlay + Object overlayImage = images.get(1); + assertTrue("Overlay image should be a URL", overlayImage instanceof URL); + URL overlayImageURL = (URL) overlayImage; + assertTrue("Overlay image should be an error bullet", overlayImageURL.getFile().endsWith("bullet_error.png")); + } + +} diff --git a/demos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/GroupItemProviderTest.java b/demos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/GroupItemProviderTest.java new file mode 100755 index 000000000..9388b859f --- /dev/null +++ b/demos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/GroupItemProviderTest.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2013 TESIS DYNAware GmbH 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: + * Torsten Sommer <torsten.sommer@tesis.de> - initial API and implementation + */ +package org.eclipse.fx.demo.contacts.edit; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.net.URL; + +import org.eclipse.fx.demo.contacts.ContactsFactory; +import org.eclipse.fx.demo.contacts.Group; +import org.eclipse.fx.demo.contacts.provider.ContactsItemProviderAdapterFactory; +import org.eclipse.fx.demo.contacts.provider.GroupItemProvider; +import org.junit.Before; +import org.junit.Test; + +public class GroupItemProviderTest { + + static final String GROUP_NAME = "Dummy Group"; + Group group; + GroupItemProvider groupItemProvider; + + @Before + public void setUp() { + ContactsItemProviderAdapterFactory adapterFactory = new ContactsItemProviderAdapterFactory(); + groupItemProvider = new GroupItemProvider(adapterFactory); + group = ContactsFactory.eINSTANCE.createGroup(); + } + + @Test + public void getTextWithValidName() { + group.setName(GROUP_NAME); + String text = groupItemProvider.getText(group); + assertEquals("Text should be the name if set", GROUP_NAME, text); + } + + @Test + public void getTextWithNullName() { + group.setName(null); + String text = groupItemProvider.getText(group); + assertEquals("Text should be '?' if the name is null", "?", text); + } + + @Test + public void getImage() { + Object image = groupItemProvider.getImage(group); + assertTrue("Image should be a URL", image instanceof URL); + URL imageURL = (URL) image; + assertTrue("Groups should have a folder icon", imageURL.getFile().endsWith("folder.png")); + } + +} diff --git a/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactItemProvider.java b/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactItemProvider.java index 4be68582c..07c83f9ab 100755 --- a/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactItemProvider.java +++ b/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactItemProvider.java @@ -36,7 +36,7 @@ import org.eclipse.fx.demo.contacts.Contact; import org.eclipse.fx.demo.contacts.ContactsPackage;
/**
- * This is the item provider adapter for a {@link at.bestsolution.efxclipse.runtime.demo.contacts.Contact} object.
+ * This is the item provider adapter for a {@link org.eclipse.fx.demo.contacts.Contact} object.
* <!-- begin-user-doc -->
* @implements ITableItemLabelProvider
* <!-- end-user-doc -->
diff --git a/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactsItemProviderAdapterFactory.java b/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactsItemProviderAdapterFactory.java index 744f1d915..90382ff8c 100755 --- a/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactsItemProviderAdapterFactory.java +++ b/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/ContactsItemProviderAdapterFactory.java @@ -82,7 +82,7 @@ public class ContactsItemProviderAdapterFactory extends ContactsAdapterFactory i }
/**
- * This keeps track of the one adapter used for all {@link at.bestsolution.efxclipse.runtime.demo.contacts.Contact} instances.
+ * This keeps track of the one adapter used for all {@link org.eclipse.fx.demo.contacts.Contact} instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -90,7 +90,7 @@ public class ContactsItemProviderAdapterFactory extends ContactsAdapterFactory i protected ContactItemProvider contactItemProvider;
/**
- * This creates an adapter for a {@link at.bestsolution.efxclipse.runtime.demo.contacts.Contact}.
+ * This creates an adapter for a {@link org.eclipse.fx.demo.contacts.Contact}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -105,7 +105,7 @@ public class ContactsItemProviderAdapterFactory extends ContactsAdapterFactory i }
/**
- * This keeps track of the one adapter used for all {@link at.bestsolution.efxclipse.runtime.demo.contacts.Group} instances.
+ * This keeps track of the one adapter used for all {@link org.eclipse.fx.demo.contacts.Group} instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -113,7 +113,7 @@ public class ContactsItemProviderAdapterFactory extends ContactsAdapterFactory i protected GroupItemProvider groupItemProvider;
/**
- * This creates an adapter for a {@link at.bestsolution.efxclipse.runtime.demo.contacts.Group}.
+ * This creates an adapter for a {@link org.eclipse.fx.demo.contacts.Group}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
diff --git a/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/GroupItemProvider.java b/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/GroupItemProvider.java index 4578b1490..92550c8eb 100755 --- a/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/GroupItemProvider.java +++ b/demos/org.eclipse.fx.demo.contacts.edit/src/org/eclipse/fx/demo/contacts/provider/GroupItemProvider.java @@ -33,7 +33,7 @@ import org.eclipse.fx.demo.contacts.ContactsPackage; import org.eclipse.fx.demo.contacts.Group;
/**
- * This is the item provider adapter for a {@link at.bestsolution.efxclipse.runtime.demo.contacts.Group} object.
+ * This is the item provider adapter for a {@link org.eclipse.fx.demo.contacts.Group} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
|