Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-04-17 18:06:32 -0400
committerTom Schindl2013-04-17 18:06:32 -0400
commit6c87534faf9ff8a57e86281e6f60eeba9626fc92 (patch)
tree9dc0108111a66d0b0ca262a1cbd4aeacfbeb4f03 /demos/org.eclipse.fx.demo.contacts.edit.tests
parent97aa76572c2ffca453d4ac5692047d8e79d50e4f (diff)
downloadorg.eclipse.efxclipse-6c87534faf9ff8a57e86281e6f60eeba9626fc92.tar.gz
org.eclipse.efxclipse-6c87534faf9ff8a57e86281e6f60eeba9626fc92.tar.xz
org.eclipse.efxclipse-6c87534faf9ff8a57e86281e6f60eeba9626fc92.zip
initial check in
Diffstat (limited to 'demos/org.eclipse.fx.demo.contacts.edit.tests')
-rwxr-xr-xdemos/org.eclipse.fx.demo.contacts.edit.tests/.classpath7
-rw-r--r--demos/org.eclipse.fx.demo.contacts.edit.tests/.gitignore1
-rwxr-xr-xdemos/org.eclipse.fx.demo.contacts.edit.tests/.project28
-rw-r--r--demos/org.eclipse.fx.demo.contacts.edit.tests/.settings/org.eclipse.jdt.core.prefs7
-rwxr-xr-xdemos/org.eclipse.fx.demo.contacts.edit.tests/META-INF/MANIFEST.MF8
-rwxr-xr-xdemos/org.eclipse.fx.demo.contacts.edit.tests/build.properties4
-rwxr-xr-xdemos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/ContactItemProviderTest.java86
-rwxr-xr-xdemos/org.eclipse.fx.demo.contacts.edit.tests/src/org/eclipse/fx/demo/contacts/edit/GroupItemProviderTest.java60
8 files changed, 201 insertions, 0 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"));
+ }
+
+}

Back to the top