1   /*
2    * Copyright 2002-2007 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.springframework.richclient.dialog;
17  
18  import java.awt.image.BufferedImage;
19  
20  import javax.swing.JLabel;
21  import javax.swing.JPanel;
22  
23  import junit.framework.TestCase;
24  
25  import org.springframework.richclient.core.DefaultMessage;
26  
27  /**
28   * Testcase for TitlePane
29   * 
30   * @author Peter De Bruycker
31   */
32  public class TitlePaneTests extends TestCase {
33  
34  	public void testBlah() {
35  		TitlePane titlePane = new TitlePane();
36  		titlePane.setImage(new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB));
37  		titlePane.setTitle("new title");
38  		titlePane.setMessage(new DefaultMessage("test message", null));
39  		assertEquals("new title", titlePane.getTitle());
40  
41  		// trigger control creation
42  		JPanel panel = (JPanel) titlePane.getControl();
43  
44  		assertEquals("must have 3 components: title, icon and message", 3, panel.getComponentCount());
45  
46  		JLabel titleLabel = (JLabel) panel.getComponent(0);
47  		assertEquals("new title", titleLabel.getText());
48  
49  		JLabel iconLabel = (JLabel) panel.getComponent(1);
50  		assertNotNull(iconLabel.getIcon());
51  
52  		JLabel messageLabel = (JLabel) panel.getComponent(2);
53  		assertEquals("<html>test message</html>", messageLabel.getText());
54  		
55  		// change title and message after control creation
56  		titlePane.setTitle("other title");
57  		titlePane.setMessage(new DefaultMessage("other message", null));
58  
59  		assertEquals("other title", titleLabel.getText());
60  		assertEquals("<html>other message</html>", messageLabel.getText());
61  	}
62  
63  }