|
|
@ -1,15 +1,25 @@ |
|
|
|
package com.fr.design.designer.beans.models; |
|
|
|
package com.fr.design.designer.beans.models; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.config.dao.DaoContext; |
|
|
|
|
|
|
|
import com.fr.config.dao.impl.LocalClassHelperDao; |
|
|
|
|
|
|
|
import com.fr.config.dao.impl.LocalEntityDao; |
|
|
|
|
|
|
|
import com.fr.config.dao.impl.LocalXmlEntityDao; |
|
|
|
import com.fr.design.designer.creator.CRPropertyDescriptor; |
|
|
|
import com.fr.design.designer.creator.CRPropertyDescriptor; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XWTitleLayout; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardLayout; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.ui.ChartEditor; |
|
|
|
import com.fr.form.ui.ChartEditor; |
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
import com.fr.form.ui.container.WAbsoluteLayout; |
|
|
|
import com.fr.form.ui.container.WAbsoluteLayout; |
|
|
|
|
|
|
|
import com.fr.form.ui.container.WCardLayout; |
|
|
|
import com.fr.form.ui.container.WTitleLayout; |
|
|
|
import com.fr.form.ui.container.WTitleLayout; |
|
|
|
import org.easymock.EasyMock; |
|
|
|
import org.easymock.EasyMock; |
|
|
|
|
|
|
|
import org.junit.After; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JComponent; |
|
|
@ -19,6 +29,20 @@ import java.beans.IntrospectionException; |
|
|
|
|
|
|
|
|
|
|
|
public class AddingModelTest { |
|
|
|
public class AddingModelTest { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
|
|
|
public void setUp() { |
|
|
|
|
|
|
|
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
|
|
|
|
|
|
|
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
|
|
|
|
|
|
|
DaoContext.setEntityDao(new LocalEntityDao()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@After |
|
|
|
|
|
|
|
public void tearDown() { |
|
|
|
|
|
|
|
DaoContext.setXmlEntityDao(null); |
|
|
|
|
|
|
|
DaoContext.setClassHelperDao(null); |
|
|
|
|
|
|
|
DaoContext.setEntityDao(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testInstantiateCreator() throws Exception { |
|
|
|
public void testInstantiateCreator() throws Exception { |
|
|
|
|
|
|
|
|
|
|
@ -37,7 +61,9 @@ public class AddingModelTest { |
|
|
|
WAbsoluteLayout.BoundsWidget boundsWidget = new WAbsoluteLayout.BoundsWidget(chartEditor3, new Rectangle(dimension)); |
|
|
|
WAbsoluteLayout.BoundsWidget boundsWidget = new WAbsoluteLayout.BoundsWidget(chartEditor3, new Rectangle(dimension)); |
|
|
|
WTitleLayout wTitleLayout03 = new WTitleLayout(); |
|
|
|
WTitleLayout wTitleLayout03 = new WTitleLayout(); |
|
|
|
wTitleLayout03.addWidget(boundsWidget); |
|
|
|
wTitleLayout03.addWidget(boundsWidget); |
|
|
|
DemoCreator xCreator3 = new DemoCreator(wTitleLayout03, dimension, "test03"); |
|
|
|
//需要和内部的 widget 一样
|
|
|
|
|
|
|
|
wTitleLayout03.setWidgetName("test03"); |
|
|
|
|
|
|
|
XWTitleLayout xCreator3 = new XWTitleLayout(wTitleLayout03, dimension); |
|
|
|
xCreator1.add(xCreator3); |
|
|
|
xCreator1.add(xCreator3); |
|
|
|
|
|
|
|
|
|
|
|
AddingModel addingModel = new AddingModel(xCreator1, 20, 20); |
|
|
|
AddingModel addingModel = new AddingModel(xCreator1, 20, 20); |
|
|
@ -61,6 +87,31 @@ public class AddingModelTest { |
|
|
|
Assert.assertEquals("test030", xCreator3.toData().getWidgetName()); |
|
|
|
Assert.assertEquals("test030", xCreator3.toData().getWidgetName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testInstantiateCreator_cardLayout() throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Form form = EasyMock.mock(Form.class); |
|
|
|
|
|
|
|
EasyMock.expect(form.isNameExist("cardlayout")).andReturn(true).once(); |
|
|
|
|
|
|
|
EasyMock.expect(form.isNameExist(EasyMock.anyString())).andReturn(false).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.replay(form); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FormDesigner mock = EasyMock.mock(FormDesigner.class); |
|
|
|
|
|
|
|
EasyMock.expect(mock.getTarget()).andReturn(form).anyTimes(); |
|
|
|
|
|
|
|
EasyMock.replay(mock); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WCardLayout wCardLayout = new WCardLayout(20, 20); |
|
|
|
|
|
|
|
XWCardLayout xwCardLayout = new XWCardLayout(wCardLayout, new Dimension(20, 20)); |
|
|
|
|
|
|
|
AddingModel addingModel = new AddingModel(mock, xwCardLayout); |
|
|
|
|
|
|
|
Assert.assertEquals("cardlayout1", xwCardLayout.toData().getWidgetName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//依赖于 cardlayout 创建 container
|
|
|
|
|
|
|
|
XLayoutContainer parentLayOut = xwCardLayout.initCreatorWrapper(20); |
|
|
|
|
|
|
|
AddingModel parentModel = new AddingModel(mock, parentLayOut); |
|
|
|
|
|
|
|
Assert.assertEquals("tablayout1", parentLayOut.toData().getWidgetName()); |
|
|
|
|
|
|
|
Assert.assertEquals("tabpane1", ((XCreator) (parentLayOut.getComponent(0))).getXCreator().toData().getWidgetName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class DemoCreator extends XCreator { |
|
|
|
private static class DemoCreator extends XCreator { |
|
|
|
|
|
|
|
|
|
|
|
private String widgetName; |
|
|
|
private String widgetName; |
|
|
|