Browse Source

REPORT-103529 完善

release/11.0
obo 1 year ago
parent
commit
7a8ce0346d
  1. 12
      designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java
  2. 7
      designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java
  3. 8
      designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java
  4. 29
      designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java

12
designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java

@ -6,8 +6,8 @@ import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.general.ModuleContext;
import com.fr.report.restriction.CellCountRestriction;
import com.fr.report.restriction.ReportRestrictionScene;
@ -18,6 +18,9 @@ import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashSet;
@ -29,9 +32,14 @@ import java.util.Set;
* Created by zack on 2019/9/17
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class ExtraDesignClassManagerTest extends TestCase {
@Override
protected void setUp() throws Exception {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
DaoContext.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
@ -41,7 +49,7 @@ public class ExtraDesignClassManagerTest extends TestCase {
public void testGetWebOption() {
try {
final JTemplate jTemplate = new JVirtualTemplate(null);
final JTemplate jTemplate = EasyMock.mock(JTemplate.class);
ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class);
ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class);
EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes();

7
designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java

@ -4,12 +4,14 @@ import com.fr.design.gui.core.UITextComponent;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralContext;
import com.fr.stable.StringUtils;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@ -17,6 +19,7 @@ import javax.swing.Icon;
import java.awt.Component;
import java.awt.Graphics;
import java.util.Locale;
import static org.junit.Assert.*;
@ -25,6 +28,7 @@ import static org.junit.Assert.*;
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class UIComponentUtilsTest {
private static final String HTML_TAG_TPL = "<html><body style='width: %dpx'>";
private static final String HTML_TAG = "<html>";
@ -40,6 +44,7 @@ public class UIComponentUtilsTest {
public void setUp() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
textButton = new UIButton("hello");
emptyTextButton = new UIButton(StringUtils.EMPTY);
iconButton = new UIButton(createMockIcon());
@ -47,13 +52,13 @@ public class UIComponentUtilsTest {
textLabel = new UILabel("hello");
emptyTextLabel = new UILabel(StringUtils.EMPTY);
iconLabel = new UILabel(createMockIcon());
GeneralContext.setLocale(Locale.US);
}
@Test
public void testSetLineWrap() {
UITextComponent[] noWrapComps = {emptyTextButton, emptyTextLabel, iconButton, iconLabel};
UITextComponent[] wrapComps = {textLabel, textButton};
for (UITextComponent comp : wrapComps) {
UIComponentUtils.setLineWrap(comp);
assertTrue(isLineWrapped(comp));

8
designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java

@ -12,14 +12,6 @@ import java.util.Map;
* Created by kerry on 2020-04-24
*/
public class FormAdaptivePreviewTest {
@Test
public void testParametersForPreview() {
FormAdaptivePreview formPreview = new FormAdaptivePreview();
Map<String, Object> map = formPreview.parametersForPreview();
Assert.assertEquals(0, map.size());
Assert.assertNull(map.get(ParameterConstants.OP));
}
@Test
public void testAccept() {
FormAdaptivePreview formPreview = new FormAdaptivePreview();

29
designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java

@ -1,6 +1,8 @@
package com.fr.design.mainframe;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.FormThemeConfig;
import com.fr.base.theme.ReportThemeConfig;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeConfig;
import com.fr.config.dao.DaoContext;
@ -10,8 +12,11 @@ import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.form.main.Form;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.container.OccupiedLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.general.ImageWithSuffix;
import com.fr.general.ModuleContext;
import com.fr.invoke.Reflect;
import com.fr.main.impl.WorkBook;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellImage;
@ -23,14 +28,20 @@ import com.fr.restriction.Restrictions;
import com.fr.stable.StringUtils;
import com.fr.stable.module.Module;
import com.fr.start.MainDesigner;
import com.fr.third.guava.collect.Lists;
import com.fr.transaction.WorkerCallBack;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.modules.junit4.PowerMockRunner;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.swing.*")
@ -55,6 +66,7 @@ public class JFileTest extends TestCase {
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg");
CellImage cellImage = new CellImage();
cellImage.setImage(imageWithSuffix);
mockJCreateConfigEnv(ReportThemeConfig.getInstance());
JWorkBook jWorkBook = new JWorkBook(workBook, "text");
jWorkBook.setPictureElem(cellElement, cellImage);
Assert.assertEquals(imageWithSuffix, cellElement.getValue());
@ -71,9 +83,24 @@ public class JFileTest extends TestCase {
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg");
CellImage cellImage = new CellImage();
cellImage.setImage(imageWithSuffix);
JForm jForm = new JForm();
mockJCreateConfigEnv(FormThemeConfig.getInstance());
form.setContainer(new WFitLayout());
JForm jForm = new JForm(form);
jForm.setTarget(form);
jForm.setPictureElem(cellElement, cellImage);
Assert.assertEquals(imageWithSuffix, cellElement.getValue());
}
private void mockJCreateConfigEnv(TemplateThemeConfig instance) {
Reflect.on(instance).field("themeName4NewTemplate").call("set", "test");
TemplateThemeConfig.OrderedNameList list = new TemplateThemeConfig.OrderedNameList();
list.setThemeNames(Lists.newArrayList("test"));
Reflect.on(instance).field("themeNameList").call("set", list);
TemplateTheme testTheme = new FormTheme();
testTheme.setDark(false);
testTheme.setName("test");
Map<String, TemplateTheme> testMap = new HashMap<>();
testMap.put("test", testTheme);
Reflect.on(instance).call("put", "test", testTheme, true);
}
}
Loading…
Cancel
Save