1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.richclient.command.config;
17
18 import javax.swing.JButton;
19
20
21
22
23
24
25 public class ToolBarCommandButtonConfigurerTests extends CommandButtonConfigurerTestCase {
26
27 public void testDefaults() {
28 ToolBarCommandButtonConfigurer configurer= new ToolBarCommandButtonConfigurer();
29
30 assertFalse(configurer.isShowText());
31 assertTrue(configurer.isTextBelowIcon());
32 }
33
34 public void testConfigureWithDefaults() {
35 ToolBarCommandButtonConfigurer configurer = new ToolBarCommandButtonConfigurer();
36 JButton button = new JButton();
37
38 configurer.configure(button, null, getCommandFaceDescriptor());
39
40 assertEquals(null, button.getText());
41 assertEquals(getCommandFaceDescriptor().getIcon(), button.getIcon());
42 assertEquals(getCommandFaceDescriptor().getCaption(), button.getToolTipText());
43 }
44
45 public void testConfigureWithShowTextTrue() {
46 ToolBarCommandButtonConfigurer configurer = new ToolBarCommandButtonConfigurer();
47 configurer.setShowText(true);
48
49 JButton button = new JButton();
50
51 configurer.configure(button, null, getCommandFaceDescriptor());
52
53 assertEquals(getCommandFaceDescriptor().getText(), button.getText());
54 assertEquals(getCommandFaceDescriptor().getIcon(), button.getIcon());
55 assertEquals(getCommandFaceDescriptor().getCaption(), button.getToolTipText());
56
57 assertEquals(JButton.BOTTOM, button.getVerticalTextPosition());
58 assertEquals(JButton.CENTER, button.getHorizontalTextPosition());
59 }
60
61 public void testConfigureWithShowTextTrueAndTextBelowIconFalse() {
62 ToolBarCommandButtonConfigurer configurer = new ToolBarCommandButtonConfigurer();
63 configurer.setShowText(true);
64 configurer.setTextBelowIcon(false);
65
66 JButton button = new JButton();
67
68 configurer.configure(button, null, getCommandFaceDescriptor());
69
70 assertEquals(getCommandFaceDescriptor().getText(), button.getText());
71 assertEquals(getCommandFaceDescriptor().getIcon(), button.getIcon());
72 assertEquals(getCommandFaceDescriptor().getCaption(), button.getToolTipText());
73
74 assertEquals(JButton.CENTER, button.getVerticalTextPosition());
75 assertEquals(JButton.TRAILING, button.getHorizontalTextPosition());
76 }
77
78 protected CommandButtonConfigurer createConfigurer() {
79 return new ToolBarCommandButtonConfigurer();
80 }
81 }