Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: Icb818f86b1c94283491dc5537a8be522b75e9eef
- Loading branch information
1 parent
165d338
commit 5f77698
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/CachedLabelProviderTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2014 RCP Vision (http://www.rcp-vision.com) 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: | ||
* Lorenzo Bettini - Initial contribution and API | ||
*******************************************************************************/ | ||
package org.eclipse.emf.parsley.tests | ||
|
||
import org.eclipse.emf.parsley.composite.CachedLabelProvider | ||
import org.eclipse.jface.viewers.ILabelProvider | ||
import org.eclipse.jface.viewers.ILabelProviderListener | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
import static org.mockito.Matchers.* | ||
import static org.mockito.Mockito.* | ||
|
||
import static extension org.junit.Assert.* | ||
|
||
class CachedLabelProviderTest extends AbstractImageBasedTest { | ||
|
||
var CachedLabelProvider labelProvider | ||
var ILabelProvider delegate | ||
val final TEST_VAL = "TEST" | ||
|
||
@Before | ||
def void setupLabelProvider() { | ||
delegate = mock(ILabelProvider) | ||
when(delegate.getText(anyObject)).thenReturn(TEST_VAL) | ||
labelProvider = new CachedLabelProvider(delegate) | ||
} | ||
|
||
@After | ||
def void disposeLabelProvider() { | ||
labelProvider.dispose | ||
} | ||
|
||
@Test | ||
def void testGetText() { | ||
TEST_VAL.assertEquals(labelProvider.getText(classForControlsInstance)) | ||
TEST_VAL.assertEquals(labelProvider.getText(classForControlsInstance)) | ||
verify(delegate, times(1)).getText(anyObject) | ||
} | ||
|
||
@Test | ||
def void testGetImage() { | ||
assertNull(labelProvider.getImage(classForControlsInstance)) | ||
assertNull(labelProvider.getImage(classForControlsInstance)) | ||
verify(delegate, times(1)).getImage(anyObject) | ||
} | ||
|
||
@Test | ||
def void testIsValueProperty() { | ||
assertFalse(labelProvider.isLabelProperty(classForControlsInstance, "foo")) | ||
verify(delegate, times(1)).isLabelProperty(classForControlsInstance, "foo") | ||
} | ||
|
||
@Test | ||
def void testListeners() { | ||
val listener = mock(ILabelProviderListener) | ||
labelProvider.addListener(listener) | ||
labelProvider.removeListener(listener) | ||
verify(delegate, times(1)).addListener(listener) | ||
verify(delegate, times(1)).removeListener(listener) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters