blob: 9388b859f098c127c9b7dade0b6d5c74be7ee8a8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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"));
}
}
|