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;
19  import java.awt.image.BufferedImage;
20  
21  import org.springframework.richclient.core.DefaultMessage;
22  
23  /**
24   * Testcase for TitledApplicationDialog
25   * 
26   * @author Peter De Bruycker
27   */
28  public abstract class TitledApplicationDialogTestCase extends ApplicationDialogTestCase {
29  	private TitledApplicationDialog dialogUnderTest;
30  
31  	protected abstract TitledApplicationDialog createTitledApplicationDialog(final Runnable onAboutToShow);
32  
33  	protected final ApplicationDialog createApplicationDialog(final Runnable onAboutToShow) {
34  		dialogUnderTest = createTitledApplicationDialog(onAboutToShow);
35  
36  		return dialogUnderTest;
37  	}
38  
39  	public void testGetAndSetTitlePaneTitle() {
40  		dialogUnderTest.setTitlePaneTitle("new title pane text");
41  		assertEquals("new title pane text", dialogUnderTest.getTitlePaneTitle());
42  
43  		dialogUnderTest.getDialog();
44  
45  		dialogUnderTest.setTitlePaneTitle("other title pane text");
46  		assertEquals("other title pane text", dialogUnderTest.getTitlePaneTitle());
47  	}
48  
49  	public void testGetAndSetMessage() {
50  		dialogUnderTest.setMessage(new DefaultMessage("test message"));
51  		assertEquals("test message", dialogUnderTest.getMessage().getMessage());
52  
53  		dialogUnderTest.getDialog();
54  
55  		dialogUnderTest.setMessage(new DefaultMessage("new message"));
56  		assertEquals("new message", dialogUnderTest.getMessage().getMessage());
57  	}
58  
59  	public void testGetAndSetTitlePaneImage() {
60  		Image image1 = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
61  		Image image2 = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB);
62  
63  		dialogUnderTest.setTitlePaneImage(image1);
64  		assertEquals(image1, dialogUnderTest.getTitlePaneImage());
65  
66  		dialogUnderTest.getDialog();
67  
68  		dialogUnderTest.setImage(image2);
69  		assertEquals(image2, dialogUnderTest.getTitlePaneImage());
70  	}
71  }