forked from fanruan/design
Browse Source
[场景] 拖入组件时,组件时绝对画布块,内部有多个组件。此时,不会对内部的多个组件进行检测。 [solution] 递归的对所有组件进行处理。feature/big-screen
Harrison
5 years ago
2 changed files with 118 additions and 29 deletions
@ -0,0 +1,52 @@ |
|||||||
|
package com.fr.design.designer.beans.models; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.form.ui.ChartEditor; |
||||||
|
import org.easymock.EasyMock; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import javax.swing.JComponent; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.beans.IntrospectionException; |
||||||
|
|
||||||
|
public class AddingModelTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testInstantiateCreator() throws Exception { |
||||||
|
|
||||||
|
ChartEditor chartEditor = new ChartEditor(); |
||||||
|
chartEditor.setWidgetName("test"); |
||||||
|
XCreator xCreator = new XCreator(chartEditor, new Dimension(20, 20)) { |
||||||
|
@Override |
||||||
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||||
|
return new CRPropertyDescriptor[0]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JComponent initEditor() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initXCreatorProperties() { |
||||||
|
} |
||||||
|
}; |
||||||
|
AddingModel addingModel = new AddingModel(xCreator, 20, 20); |
||||||
|
|
||||||
|
Form form = EasyMock.mock(Form.class); |
||||||
|
EasyMock.expect(form.isNameExist("test_a")).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); |
||||||
|
|
||||||
|
addingModel.instantiateCreator(mock); |
||||||
|
Assert.assertEquals("test_a_a", xCreator.toData().getWidgetName()); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue