Example #1
0
 @Test
 public void testValidLabelProvider() {
   TagCloudViewer viewer = new TagCloudViewer(cloud);
   TestLabelProvider labelProvider = new TestLabelProvider();
   viewer.setLabelProvider(labelProvider);
   Assert.assertEquals(labelProvider, viewer.getLabelProvider());
 }
Example #2
0
 @Test
 public void testValidLayouter() {
   TagCloudViewer viewer = new TagCloudViewer(cloud);
   DefaultLayouter layouter = new DefaultLayouter(5, 5);
   viewer.setLayouter(layouter);
   Assert.assertEquals(layouter, viewer.getLayouter());
 }
Example #3
0
 @Test
 public void testValidLabelAsignment() {
   TagCloudViewer viewer = new TagCloudViewer(cloud);
   ListContentProvider provider = new ListContentProvider();
   viewer.setContentProvider(provider);
   TestLabelProvider labelProvider = new TestLabelProvider();
   viewer.setLabelProvider(labelProvider);
   List<String> data = new ArrayList<String>();
   data.add("Hello");
   data.add("World");
   viewer.setInput(data);
   List<Word> words = viewer.getCloud().getWords();
   for (Word word : words) {
     Assert.assertEquals(TestLabelProvider.COLOR, word.getColor());
     for (int i = 0; i < TestLabelProvider.FONT_DATA.length; i++) {
       Assert.assertEquals(TestLabelProvider.FONT_DATA[i], word.getFontData()[i]);
     }
     Assert.assertEquals(TestLabelProvider.ANGLE, word.angle);
     Assert.assertEquals(TestLabelProvider.WEIGHT, word.weight);
     Assert.assertTrue(word.x != 0);
     Assert.assertTrue(word.y != 0);
     Assert.assertTrue(word.width != 0);
     Assert.assertTrue(word.height != 0);
   }
 }
Example #4
0
 @Test
 public void testValidContentProvider() {
   TagCloudViewer viewer = new TagCloudViewer(cloud);
   ListContentProvider provider = new ListContentProvider();
   viewer.setContentProvider(provider);
   Assert.assertEquals(provider, viewer.getContentProvider());
 }
Example #5
0
 @Test
 public void testConstructor_ValidCloud() {
   TagCloudViewer viewer = new TagCloudViewer(cloud);
   TagCloud cloud = viewer.getCloud();
   Assert.assertNotNull(cloud);
   Assert.assertEquals(this.cloud, cloud);
   Assert.assertTrue(viewer.getSelection() != null);
   Assert.assertTrue(viewer.getSelection().isEmpty());
 }
Example #6
0
  @Test(expected = IllegalArgumentException.class)
  public void testInvalidContentProvider2() {
    TagCloudViewer viewer = new TagCloudViewer(cloud);
    viewer.setContentProvider(
        new IContentProvider() {
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          public void dispose() {}
        });
  }
Example #7
0
 @Test(expected = IllegalArgumentException.class)
 public void testInvalidLabelProvider2() {
   TagCloudViewer viewer = new TagCloudViewer(cloud);
   viewer.setLabelProvider(new BaseLabelProvider());
 }
Example #8
0
 @Test(expected = IllegalArgumentException.class)
 public void testInvalidLayouter() {
   TagCloudViewer viewer = new TagCloudViewer(cloud);
   viewer.setLayouter(null);
 }