Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-04-19 10:33:59 +0000
committerTom Schindl2013-04-19 10:33:59 +0000
commit0ae35adfbf0f45a3af2c5e64f927a14512b377aa (patch)
treeaed7966be126dd5c1484817e481bc38ff35573f0
parentd3352e32cbd46a4696c6be1033f4ece0201662a0 (diff)
downloadorg.eclipse.efxclipse-0ae35adfbf0f45a3af2c5e64f927a14512b377aa.tar.gz
org.eclipse.efxclipse-0ae35adfbf0f45a3af2c5e64f927a14512b377aa.tar.xz
org.eclipse.efxclipse-0ae35adfbf0f45a3af2c5e64f927a14512b377aa.zip
initial checkin
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.classpath7
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.gitignore2
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.project28
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/META-INF/MANIFEST.MF41
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/build.properties4
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AbstractAdapterFactoryCellFactoryTest.java116
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryCellFactoryTest.java255
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryListCellFactoryTest.java98
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableListTest.java338
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactoryTest.java149
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactoryTest.java99
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeItemTest.java63
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/LocalTransferTest.java17
-rwxr-xr-xbundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/ProxyCellValueFactoryTest.java35
14 files changed, 1252 insertions, 0 deletions
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.classpath b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.classpath
new file mode 100755
index 000000000..098194ca4
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.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/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.gitignore b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.gitignore
new file mode 100755
index 000000000..249a49ea0
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.gitignore
@@ -0,0 +1,2 @@
+/.settings
+/bin
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.project b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.project
new file mode 100755
index 000000000..fb8181796
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.fx.emf.edit.ui.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/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/META-INF/MANIFEST.MF b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/META-INF/MANIFEST.MF
new file mode 100755
index 000000000..42400ea12
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,41 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: EMF Edit UI for JavaFX Tests
+Bundle-SymbolicName: org.eclipse.fx.emf.edit.ui.tests
+Bundle-Version: 1.0.0.qualifier
+Fragment-Host: org.eclipse.fx.emf.edit.ui;bundle-version="0.1.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Require-Bundle: org.junit4;bundle-version="4.8.1",
+ org.mockito;bundle-version="1.8.4"
+Import-Package: javafx.animation;version="2.2.0",
+ javafx.application;version="2.2.0",
+ javafx.beans;version="2.2.0",
+ javafx.beans.binding;version="2.2.0",
+ javafx.beans.property;version="2.2.0",
+ javafx.beans.property.adapter;version="2.2.0",
+ javafx.beans.value;version="2.2.0",
+ javafx.collections,
+ javafx.concurrent;version="2.2.0",
+ javafx.embed.swing;version="2.2.0",
+ javafx.embed.swt;version="2.2.0",
+ javafx.event;version="2.2.0",
+ javafx.fxml;version="2.2.0",
+ javafx.geometry;version="2.2.0",
+ javafx.scene;version="2.2.0",
+ javafx.scene.canvas;version="2.2.0",
+ javafx.scene.chart;version="2.2.0",
+ javafx.scene.control;version="2.2.0",
+ javafx.scene.control.cell;version="2.2.0",
+ javafx.scene.effect;version="2.2.0",
+ javafx.scene.image;version="2.2.0",
+ javafx.scene.input;version="2.2.0",
+ javafx.scene.layout;version="2.2.0",
+ javafx.scene.media;version="2.2.0",
+ javafx.scene.paint;version="2.2.0",
+ javafx.scene.shape;version="2.2.0",
+ javafx.scene.text;version="2.2.0",
+ javafx.scene.transform;version="2.2.0",
+ javafx.scene.web;version="2.2.0",
+ javafx.stage;version="2.2.0",
+ javafx.util;version="2.2.0",
+ javafx.util.converter;version="2.2.0"
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/build.properties b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/build.properties
new file mode 100755
index 000000000..34d2e4d2d
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AbstractAdapterFactoryCellFactoryTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AbstractAdapterFactoryCellFactoryTest.java
new file mode 100755
index 000000000..783e876a6
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AbstractAdapterFactoryCellFactoryTest.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Method;
+
+import javafx.scene.control.Cell;
+import javafx.scene.paint.Color;
+import javafx.scene.text.Font;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.EList;
+import org.mockito.ArgumentCaptor;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+/**
+ * This class provides a test bench and helper methods for
+ * {@link AdapterFactoryCellFactory} tests
+ */
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public abstract class AbstractAdapterFactoryCellFactoryTest {
+
+ AdapterFactory adapterFactory;
+ Adapter adapter1;
+ Adapter adapter2;
+ ArgumentCaptor<Object> itemCaptor;
+ ArgumentCaptor<Cell> cellCaptor;
+ ArgumentCaptor<AdapterFactory> adapterFactoryCaptor;
+ Notifier item1;
+ Notifier item2;
+ EList<Adapter> adapterList1;
+ EList<Adapter> adapterList2;
+ Object foregroundObject;
+ Object backgroundObject;
+ Color foregroundColor;
+ Color backgroundColor;
+ String backgroundCss;
+ Object fontObject;
+ Font font;
+
+ void createTestBench() {
+ adapterFactory = mock(AdapterFactory.class);
+ itemCaptor = ArgumentCaptor.forClass(Object.class);
+ cellCaptor = ArgumentCaptor.forClass(Cell.class);
+ adapterFactoryCaptor = ArgumentCaptor.forClass(AdapterFactory.class);
+
+ item1 = mock(Notifier.class);
+ adapterList1 = mock(EList.class);
+ when(item1.eAdapters()).thenReturn(adapterList1);
+ when(adapterList1.add(any(Adapter.class))).thenAnswer(new Answer() {
+
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ adapter1 = (Adapter) invocation.getArguments()[0];
+ return null;
+ }
+
+ });
+
+ item2 = mock(Notifier.class);
+ adapterList2 = mock(EList.class);
+ when(item2.eAdapters()).thenReturn(adapterList2);
+ when(adapterList2.add(any(Adapter.class))).thenAnswer(new Answer() {
+
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ adapter2 = (Adapter) invocation.getArguments()[0];
+ return null;
+ }
+
+ });
+
+ foregroundObject = mock(Object.class);
+ foregroundColor = mock(Color.class);
+
+ backgroundObject = mock(Object.class);
+ backgroundColor = mock(Color.class);
+
+ backgroundCss = "rgb(0, 255, 0)";
+
+ fontObject = mock(Object.class);
+ font = Font.getDefault();
+ }
+
+ void stubHelperMethods(AdapterFactoryCellFactory cellFactory) {
+ when(cellFactory.colorFromObject(foregroundObject)).thenReturn(foregroundColor);
+ when(cellFactory.colorFromObject(backgroundObject)).thenReturn(backgroundColor);
+ when(cellFactory.cssColorFromObject(backgroundObject)).thenReturn(backgroundCss);
+ when(cellFactory.fontFromObject(fontObject)).thenReturn(font);
+ }
+
+ /**
+ * Helper method to call protected method {@link Cell#updateItem}
+ */
+ static void invokeUpdateItem(Cell<?> cell, Object item, boolean empty) throws Exception {
+ Method updateItem = Cell.class.getDeclaredMethod("updateItem", Object.class, boolean.class);
+ updateItem.setAccessible(true);
+ updateItem.invoke(cell, item, empty);
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryCellFactoryTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryCellFactoryTest.java
new file mode 100755
index 000000000..e384edcff
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryCellFactoryTest.java
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javafx.scene.Node;
+import javafx.scene.control.Cell;
+import javafx.scene.image.ImageView;
+import javafx.scene.paint.Color;
+import javafx.scene.text.Font;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.edit.provider.IItemColorProvider;
+import org.eclipse.emf.edit.provider.IItemFontProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellCreationListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellUpdateListener;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AdapterFactoryCellFactoryTest {
+
+ AdapterFactory adapterFactory;
+ AdapterFactoryCellFactory cellFactory;
+
+ @Before
+ public void setUp() {
+ adapterFactory = mock(AdapterFactory.class);
+ cellFactory = spy(new AdapterFactoryCellFactory(adapterFactory) {
+ });
+ }
+
+ @Test
+ public void getAdapterFactory() {
+ assertEquals(adapterFactory, cellFactory.getAdapterFactory());
+ }
+
+ @Test
+ public void addAndRemoveCellCreationListener() {
+ ICellCreationListener listener = mock(ICellCreationListener.class);
+ cellFactory.addCellCreationListener(listener);
+ assertEquals(listener, cellFactory.cellCreationListeners.get(0));
+
+ cellFactory.removeCellCreationListener(listener);
+ assertTrue(cellFactory.cellCreationListeners.isEmpty());
+ }
+
+ @Test
+ public void addAndRemoveCellUpdateListener() {
+ ICellUpdateListener listener = mock(ICellUpdateListener.class);
+ cellFactory.addCellUpdateListener(listener);
+ assertEquals(listener, cellFactory.cellUpdateListeners.get(0));
+
+ cellFactory.removeCellUpdateListener(listener);
+ assertTrue(cellFactory.cellUpdateListeners.isEmpty());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void constructorWithNullAdapterFactory() {
+ new AdapterFactoryCellFactory(null) {
+ };
+ }
+
+ @Test
+ public void fontFromObjectWithNonURI() {
+ cellFactory.fontFromObject(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void fontFromObjectWithIllegalScheme() {
+ URI uri = URI.createURI("http://Arial/8/bold");
+ cellFactory.fontFromObject(uri);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void fontFromObjectWithoutSegments() {
+ URI uri = URI.createURI("font://");
+ cellFactory.fontFromObject(uri);
+ }
+
+ @Test
+ public void fontFromObjectWithoutFontName() {
+ URI uri = URI.createURI("font:///8/");
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals(8, font.getSize(), 0);
+ }
+
+ @Test
+ public void fontFromObjectWithPositiveHeightDelta() {
+ URI uri = URI.createURI("font://Arial/+1/");
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals(Font.getDefault().getSize() + 1, font.getSize(), 0);
+ }
+
+ @Test
+ public void fontFromObjectWithNegativeHeightDelta() {
+ URI uri = URI.createURI("font://Arial/-2/");
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals(Font.getDefault().getSize() - 2, font.getSize(), 0);
+ }
+
+ @Test
+ public void fontFromObjectWithoutHeight() {
+ URI uri = URI.createURI("font://Arial//");
+ cellFactory.fontFromObject(uri);
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals("Arial", font.getName());
+ }
+
+ @Test
+ public void fontFromObjectBold() {
+ URI uri = URI.createURI("font://Arial/8/bold");
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals("Arial Bold", font.getName());
+ assertEquals(8, font.getSize(), 0);
+ }
+
+ @Test
+ public void fontFromObjectItalic() {
+ URI uri = URI.createURI("font://Arial/8/italic");
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals("Arial Italic", font.getName());
+ assertEquals(8, font.getSize(), 0);
+ }
+
+ @Test
+ public void fontFromObjectBoldAndItalic() {
+ URI uri = URI.createURI("font://Arial/8/bold+italic");
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals("Arial Bold Italic", font.getName());
+ assertEquals(8, font.getSize(), 0);
+ }
+
+ @Test
+ public void fontFromObjectItalicAndBold() {
+ URI uri = URI.createURI("font://Arial/8/italic+bold");
+ Font font = cellFactory.fontFromObject(uri);
+ assertEquals("Arial Bold Italic", font.getName());
+ assertEquals(8, font.getSize(), 0);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void colorFromObjectWithIllegalScheme() {
+ URI uri = URI.createURI("http://");
+ cellFactory.colorFromObject(uri);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void colorFromObjectWithIllegalAuthority() {
+ URI uri = URI.createURI("color://hsb");
+ cellFactory.colorFromObject(uri);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void colorFromObjectWithIllegalSegmentCount() {
+ URI uri = URI.createURI("color://rgb/120/100");
+ cellFactory.colorFromObject(uri);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void colorFromObjectWithIllegalNumberFormat() {
+ URI uri = URI.createURI("color://rgb/100/XXX/0");
+ Color color = cellFactory.colorFromObject(uri);
+ assertEquals(Color.rgb(100, 200, 0), color);
+ }
+
+ @Test
+ public void colorFromObjectValidURI() {
+ URI uri = URI.createURI("color://rgb/100/200/0");
+ Color color = cellFactory.colorFromObject(uri);
+ assertEquals(Color.rgb(100, 200, 0), color);
+ }
+
+ @Test
+ public void cssColorFromObjectValidURI() {
+ URI uri = URI.createURI("color://rgb/100/200/0");
+ String color = cellFactory.cssColorFromObject(uri);
+ assertEquals("rgb(100, 200, 0)", color);
+ }
+
+ @Test
+ public void applyItemProviderFont() {
+ IItemFontProvider fontProvider = mock(IItemFontProvider.class);
+ Object item = new Object();
+ URI fontURI = URI.createURI("font://Arial/8/");
+ Font font = new Font(8);
+ when(fontProvider.getFont(item)).thenReturn(fontURI);
+ when(adapterFactory.adapt(item, IItemFontProvider.class)).thenReturn(fontProvider);
+ when(cellFactory.fontFromObject(fontURI)).thenReturn(font);
+ Cell<?> cell = new Cell<>();
+ cellFactory.applyItemProviderFont(item, cell, adapterFactory);
+ }
+
+ @Test
+ public void applyItemProviderLabel() {
+ IItemLabelProvider labelProvider = mock(IItemLabelProvider.class);
+ Object item = new Object();
+ String text = "";
+ URI imageURI = URI.createURI("");
+ when(labelProvider.getText(item)).thenReturn(text);
+ when(labelProvider.getImage(item)).thenReturn(imageURI);
+ ImageView graphic = new ImageView();
+ when(cellFactory.graphicFromObject(imageURI)).thenReturn(graphic);
+ when(adapterFactory.adapt(item, IItemLabelProvider.class)).thenReturn(labelProvider);
+
+ Cell<?> cell = new Cell<>();
+ cellFactory.applyItemProviderLabel(item, cell, adapterFactory);
+
+ assertEquals(text, cell.getText());
+ assertEquals(graphic, cell.getGraphic());
+ }
+
+ @Test
+ public void applyItemProviderColor() {
+ IItemColorProvider colorProvider = mock(IItemColorProvider.class);
+ Object item = new Object();
+ URI foregroundColorURI = URI.createURI("color://rgb/255/0/0");
+ URI backgroundColorURI = URI.createURI("color://rgb/0/255/0");
+ when(colorProvider.getForeground(item)).thenReturn(foregroundColorURI);
+ when(colorProvider.getBackground(item)).thenReturn(backgroundColorURI);
+ when(adapterFactory.adapt(item, IItemColorProvider.class)).thenReturn(colorProvider);
+
+ Cell<?> cell = new Cell<>();
+ cellFactory.applyItemProviderColor(item, cell, adapterFactory);
+
+ assertEquals(Color.rgb(255, 0, 0), cell.getTextFill());
+ assertEquals("-fx-background-color: rgb(0, 255, 0)", cell.getStyle());
+ }
+
+ @Test
+ public void imageFromObject() throws MalformedURLException {
+ URL imageURL = new URL("http://domain.com/image.jpg");
+ Node image = cellFactory.graphicFromObject(imageURL);
+ assertNotNull(image);
+ }
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryListCellFactoryTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryListCellFactoryTest.java
new file mode 100755
index 000000000..1c7bdcd93
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryListCellFactoryTest.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import javafx.scene.control.Cell;
+import javafx.scene.control.ListCell;
+import javafx.scene.control.ListView;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellCreationListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellUpdateListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryListCellFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class AdapterFactoryListCellFactoryTest extends AbstractAdapterFactoryCellFactoryTest {
+
+ AdapterFactoryListCellFactory cellFactory;
+
+ @Before
+ public void setUp() {
+ createTestBench();
+ cellFactory = spy(new AdapterFactoryListCellFactory(adapterFactory));
+ stubHelperMethods(cellFactory);
+
+ }
+
+ @Test
+ public void call() {
+ cellFactory.call(null);
+ }
+
+ @Test
+ public void cellCreationNotification() {
+ ICellCreationListener listener = mock(ICellCreationListener.class);
+ cellFactory.addCellCreationListener(listener);
+ cellFactory.call(null);
+ verify(listener).cellCreated((Cell<?>) any());
+ }
+
+ @Test
+ public void updateItem() throws Exception {
+ ICellUpdateListener listener = mock(ICellUpdateListener.class);
+ cellFactory.addCellUpdateListener(listener);
+ ListView<Object> listView = new ListView<>();
+ ListCell<Object> listCell = cellFactory.call(listView);
+
+ // update the cell
+ invokeUpdateItem(listCell, item1, false);
+
+ assertNotNull("No adapter was added", adapter1);
+
+ verify(cellFactory, times(1)).applyItemProviderStyle(itemCaptor.capture(), cellCaptor.capture(), adapterFactoryCaptor.capture());
+ assertEquals(item1, itemCaptor.getValue());
+ assertEquals(listCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+
+ // update the cell again
+ invokeUpdateItem(listCell, item2, false);
+
+ verify(adapterList1).remove(adapter1);
+
+ assertNotNull("No adapter was added", adapter2);
+
+ verify(cellFactory, times(2)).applyItemProviderStyle(itemCaptor.capture(), cellCaptor.capture(), adapterFactoryCaptor.capture());
+ assertEquals(item2, itemCaptor.getValue());
+ assertEquals(listCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+
+ // notify the adapter
+ Notification notification = mock(Notification.class);
+ when(notification.getNotifier()).thenReturn(item2);
+ adapter2.notifyChanged(notification);
+
+ verify(cellFactory, times(3)).applyItemProviderStyle(itemCaptor.capture(), cellCaptor.capture(), adapterFactoryCaptor.capture());
+ assertEquals(item2, itemCaptor.getValue());
+ assertEquals(listCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableListTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableListTest.java
new file mode 100755
index 000000000..f6bc76a3c
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryObservableListTest.java
@@ -0,0 +1,338 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import javafx.beans.InvalidationListener;
+import javafx.collections.ListChangeListener;
+import javafx.collections.ObservableList;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.edit.provider.IChangeNotifier;
+import org.eclipse.emf.edit.provider.INotifyChangedListener;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemProvider;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryObservableList;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class AdapterFactoryObservableListTest {
+
+ final static int DUMMY_INDEX = 0;
+ final static int DUMMY_SIZE = 10;
+ final static List<Object> DUMMY_LIST = Collections.emptyList();
+ final static Object DUMMY_OBJECT = new Object();
+ final static Object[] DUMMY_ARRAY = new Object[0];
+ final static Iterator<Object> DUMMY_ITERATOR = mock(Iterator.class);
+ final static ListIterator<Object> DUMMY_LIST_ITERATOR = mock(ListIterator.class);
+ final static ListIterator<Object> DUMMY_LIST_ITERATOR_WITH_INDEX = mock(ListIterator.class);
+ final static ListChangeListener DUMMY_LIST_CHANGE_LISTENER = mock(ListChangeListener.class);
+ final static InvalidationListener DUMMY_INVALIDATION_LISTENER = mock(InvalidationListener.class);
+
+ AdapterFactoryObservableList list;
+ ObservableList<Object> elements;
+ AdapterFactoryImpl adapterFactory;
+
+ @Before
+ public void setUp() {
+ elements = mock(ObservableList.class);
+ when(elements.lastIndexOf(DUMMY_OBJECT)).thenReturn(DUMMY_INDEX);
+ when(elements.iterator()).thenReturn(DUMMY_ITERATOR);
+ when(elements.listIterator()).thenReturn(DUMMY_LIST_ITERATOR);
+ when(elements.listIterator(DUMMY_INDEX)).thenReturn(
+ DUMMY_LIST_ITERATOR_WITH_INDEX);
+ when(elements.size()).thenReturn(DUMMY_SIZE);
+ when(elements.subList(DUMMY_INDEX, DUMMY_INDEX)).thenReturn(DUMMY_LIST);
+ when(elements.toArray()).thenReturn(DUMMY_ARRAY);
+ when(elements.toArray(DUMMY_ARRAY)).thenReturn(DUMMY_ARRAY);
+ adapterFactory = new AdapterFactoryImpl();
+ ItemProvider root = new ItemProvider();
+ list = new AdapterFactoryObservableList(adapterFactory, root);
+ list.elements = elements;
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void constructorWithNullAdapterFactory() {
+ new AdapterFactoryObservableList(null, DUMMY_OBJECT);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void constructorWithNonAdaptableRoot() {
+ new AdapterFactoryObservableList(adapterFactory, DUMMY_OBJECT);
+ }
+
+ Adapter adapter;
+
+ @Test
+ public void constructorWithNotifierRoot() {
+ Notifier notifier = mock(Notifier.class);
+ EList adapterList = mock(EList.class);
+ when(notifier.eAdapters()).thenReturn(adapterList);
+ when(adapterList.add(any())).thenAnswer(new Answer() {
+
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ adapter = (Adapter) invocation.getArguments()[0];
+ return null;
+ }
+
+ });
+ AdapterFactory adapterFactory = mock(AdapterFactory.class);
+ IStructuredItemContentProvider contentProvider = mock(IStructuredItemContentProvider.class);
+ when(adapterFactory.adapt(any(), any())).thenReturn(contentProvider);
+ AdapterFactoryObservableList observableList = new AdapterFactoryObservableList(
+ adapterFactory, notifier);
+ observableList.elements = elements;
+
+ // make sure that notification are forwarded
+ adapter.notifyChanged(mock(Notification.class));
+ verify(elements).setAll(any(Collection.class));
+ }
+
+ INotifyChangedListener changeListener;
+
+ @Test
+ public void constructorWithIChangeNotifierRoot() {
+ ItemProvider itemProvider = mock(ItemProvider.class);
+ doAnswer(new Answer() {
+
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ changeListener = (INotifyChangedListener) invocation
+ .getArguments()[0];
+ return null;
+ }
+ }).when(itemProvider).addListener(
+ (INotifyChangedListener) any(IChangeNotifier.class));
+
+ AdapterFactoryObservableList observableList = new AdapterFactoryObservableList(
+ adapterFactory, itemProvider);
+ observableList.elements = elements;
+
+ verify(itemProvider).addListener(any(INotifyChangedListener.class));
+
+ // make sure that notification are forwarded
+ changeListener.notifyChanged(mock(Notification.class));
+ verify(elements).setAll(any(Collection.class));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addWidthObject() {
+ list.add(DUMMY_OBJECT);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addWidthIndexAndObject() {
+ list.add(DUMMY_INDEX, DUMMY_OBJECT);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addAllWithCollection() {
+ list.addAll(DUMMY_LIST);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addAllWithIndexAndCollection() {
+ list.addAll(DUMMY_INDEX, DUMMY_LIST);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void addAllWithArray() {
+ list.addAll(DUMMY_OBJECT);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void clear() {
+ list.clear();
+ }
+
+ @Test
+ public void contains() {
+ list.contains(DUMMY_OBJECT);
+ verify(elements).contains(DUMMY_OBJECT);
+ }
+
+ @Test
+ public void containsAll() {
+ list.containsAll(DUMMY_LIST);
+ verify(elements).containsAll(DUMMY_LIST);
+ }
+
+ @Test
+ public void get() {
+ list.get(DUMMY_INDEX);
+ verify(elements).get(DUMMY_INDEX);
+ }
+
+ @Test
+ public void indexOf() {
+ list.indexOf(DUMMY_OBJECT);
+ verify(elements).indexOf(DUMMY_OBJECT);
+ }
+
+ @Test
+ public void isEmpty() {
+ list.isEmpty();
+ verify(elements).isEmpty();
+ }
+
+ @Test
+ public void iterator() {
+ Iterator<Object> iterator = list.iterator();
+ verify(elements).iterator();
+ assertEquals(DUMMY_ITERATOR, iterator);
+ }
+
+ @Test
+ public void lastIndexOf() {
+ int index = list.lastIndexOf(DUMMY_OBJECT);
+ verify(elements).lastIndexOf(DUMMY_OBJECT);
+ assertEquals(DUMMY_INDEX, index);
+ }
+
+ @Test
+ public void listIterator() {
+ ListIterator<Object> listIterator = list.listIterator();
+ verify(elements).listIterator();
+ assertEquals(DUMMY_LIST_ITERATOR, listIterator);
+ }
+
+ @Test
+ public void listIteratorWithIndex() {
+ ListIterator<Object> listIterator = list.listIterator(DUMMY_INDEX);
+ verify(elements).listIterator(DUMMY_INDEX);
+ assertEquals(DUMMY_LIST_ITERATOR_WITH_INDEX, listIterator);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void removeWidthObject() {
+ list.remove(DUMMY_OBJECT);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void removeWithIndex() {
+ list.remove(DUMMY_INDEX);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void removeWithFromAndToIndex() {
+ list.remove(DUMMY_INDEX, DUMMY_INDEX);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void removeAllWithCollection() {
+ list.removeAll(DUMMY_LIST);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void removeAllWithObject() {
+ list.removeAll(DUMMY_OBJECT);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void retainAllWithCollection() {
+ list.retainAll(DUMMY_LIST);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void retainAllWithObject() {
+ list.retainAll(DUMMY_OBJECT);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void set() {
+ list.set(DUMMY_INDEX, DUMMY_OBJECT);
+ }
+
+ @Test
+ public void size() {
+ int size = list.size();
+ verify(elements).size();
+ assertEquals(DUMMY_SIZE, size);
+ }
+
+ @Test
+ public void subList() {
+ List<Object> subList = list.subList(DUMMY_INDEX, DUMMY_INDEX);
+ verify(elements).subList(DUMMY_INDEX, DUMMY_INDEX);
+ assertEquals(DUMMY_LIST, subList);
+ }
+
+ @Test
+ public void toArray() {
+ Object[] array = list.toArray();
+ verify(elements).toArray();
+ assertArrayEquals(DUMMY_ARRAY, array);
+ }
+
+ @Test
+ public void toArrayWithArray() {
+ Object[] array = list.toArray(DUMMY_ARRAY);
+ verify(elements).toArray(DUMMY_ARRAY);
+ assertArrayEquals(DUMMY_ARRAY, array);
+ }
+
+ @Test
+ public void addListenerWithInvalidationListener() {
+ list.addListener(DUMMY_INVALIDATION_LISTENER);
+ verify(elements).addListener(DUMMY_INVALIDATION_LISTENER);
+ }
+
+ @Test
+ public void addListenerWithListChangeListener() {
+ list.addListener(DUMMY_LIST_CHANGE_LISTENER);
+ verify(elements).addListener(DUMMY_LIST_CHANGE_LISTENER);
+ }
+
+ @Test
+ public void removeListenerWithInvalidationListener() {
+ list.removeListener(DUMMY_INVALIDATION_LISTENER);
+ verify(elements).removeListener(DUMMY_INVALIDATION_LISTENER);
+ }
+
+ @Test
+ public void removeListenerWithListChangeListener() {
+ list.removeListener(DUMMY_LIST_CHANGE_LISTENER);
+ verify(elements).removeListener(DUMMY_LIST_CHANGE_LISTENER);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void setAllWithCollection() {
+ list.setAll(DUMMY_LIST);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void setAllWithObject() {
+ list.setAll(DUMMY_OBJECT);
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactoryTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactoryTest.java
new file mode 100755
index 000000000..df61a12f3
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTableCellFactoryTest.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javafx.scene.control.Cell;
+import javafx.scene.control.TableCell;
+import javafx.scene.control.TableColumn;
+import javafx.scene.image.ImageView;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.edit.provider.ITableItemColorProvider;
+import org.eclipse.emf.edit.provider.ITableItemFontProvider;
+import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellCreationListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellUpdateListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryTableCellFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+@SuppressWarnings("rawtypes")
+public class AdapterFactoryTableCellFactoryTest extends AbstractAdapterFactoryCellFactoryTest {
+
+ private static final Integer COLUMN_INDEX = new Integer(1);
+ AdapterFactoryTableCellFactory cellFactory;
+ ArgumentCaptor<Integer> columnIndexCaptor;
+
+ @Before
+ public void setUp() {
+ createTestBench();
+ cellFactory = spy(new AdapterFactoryTableCellFactory(adapterFactory, COLUMN_INDEX));
+ stubHelperMethods(cellFactory);
+ columnIndexCaptor = ArgumentCaptor.forClass(Integer.class);
+ }
+
+ @Test
+ public void cellCreationNotification() {
+ ICellCreationListener listener = mock(ICellCreationListener.class);
+ cellFactory.addCellCreationListener(listener);
+ cellFactory.call(null);
+ verify(listener).cellCreated((Cell<?>) any());
+ }
+
+ @Test
+ public void updateItem() throws Exception {
+ ICellUpdateListener listener = mock(ICellUpdateListener.class);
+ cellFactory.addCellUpdateListener(listener);
+ TableColumn<Object, Object> listView = new TableColumn<Object, Object>();
+ TableCell<Object, Object> tableCell = cellFactory.call(listView);
+
+ // update the cell
+ invokeUpdateItem(tableCell, item1, false);
+
+ assertNotNull("No adapter was added", adapter1);
+
+ verify(cellFactory, times(1)).applyTableItemProviderStyle(itemCaptor.capture(), columnIndexCaptor.capture(), cellCaptor.capture(),
+ adapterFactoryCaptor.capture());
+ assertEquals(item1, itemCaptor.getValue());
+ assertEquals(COLUMN_INDEX, columnIndexCaptor.getValue());
+ assertEquals(tableCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+ // update the cell again
+ invokeUpdateItem(tableCell, item2, false);
+
+ verify(adapterList1).remove(adapter1);
+
+ assertNotNull("No adapter was added", adapter2);
+
+ verify(cellFactory, times(2)).applyTableItemProviderStyle(itemCaptor.capture(), columnIndexCaptor.capture(), cellCaptor.capture(),
+ adapterFactoryCaptor.capture());
+ assertEquals(item2, itemCaptor.getValue());
+ assertEquals(COLUMN_INDEX, columnIndexCaptor.getValue());
+ assertEquals(tableCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+
+ // notify the adapter
+ Notification notification = mock(Notification.class);
+ when(notification.getNotifier()).thenReturn(item2);
+ adapter2.notifyChanged(notification);
+
+ verify(cellFactory, times(3)).applyTableItemProviderStyle(itemCaptor.capture(), columnIndexCaptor.capture(), cellCaptor.capture(),
+ adapterFactoryCaptor.capture());
+ assertEquals(item2, itemCaptor.getValue());
+ assertEquals(COLUMN_INDEX, columnIndexCaptor.getValue());
+ assertEquals(tableCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+ }
+
+ @Test
+ public void applyTableItemProviderColor() {
+ Object item = mock(Object.class);
+ ITableItemColorProvider itemProvider = mock(ITableItemColorProvider.class);
+ when(itemProvider.getForeground(item, COLUMN_INDEX)).thenReturn(foregroundObject);
+ when(itemProvider.getBackground(item, COLUMN_INDEX)).thenReturn(backgroundObject);
+ when(adapterFactory.adapt(item, ITableItemColorProvider.class)).thenReturn(itemProvider);
+ Cell cell = new Cell();
+ cellFactory.applyTableItemProviderColor(item, COLUMN_INDEX, cell, adapterFactory);
+ assertEquals(foregroundColor, cell.getTextFill());
+ assertEquals("-fx-background-color: rgb(0, 255, 0)", cell.getStyle());
+ }
+
+ @Test
+ public void applyTableItemProviderFont() {
+ Object item = mock(Object.class);
+ ITableItemFontProvider itemProvider = mock(ITableItemFontProvider.class);
+ when(itemProvider.getFont(item, COLUMN_INDEX)).thenReturn(fontObject);
+ when(adapterFactory.adapt(item, ITableItemFontProvider.class)).thenReturn(itemProvider);
+ Cell cell = new Cell();
+ cellFactory.applyTableItemProviderFont(item, COLUMN_INDEX, cell, adapterFactory);
+ assertEquals(font, cell.getFont());
+ }
+
+ @Test
+ public void applyTableItemProviderLabel() throws MalformedURLException {
+ Object item = mock(Object.class);
+ String columnText = "my column text";
+ URL columnImage = new URL("http://domain.com/image.jpg");
+ ITableItemLabelProvider itemProvider = mock(ITableItemLabelProvider.class);
+ when(itemProvider.getColumnText(item, COLUMN_INDEX)).thenReturn(columnText);
+ when(itemProvider.getColumnImage(item, COLUMN_INDEX)).thenReturn(columnImage);
+ when(adapterFactory.adapt(item, ITableItemLabelProvider.class)).thenReturn(itemProvider);
+ Cell cell = new Cell();
+ cellFactory.applyTableItemProviderLabel(item, COLUMN_INDEX, cell, adapterFactory);
+ assertEquals(columnText, cell.getText());
+ assertTrue(cell.getGraphic() instanceof ImageView);
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactoryTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactoryTest.java
new file mode 100755
index 000000000..04b305c03
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeCellFactoryTest.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import javafx.scene.control.Cell;
+import javafx.scene.control.ListCell;
+import javafx.scene.control.ListView;
+import javafx.scene.control.TreeCell;
+import javafx.scene.control.TreeView;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellCreationListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryCellFactory.ICellUpdateListener;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryTreeCellFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class AdapterFactoryTreeCellFactoryTest extends AbstractAdapterFactoryCellFactoryTest {
+
+ AdapterFactoryTreeCellFactory cellFactory;
+
+ @Before
+ public void setUp() {
+ createTestBench();
+ cellFactory = spy(new AdapterFactoryTreeCellFactory(adapterFactory));
+ stubHelperMethods(cellFactory);
+ }
+
+ @Test
+ public void call() {
+ cellFactory.call(null);
+ }
+
+ @Test
+ public void cellCreationNotification() {
+ ICellCreationListener listener = mock(ICellCreationListener.class);
+ cellFactory.addCellCreationListener(listener);
+ cellFactory.call(null);
+ verify(listener).cellCreated((Cell<?>) any());
+ }
+
+ @Test
+ public void updateItem() throws Exception {
+ ICellUpdateListener listener = mock(ICellUpdateListener.class);
+ cellFactory.addCellUpdateListener(listener);
+ TreeView<Object> treeView = new TreeView<>();
+ TreeCell<Object> treeCell = cellFactory.call(treeView);
+
+ // update the cell
+ invokeUpdateItem(treeCell, item1, false);
+
+ assertNotNull("No adapter was added", adapter1);
+
+ verify(cellFactory, times(1)).applyItemProviderStyle(itemCaptor.capture(), cellCaptor.capture(), adapterFactoryCaptor.capture());
+ assertEquals(item1, itemCaptor.getValue());
+ assertEquals(treeCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+
+ // update the cell again
+ invokeUpdateItem(treeCell, item2, false);
+
+ verify(adapterList1).remove(adapter1);
+
+ assertNotNull("No adapter was added", adapter2);
+
+ verify(cellFactory, times(2)).applyItemProviderStyle(itemCaptor.capture(), cellCaptor.capture(), adapterFactoryCaptor.capture());
+ assertEquals(item2, itemCaptor.getValue());
+ assertEquals(treeCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+
+ // notify the adapter
+ Notification notification = mock(Notification.class);
+ when(notification.getNotifier()).thenReturn(item2);
+ adapter2.notifyChanged(notification);
+
+ verify(cellFactory, times(3)).applyItemProviderStyle(itemCaptor.capture(), cellCaptor.capture(), adapterFactoryCaptor.capture());
+ assertEquals(item2, itemCaptor.getValue());
+ assertEquals(treeCell, cellCaptor.getValue());
+ assertEquals(adapterFactory, adapterFactoryCaptor.getValue());
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeItemTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeItemTest.java
new file mode 100755
index 000000000..7af41458f
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/AdapterFactoryTreeItemTest.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.fx.emf.edit.ui.AdapterFactoryTreeItem;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public class AdapterFactoryTreeItemTest extends AbstractAdapterFactoryCellFactoryTest {
+
+ AdapterFactory adapterFactory;
+
+ @Before
+ public void setUp() {
+ createTestBench();
+ adapterFactory = mock(AdapterFactory.class);
+ }
+
+ @Ignore
+ @Test
+ public void test() {
+ ITreeItemContentProvider contentProvider = mock(ITreeItemContentProvider.class);
+ ArrayList childItems = new ArrayList();
+ Object childItem1 = new Object();
+ childItems.add(childItem1);
+ when(contentProvider.getChildren(item1)).thenReturn(childItems);
+ when(adapterFactory.adapt((Object) item1, ITreeItemContentProvider.class)).thenReturn(contentProvider);
+ AdapterFactoryTreeItem treeItem = new AdapterFactoryTreeItem(item1, null, adapterFactory);
+
+ assertEquals(childItems.get(0), treeItem.getChildren().get(0).getValue());
+
+ Object childItem2 = new Object();
+ childItems.add(childItem2);
+
+ Notification notification = mock(Notification.class);
+ when(notification.getFeature()).thenReturn(mock(EReference.class));
+ adapter1.notifyChanged(notification);
+
+ assertEquals(childItems.get(0), treeItem.getChildren().get(0).getValue());
+ assertEquals(childItems.get(1), treeItem.getChildren().get(1).getValue());
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/LocalTransferTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/LocalTransferTest.java
new file mode 100755
index 000000000..55d52ec3f
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/LocalTransferTest.java
@@ -0,0 +1,17 @@
+package org.eclipse.fx.emf.edit.ui;
+
+import static org.junit.Assert.*;
+
+import org.eclipse.fx.emf.edit.ui.dnd.LocalTransfer;
+import org.junit.Test;
+
+public class LocalTransferTest {
+
+ @Test
+ public void setAndGetObjbect() {
+ final Object object = new Object();
+ LocalTransfer.INSTANCE.setObject(object);
+ assertEquals(object, LocalTransfer.INSTANCE.getObject());
+ }
+
+}
diff --git a/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/ProxyCellValueFactoryTest.java b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/ProxyCellValueFactoryTest.java
new file mode 100755
index 000000000..351d67549
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.emf.edit.ui.tests/src/org/eclipse/fx/emf/edit/ui/ProxyCellValueFactoryTest.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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.emf.edit.ui;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import javafx.beans.value.ObservableValue;
+import javafx.scene.control.TableColumn.CellDataFeatures;
+
+import org.eclipse.fx.emf.edit.ui.ProxyCellValueFactory;
+import org.junit.Test;
+
+public class ProxyCellValueFactoryTest {
+
+ @Test
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public void call() {
+ ProxyCellValueFactory factory = new ProxyCellValueFactory();
+ CellDataFeatures features = mock(CellDataFeatures.class);
+ Object dummy = new Object();
+ when(features.getValue()).thenReturn(dummy);
+ ObservableValue<Object> observableValue = factory.call(features);
+ assertEquals(dummy, observableValue.getValue());
+ }
+
+}

Back to the top