Browse Source

Merge pull request #12861 in DESIGN/design from final/11.0 to persist/11.0

* commit 'f17efcaaf1f44c97b1e705eb09238b91bc0578d6':
  REPORT-104133 【文本类控件】文本类控件新功能入口在设计器上打开
  REPORT-104056 保持整体对齐
  REPORT-105614 设计器去除webroot/druid服务
  REPORT-104056 补充一下注释
  fix:报表块编辑返回大屏画布编辑 右侧属性面板弹框需要都隐藏 #REPORT-105397
  REPORT-104056 统一布局
  REPORT-104056 改下命名
  REPORT-104056 【FR国际化】文字显示不全
  REPORT-103529 完善
  REPORT-103529 单测巡检前置修复-2
fix-lag
superman 1 year ago
parent
commit
c8ce0eefbc
  1. 24
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 7
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  3. 5
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  4. 15
      designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java
  5. 2
      designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java
  6. 18
      designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java
  7. 7
      designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java
  8. 5
      designer-base/src/test/java/com/fr/design/os/impl/SupportOSImplTest.java
  9. 12
      designer-base/src/test/java/com/fr/design/update/push/DesignerPushUpdateManagerTest.java
  10. 3
      designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java
  11. 17
      designer-base/src/test/java/com/fr/design/utils/gui/UIComponentUtilsTest.java
  12. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java
  13. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XPassword.java
  14. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java
  15. 9
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TextEditorMobileDefinePane.java
  16. 13
      designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapterTest.java
  17. 6
      designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java
  18. 2
      designer-form/src/test/java/com/fr/design/preview/DeveloperPreviewTest.java
  19. 8
      designer-form/src/test/java/com/fr/design/preview/FormAdaptivePreviewTest.java
  20. 13
      designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java
  21. 2
      designer-realize/src/main/java/com/fr/design/widget/ui/mobile/TextEditorMobilePane.java
  22. 39
      designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java

