001 /* 002 * Copyright 2002-2007 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 005 * use this file except in compliance with the License. You may obtain a copy of 006 * the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations under 014 * the License. 015 */ 016 package org.springframework.richclient.dialog; 017 018 import java.awt.Image; 019 import java.awt.image.BufferedImage; 020 021 import org.springframework.richclient.core.DefaultMessage; 022 023 /** 024 * Testcase for TitledApplicationDialog 025 * 026 * @author Peter De Bruycker 027 */ 028 public abstract class TitledApplicationDialogTestCase extends ApplicationDialogTestCase { 029 private TitledApplicationDialog dialogUnderTest; 030 031 protected abstract TitledApplicationDialog createTitledApplicationDialog(final Runnable onAboutToShow); 032 033 protected final ApplicationDialog createApplicationDialog(final Runnable onAboutToShow) { 034 dialogUnderTest = createTitledApplicationDialog(onAboutToShow); 035 036 return dialogUnderTest; 037 } 038 039 public void testGetAndSetTitlePaneTitle() { 040 dialogUnderTest.setTitlePaneTitle("new title pane text"); 041 assertEquals("new title pane text", dialogUnderTest.getTitlePaneTitle()); 042 043 dialogUnderTest.getDialog(); 044 045 dialogUnderTest.setTitlePaneTitle("other title pane text"); 046 assertEquals("other title pane text", dialogUnderTest.getTitlePaneTitle()); 047 } 048 049 public void testGetAndSetMessage() { 050 dialogUnderTest.setMessage(new DefaultMessage("test message")); 051 assertEquals("test message", dialogUnderTest.getMessage().getMessage()); 052 053 dialogUnderTest.getDialog(); 054 055 dialogUnderTest.setMessage(new DefaultMessage("new message")); 056 assertEquals("new message", dialogUnderTest.getMessage().getMessage()); 057 } 058 059 public void testGetAndSetTitlePaneImage() { 060 Image image1 = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB); 061 Image image2 = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB); 062 063 dialogUnderTest.setTitlePaneImage(image1); 064 assertEquals(image1, dialogUnderTest.getTitlePaneImage()); 065 066 dialogUnderTest.getDialog(); 067 068 dialogUnderTest.setImage(image2); 069 assertEquals(image2, dialogUnderTest.getTitlePaneImage()); 070 } 071 }