24
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -44,6 +44,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
@ -75,6 +76,7 @@ import javax.swing.ButtonGroup;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
@ -248,7 +250,7 @@ public class PreferencePane extends BasicPane {
private JProgressBar gcProgressBar; private JProgressBar gcProgressBar;
private Timer gcProgressTimer; private Timer gcProgressTimer;
private UIButton gcOkButton = new UIButton(i18nText("Fine-Design_Report_OK")); private UIButton gcOkButton = new UIButton(i18nText("Fine-Design_Report_OK"));
private UIRadioButton previewResolutionBtnS; private UIRadioButton previewResolutionBtnS;
private UIRadioButton previewResolutionBtnM; private UIRadioButton previewResolutionBtnM;
@ -278,7 +280,7 @@ public class PreferencePane extends BasicPane {
JPanel generalPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel generalPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
UIScrollPane generalScrollPane = patchScroll(generalPane); UIScrollPane generalScrollPane = patchScroll(generalPane);
jtabPane.addTab(i18nText("Fine-Design_Basic_General"), generalScrollPane); jtabPane.addTab(i18nText("Fine-Design_Basic_General"), generalScrollPane);
JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
UIScrollPane adviceScrollPane = patchScroll(advancePane); UIScrollPane adviceScrollPane = patchScroll(advancePane);
jtabPane.addTab(i18nText("Fine-Design_Basic_Advanced"), adviceScrollPane); jtabPane.addTab(i18nText("Fine-Design_Basic_Advanced"), adviceScrollPane);
@ -293,7 +295,7 @@ public class PreferencePane extends BasicPane {
//配置面板作为vcs总面板的一张卡片 //配置面板作为vcs总面板的一张卡片
vcsParentPane.add(vcsScrollPane, VcsMovePanel.SETTING); vcsParentPane.add(vcsScrollPane, VcsMovePanel.SETTING);
jtabPane.addTab(i18nText("Fine-Design_Vcs_Title"), vcsParentPane); jtabPane.addTab(i18nText("Fine-Design_Vcs_Title"), vcsParentPane);
contentPane.add(jtabPane, BorderLayout.NORTH); contentPane.add(jtabPane, BorderLayout.NORTH);
createFunctionPane(generalPane); createFunctionPane(generalPane);
@ -310,7 +312,7 @@ public class PreferencePane extends BasicPane {
createLogPane(advancePane); createLogPane(advancePane);
createLanPane(generalPane); createLanPane(generalPane);
createStartupPagePane(generalPane); createStartupPagePane(generalPane);
createLengthPane(advancePane); createLengthPane(advancePane);
@ -376,7 +378,7 @@ public class PreferencePane extends BasicPane {
designerStartupOption.add(cloudAnalyticsDelayCheckBox); designerStartupOption.add(cloudAnalyticsDelayCheckBox);
advancePane.add(designerStartupOption); advancePane.add(designerStartupOption);
} }
private JPanel createImageExportSettingPane() { private JPanel createImageExportSettingPane() {
previewResolutionBtnS = new UIRadioButton(i18nText("Fine-Design_Image_Export_SD"), true); previewResolutionBtnS = new UIRadioButton(i18nText("Fine-Design_Image_Export_SD"), true);
previewResolutionBtnM = new UIRadioButton(i18nText("Fine-Design_Image_Export_HD")); previewResolutionBtnM = new UIRadioButton(i18nText("Fine-Design_Image_Export_HD"));
@ -412,7 +414,7 @@ public class PreferencePane extends BasicPane {
generalPanelWithScroll.setPreferredSize(new Dimension(generalPane.getWidth(), 600)); generalPanelWithScroll.setPreferredSize(new Dimension(generalPane.getWidth(), 600));
return generalPanelWithScroll; return generalPanelWithScroll;
} }
private void createVcsSettingPane(JPanel generalPane,JPanel parentPane, CardLayout cardLayout) { private void createVcsSettingPane(JPanel generalPane,JPanel parentPane, CardLayout cardLayout) {
//迁移面板 //迁移面板
movePanel = createMovePane(cardLayout, parentPane); movePanel = createMovePane(cardLayout, parentPane);
@ -639,7 +641,7 @@ public class PreferencePane extends BasicPane {
private void createEditPane(JPanel generalPane) { private void createEditPane(JPanel generalPane) {
//samuel:编辑器设置 //samuel:编辑器设置
JPanel editPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Editor_Preference")); JPanel editPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Editor_Preference"));
generalPane.add(editPane); generalPane.add(editPane);
//设置是否支持将字符串编辑为公式 //设置是否支持将字符串编辑为公式
@ -649,7 +651,6 @@ public class PreferencePane extends BasicPane {
//是否默认转化 //是否默认转化
defaultStringToFormulaBox = new UICheckBox(i18nText("Fine-Design_Basic_Always")); defaultStringToFormulaBox = new UICheckBox(i18nText("Fine-Design_Basic_Always"));
editPane.add(defaultStringToFormulaBox);
//不支持转化则不能默认执行 //不支持转化则不能默认执行
supportStringToFormulaBox.addActionListener(new ActionListener() { supportStringToFormulaBox.addActionListener(new ActionListener() {
@Override @Override
@ -661,7 +662,12 @@ public class PreferencePane extends BasicPane {
keyStrokePane.add(new UILabel(i18nText("Fine-Design_Basic_Support_Auto_Complete_Shortcut") + ":"), BorderLayout.WEST); keyStrokePane.add(new UILabel(i18nText("Fine-Design_Basic_Support_Auto_Complete_Shortcut") + ":"), BorderLayout.WEST);
shortCutLabel = new UILabel(); shortCutLabel = new UILabel();
keyStrokePane.add(shortCutLabel, BorderLayout.CENTER); keyStrokePane.add(shortCutLabel, BorderLayout.CENTER);
editPane.add(keyStrokePane); keyStrokePane.setBorder(new EmptyBorder(0, 10,0,0));
JPanel defaultExecutePane = new JPanel(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout());
defaultExecutePane.add(defaultStringToFormulaBox);
defaultExecutePane.add(keyStrokePane);
editPane.add(defaultExecutePane);
shortCutLabel.addMouseListener(new MouseAdapter() { shortCutLabel.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {

7
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -690,6 +690,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
public void hideAllPopupDialog() {
for (PropertyItem item : propertyItemMap.values()) {
item.popToFrame();
}
}
private void resetPropertyIcons() { private void resetPropertyIcons() {
for (PropertyItem item : propertyItemMap.values()) { for (PropertyItem item : propertyItemMap.values()) {
item.resetButtonIcon(); item.resetButtonIcon();

5
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -15,7 +15,6 @@ import com.fr.web.socketio.WebSocketEndpoint;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import org.apache.catalina.Context; import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.loader.WebappLoader; import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.StandardRoot; import org.apache.catalina.webresources.StandardRoot;
@ -81,10 +80,6 @@ public class FineEmbedServerActivator extends Activator {
String contextPath = "/" + ProductConstants.getAppFolderName(); String contextPath = "/" + ProductConstants.getAppFolderName();
final Context context = tomcat.addContext(contextPath, docBase); final Context context = tomcat.addContext(contextPath, docBase);
context.setResources(new StandardRoot(context)); context.setResources(new StandardRoot(context));
Wrapper servlet = Tomcat.addServlet(context, "DruidStatView", "com.fr.third.alibaba.druid.support.http.StatViewServlet");
context.addServletMappingDecoded("/druid/*", "DruidStatView");
servlet.setLoadOnStartup(1);
servlet.setOverridable(true);
Tomcat.initWebappDefaults(context); Tomcat.initWebappDefaults(context);
//覆盖tomcat的WebAppClassLoader //覆盖tomcat的WebAppClassLoader
context.setLoader(new FRTomcatLoader()); context.setLoader(new FRTomcatLoader());

15
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.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.fun.ToolbarItemProvider; import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.general.ModuleContext; import com.fr.general.ModuleContext;
import com.fr.report.restriction.CellCountRestriction; import com.fr.report.restriction.CellCountRestriction;
import com.fr.report.restriction.ReportRestrictionScene; import com.fr.report.restriction.ReportRestrictionScene;
@ -17,6 +17,11 @@ import com.fr.stable.module.Module;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert; 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; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -26,9 +31,15 @@ import java.util.Set;
* @version 10.0 * @version 10.0
* Created by zack on 2019/9/17 * Created by zack on 2019/9/17
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class ExtraDesignClassManagerTest extends TestCase { public class ExtraDesignClassManagerTest extends TestCase {
@Override @Override
protected void setUp() throws Exception { 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.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao()); DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
@ -38,7 +49,7 @@ public class ExtraDesignClassManagerTest extends TestCase {
public void testGetWebOption() { public void testGetWebOption() {
try { try {
final JTemplate jTemplate = new JVirtualTemplate(null); final JTemplate jTemplate = EasyMock.mock(JTemplate.class);
ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class); ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class);
ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class); ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class);
EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes(); EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes();

2
designer-base/src/test/java/com/fr/design/extra/PluginUtilsTest.java

@ -17,7 +17,7 @@ public class PluginUtilsTest {
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9.0").get()); Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9.0").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9~").get()); Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "9~").get());
Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "10").get()); Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "10").get());
Assert.assertFalse(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get()); Assert.assertTrue(Reflect.on(PluginUtils.class).call("isCompatibleCurrentEnv", "11").get());
} }
} }

18
designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java

@ -1,14 +1,32 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.ScreenResolution;
import com.fr.design.i18n.Toolkit;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import org.easymock.EasyMock;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; 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;
/** /**
* Created by kerry on 2020-07-28 * Created by kerry on 2020-07-28
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class JFormSliderPaneTest { public class JFormSliderPaneTest {
@Before
public void setUp() throws Exception {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
}
@Test @Test
public void testGetPreferredValue() { public void testGetPreferredValue() {

7
designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java

@ -5,6 +5,7 @@ import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao; import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao; import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.i18n.Toolkit;
import com.fr.design.notification.SnapChatAllTypes; import com.fr.design.notification.SnapChatAllTypes;
import com.fr.design.notification.SnapChatConfig; import com.fr.design.notification.SnapChatConfig;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -29,13 +30,14 @@ import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({SnapChatConfig.class, SnapChatUpdateAction.class}) @PrepareForTest({Toolkit.class, SnapChatConfig.class, SnapChatUpdateAction.class})
@PowerMockIgnore({"javax.crypto.*","javax.net.ssl.*","sun.security.ssl.*","com.sun.*"}) @PowerMockIgnore({"javax.crypto.*","javax.net.ssl.*","sun.security.ssl.*","com.sun.*"})
public class SnapChatMenuDefTest { public class SnapChatMenuDefTest {
@Before @Before
public void before() throws Exception { public void before() throws Exception {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao()); DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setEntityDao(new LocalEntityDao()); DaoContext.setEntityDao(new LocalEntityDao());
@ -46,7 +48,6 @@ public class SnapChatMenuDefTest {
@Test @Test
public void testAddShortCut() throws Exception { public void testAddShortCut() throws Exception {
PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class)); PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class));
SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class) SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class)
.addMockedMethod("readXML") .addMockedMethod("readXML")

5
designer-base/src/test/java/com/fr/design/os/impl/SupportOSImplTest.java

@ -1,11 +1,15 @@
package com.fr.design.os.impl; package com.fr.design.os.impl;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.third.org.apache.commons.math3.analysis.function.Pow;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.util.Locale; import java.util.Locale;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox; import org.powermock.reflect.Whitebox;
/** /**
@ -13,6 +17,7 @@ import org.powermock.reflect.Whitebox;
* @version 10.0 * @version 10.0
* Created by hades on 2020/1/16 * Created by hades on 2020/1/16
*/ */
@RunWith(PowerMockRunner.class)
public class SupportOSImplTest extends TestCase { public class SupportOSImplTest extends TestCase {
@Test @Test

12
designer-base/src/test/java/com/fr/design/update/push/DesignerPushUpdateManagerTest.java

@ -41,18 +41,6 @@ public class DesignerPushUpdateManagerTest {
assertSame(m1, m2); assertSame(m1, m2);
} }
@Test
public void testIsAutoPushUpdateSupported() {
// 中文环境 + 本地设计 -> true
DesignerPushUpdateManager pushUpdateManager = DesignerPushUpdateManager.getInstance();
assertEquals(true, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", true, true).get());
// 非中文环境 || 远程设计 -> false
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", false, true).get());
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", true, false).get());
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", false, false).get());
}
@Test @Test
public void testSkipCurrentPushVersion() { public void testSkipCurrentPushVersion() {
DesignerPushUpdateManager pushUpdateManager = DesignerPushUpdateManager.getInstance(); DesignerPushUpdateManager pushUpdateManager = DesignerPushUpdateManager.getInstance();

3
designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java

@ -44,10 +44,11 @@ public class UpmUtilsTest {
GeneralContext.setLocale(Locale.CHINA); GeneralContext.setLocale(Locale.CHINA);
Map<String, String> map4Tpl = UpmUtils.renderMap(); Map<String, String> map4Tpl = UpmUtils.renderMap();
Assert.assertEquals(map4Tpl.size(), 3); Assert.assertEquals(map4Tpl.size(), 4);
Assert.assertEquals(map4Tpl.get("version"), "1.0"); Assert.assertEquals(map4Tpl.get("version"), "1.0");
Assert.assertEquals(map4Tpl.get("new_version"), "2.0"); Assert.assertEquals(map4Tpl.get("new_version"), "2.0");
Assert.assertEquals(map4Tpl.get("language"), "zh_CN"); Assert.assertEquals(map4Tpl.get("language"), "zh_CN");
Assert.assertEquals(map4Tpl.get("designer_version"), "Fine-Core_Basic_About_No_Build");
EasyMock.verify(serverPreferenceConfig, cloudCenter); EasyMock.verify(serverPreferenceConfig, cloudCenter);

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

@ -3,20 +3,32 @@ package com.fr.design.utils.gui;
import com.fr.design.gui.core.UITextComponent; import com.fr.design.gui.core.UITextComponent;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralContext;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import org.easymock.EasyMock;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; 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;
import javax.swing.Icon; import javax.swing.Icon;
import java.awt.Component; import java.awt.Component;
import java.awt.Graphics; import java.awt.Graphics;
import java.util.Locale;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
* Created by plough on 2019/1/11. * Created by plough on 2019/1/11.
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class UIComponentUtilsTest { public class UIComponentUtilsTest {
private static final String HTML_TAG_TPL = "<html><body style='width: %dpx'>"; private static final String HTML_TAG_TPL = "<html><body style='width: %dpx'>";
private static final String HTML_TAG = "<html>"; private static final String HTML_TAG = "<html>";
@ -30,6 +42,9 @@ public class UIComponentUtilsTest {
@Before @Before
public void setUp() { public void setUp() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
textButton = new UIButton("hello"); textButton = new UIButton("hello");
emptyTextButton = new UIButton(StringUtils.EMPTY); emptyTextButton = new UIButton(StringUtils.EMPTY);
iconButton = new UIButton(createMockIcon()); iconButton = new UIButton(createMockIcon());
@ -37,13 +52,13 @@ public class UIComponentUtilsTest {
textLabel = new UILabel("hello"); textLabel = new UILabel("hello");
emptyTextLabel = new UILabel(StringUtils.EMPTY); emptyTextLabel = new UILabel(StringUtils.EMPTY);
iconLabel = new UILabel(createMockIcon()); iconLabel = new UILabel(createMockIcon());
GeneralContext.setLocale(Locale.US);
} }
@Test @Test
public void testSetLineWrap() { public void testSetLineWrap() {
UITextComponent[] noWrapComps = {emptyTextButton, emptyTextLabel, iconButton, iconLabel}; UITextComponent[] noWrapComps = {emptyTextButton, emptyTextLabel, iconButton, iconLabel};
UITextComponent[] wrapComps = {textLabel, textButton}; UITextComponent[] wrapComps = {textLabel, textButton};
for (UITextComponent comp : wrapComps) { for (UITextComponent comp : wrapComps) {
UIComponentUtils.setLineWrap(comp); UIComponentUtils.setLineWrap(comp);
assertTrue(isLineWrapped(comp)); assertTrue(isLineWrapped(comp));

10
designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java

@ -6,7 +6,9 @@ package com.fr.design.designer.creator;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.designer.properties.mobile.NumberEditorMobilePropertyUI;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor; import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor;
import com.fr.design.mainframe.widget.editors.SpinnerMaxNumberEditor; import com.fr.design.mainframe.widget.editors.SpinnerMaxNumberEditor;
import com.fr.design.mainframe.widget.editors.SpinnerMinNumberEditor; import com.fr.design.mainframe.widget.editors.SpinnerMinNumberEditor;
@ -102,8 +104,8 @@ public class XNumberEditor extends XWrapperedFieldEditor {
return "number_field_16.png"; return "number_field_16.png";
} }
// @Override @Override
// public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
// return new WidgetPropertyUIProvider[]{new NumberEditorMobilePropertyUI(this)}; return new WidgetPropertyUIProvider[]{new NumberEditorMobilePropertyUI(this)};
// } }
} }

10
designer-form/src/main/java/com/fr/design/designer/creator/XPassword.java

@ -3,7 +3,9 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.design.designer.properties.mobile.PasswordMobilePropertyUI;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.ibutton.UIPasswordField; import com.fr.design.gui.ibutton.UIPasswordField;
import com.fr.design.mainframe.widget.editors.RegexEditor; import com.fr.design.mainframe.widget.editors.RegexEditor;
import com.fr.design.mainframe.widget.editors.WidgetValueEditor; import com.fr.design.mainframe.widget.editors.WidgetValueEditor;
@ -68,8 +70,8 @@ public class XPassword extends XWrapperedFieldEditor {
(CRPropertyDescriptor[]) ArrayUtils.addAll(sup, new CRPropertyDescriptor[]{regex, waterMark}); (CRPropertyDescriptor[]) ArrayUtils.addAll(sup, new CRPropertyDescriptor[]{regex, waterMark});
} }
// @Override @Override
// public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
// return new WidgetPropertyUIProvider[]{new PasswordMobilePropertyUI(this)}; return new WidgetPropertyUIProvider[]{new PasswordMobilePropertyUI(this)};
// } }
} }

10
designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java

@ -6,7 +6,9 @@ package com.fr.design.designer.creator;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.designer.properties.mobile.TextAreaMobilePropertyUI;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.widget.editors.RegexEditor; import com.fr.design.mainframe.widget.editors.RegexEditor;
import com.fr.design.mainframe.widget.editors.WidgetValueEditor; import com.fr.design.mainframe.widget.editors.WidgetValueEditor;
import com.fr.design.mainframe.widget.renderer.RegexCellRencerer; import com.fr.design.mainframe.widget.renderer.RegexCellRencerer;
@ -83,9 +85,9 @@ public class XTextArea extends XWrapperedFieldEditor {
return "text_area_16.png"; return "text_area_16.png";
} }
// @Override @Override
// public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
// return new WidgetPropertyUIProvider[]{new TextAreaMobilePropertyUI(this)}; return new WidgetPropertyUIProvider[]{new TextAreaMobilePropertyUI(this)};
// } }
} }

9
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TextEditorMobileDefinePane.java

@ -3,6 +3,7 @@ package com.fr.design.widget.ui.designer.mobile;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.widget.ui.designer.mobile.component.MobileTextEditSettingPane;
import com.fr.design.widget.ui.designer.mobile.component.MobileTextFieldInputSettingPane; import com.fr.design.widget.ui.designer.mobile.component.MobileTextFieldInputSettingPane;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
@ -30,10 +31,8 @@ public class TextEditorMobileDefinePane extends BaseTextEditorMobileDefinePane {
@Override @Override
protected void initSettingPane(JPanel container) { protected void initSettingPane(JPanel container) {
inputSettingPane = new MobileTextFieldInputSettingPane(); inputSettingPane = new MobileTextFieldInputSettingPane();
/// 延期,屏蔽入口 textSettingPane = new MobileTextEditSettingPane();
/// textSettingPane = new MobileTextEditSettingPane();
container.add(inputSettingPane); container.add(inputSettingPane);
/// container.add(textSettingPane);
} }
@ -41,7 +40,7 @@ public class TextEditorMobileDefinePane extends BaseTextEditorMobileDefinePane {
public void populate(FormDesigner designer) { public void populate(FormDesigner designer) {
TextEditor textEditor = (TextEditor) getxCreator().toData(); TextEditor textEditor = (TextEditor) getxCreator().toData();
inputSettingPane.populateBean(textEditor.getMobileScanCodeAttr()); inputSettingPane.populateBean(textEditor.getMobileScanCodeAttr());
/// textSettingPane.populateBean(textEditor.getMobileTextEditAttr()); textSettingPane.populateBean(textEditor.getMobileTextEditAttr());
this.bindListeners2Widgets(); this.bindListeners2Widgets();
} }
@ -49,7 +48,7 @@ public class TextEditorMobileDefinePane extends BaseTextEditorMobileDefinePane {
public void update() { public void update() {
TextEditor textEditor = (TextEditor) getxCreator().toData(); TextEditor textEditor = (TextEditor) getxCreator().toData();
inputSettingPane.updateBean(textEditor.getMobileScanCodeAttr()); inputSettingPane.updateBean(textEditor.getMobileScanCodeAttr());
/// textSettingPane.updateBean(textEditor.getMobileTextEditAttr()); textSettingPane.updateBean(textEditor.getMobileTextEditAttr());
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
} }

13
designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapterTest.java

@ -7,15 +7,28 @@ import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.designer.creator.XButton; import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.i18n.Toolkit;
import com.fr.form.ui.Button; import com.fr.form.ui.Button;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import java.awt.Dimension; import java.awt.Dimension;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert; 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;
@RunWith(PowerMockRunner.class)
@PrepareForTest({Toolkit.class})
@PowerMockIgnore("javax.swing.*")
public class FRAbsoluteLayoutAdapterTest extends TestCase { public class FRAbsoluteLayoutAdapterTest extends TestCase {
@Override @Override
protected void setUp() throws Exception { 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.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao()); DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); DaoContext.setXmlEntityDao(new LocalXmlEntityDao());

6
designer-form/src/test/java/com/fr/design/fit/PXReportLengthUNITTest.java

@ -1,6 +1,7 @@
package com.fr.design.fit; package com.fr.design.fit;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.PXReportLengthUNIT; import com.fr.design.mainframe.PXReportLengthUNIT;
import com.fr.stable.unit.FU; import com.fr.stable.unit.FU;
import org.easymock.EasyMock; import org.easymock.EasyMock;
@ -15,11 +16,14 @@ import org.powermock.modules.junit4.PowerMockRunner;
* Created by kerry on 2020-04-24 * Created by kerry on 2020-04-24
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest(ScreenResolution.class) @PrepareForTest({ScreenResolution.class, Toolkit.class})
public class PXReportLengthUNITTest { public class PXReportLengthUNITTest {
@Test @Test
public void testUnitText() { public void testUnitText() {
PowerMock.mockStatic(Toolkit.class);
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
PowerMock.replayAll();
PXReportLengthUNIT pxReportLengthUNIT = new PXReportLengthUNIT(); PXReportLengthUNIT pxReportLengthUNIT = new PXReportLengthUNIT();
Assert.assertEquals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), pxReportLengthUNIT.unitText()); Assert.assertEquals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), pxReportLengthUNIT.unitText());
} }

2
designer-form/src/test/java/com/fr/design/preview/DeveloperPreviewTest.java

@ -17,7 +17,7 @@ public class DeveloperPreviewTest {
DeveloperPreview formPreview = new DeveloperPreview(); DeveloperPreview formPreview = new DeveloperPreview();
Map<String, Object> map = formPreview.parametersForPreview(); Map<String, Object> map = formPreview.parametersForPreview();
Assert.assertEquals(1, map.size()); Assert.assertEquals(1, map.size());
Assert.assertEquals("developer_preview", map.get(ParameterConstants.OP)); Assert.assertEquals("editable_preview", map.get(ParameterConstants.OP));
} }
@Test @Test

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 * Created by kerry on 2020-04-24
*/ */
public class FormAdaptivePreviewTest { public class FormAdaptivePreviewTest {
@Test
public void testParametersForPreview() {
FormAdaptivePreview formPreview = new FormAdaptivePreview();
Map<String, Object> map = formPreview.parametersForPreview();
Assert.assertEquals(1, map.size());
Assert.assertEquals("form_adaptive", map.get(ParameterConstants.OP));
}
@Test @Test
public void testAccept() { public void testAccept() {
FormAdaptivePreview formPreview = new FormAdaptivePreview(); FormAdaptivePreview formPreview = new FormAdaptivePreview();

13
designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java

@ -4,8 +4,14 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.fun.CellWidgetOptionProvider;
import com.fr.design.widget.mobile.WidgetMobilePane; import com.fr.design.widget.mobile.WidgetMobilePane;
import com.fr.design.widget.ui.mobile.MultiFileEditorMobilePane; import com.fr.design.widget.ui.mobile.MultiFileEditorMobilePane;
import com.fr.design.widget.ui.mobile.NumberEditorMobilePane;
import com.fr.design.widget.ui.mobile.PasswordMobilePane;
import com.fr.design.widget.ui.mobile.TextAreaMobilePane;
import com.fr.design.widget.ui.mobile.TextEditorMobilePane; import com.fr.design.widget.ui.mobile.TextEditorMobilePane;
import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.MultiFileEditor;
import com.fr.form.ui.NumberEditor;
import com.fr.form.ui.Password;
import com.fr.form.ui.TextArea;
import com.fr.form.ui.TextEditor; import com.fr.form.ui.TextEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
@ -29,10 +35,9 @@ public class WidgetMobilePaneFactory {
static { static {
mobilePaneMap.put(MultiFileEditor.class, MultiFileEditorMobilePane.class); mobilePaneMap.put(MultiFileEditor.class, MultiFileEditorMobilePane.class);
mobilePaneMap.put(TextEditor.class, TextEditorMobilePane.class); mobilePaneMap.put(TextEditor.class, TextEditorMobilePane.class);
/// 此版本不发布,先屏蔽入口 mobilePaneMap.put(TextArea.class, TextAreaMobilePane.class);
/// mobilePaneMap.put(TextArea.class, TextAreaMobilePane.class); mobilePaneMap.put(NumberEditor.class, NumberEditorMobilePane.class);
/// mobilePaneMap.put(NumberEditor.class, NumberEditorMobilePane.class); mobilePaneMap.put(Password.class, PasswordMobilePane.class);
/// mobilePaneMap.put(Password.class, PasswordMobilePane.class);
mobilePluginPaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); mobilePluginPaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap());
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { GeneralContext.listenPluginRunningChanged(new PluginEventListener() {

2
designer-realize/src/main/java/com/fr/design/widget/ui/mobile/TextEditorMobilePane.java

@ -37,7 +37,7 @@ public class TextEditorMobilePane extends WidgetMobilePane {
settingPane = new MobileTextFieldInputSettingPane(); settingPane = new MobileTextFieldInputSettingPane();
textSettingPane = new MobileTextEditSettingPane(); textSettingPane = new MobileTextEditSettingPane();
container.add(settingPane); container.add(settingPane);
/// container.add(textSettingPane); container.add(textSettingPane);
this.add(new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, container), BorderLayout.NORTH); this.add(new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, container), BorderLayout.NORTH);
} }

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

@ -1,5 +1,10 @@
package com.fr.design.mainframe; 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; import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao; import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao; import com.fr.config.dao.impl.LocalEntityDao;
@ -7,8 +12,11 @@ import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.ui.ElementCaseEditor; 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.ImageWithSuffix;
import com.fr.general.ModuleContext; import com.fr.general.ModuleContext;
import com.fr.invoke.Reflect;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.cellattr.CellImage;
@ -17,13 +25,26 @@ import com.fr.report.restriction.ReportRestrictionScene;
import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.FormElementCase;
import com.fr.report.worksheet.WorkSheet; import com.fr.report.worksheet.WorkSheet;
import com.fr.restriction.Restrictions; import com.fr.restriction.Restrictions;
import com.fr.stable.StringUtils;
import com.fr.stable.module.Module; import com.fr.stable.module.Module;
import com.fr.start.MainDesigner; import com.fr.start.MainDesigner;
import com.fr.third.guava.collect.Lists;
import com.fr.transaction.WorkerCallBack;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert; 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.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.swing.*")
public class JFileTest extends TestCase { public class JFileTest extends TestCase {
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
@ -45,6 +66,7 @@ public class JFileTest extends TestCase {
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg");
CellImage cellImage = new CellImage(); CellImage cellImage = new CellImage();
cellImage.setImage(imageWithSuffix); cellImage.setImage(imageWithSuffix);
mockJCreateConfigEnv(ReportThemeConfig.getInstance());
JWorkBook jWorkBook = new JWorkBook(workBook, "text"); JWorkBook jWorkBook = new JWorkBook(workBook, "text");
jWorkBook.setPictureElem(cellElement, cellImage); jWorkBook.setPictureElem(cellElement, cellImage);
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); Assert.assertEquals(imageWithSuffix, cellElement.getValue());
@ -61,9 +83,24 @@ public class JFileTest extends TestCase {
ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg");
CellImage cellImage = new CellImage(); CellImage cellImage = new CellImage();
cellImage.setImage(imageWithSuffix); cellImage.setImage(imageWithSuffix);
JForm jForm = new JForm(); mockJCreateConfigEnv(FormThemeConfig.getInstance());
form.setContainer(new WFitLayout());
JForm jForm = new JForm(form);
jForm.setTarget(form); jForm.setTarget(form);
jForm.setPictureElem(cellElement, cellImage); jForm.setPictureElem(cellElement, cellImage);
Assert.assertEquals(imageWithSuffix, cellElement.getValue()); 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