zheng
6 years ago
35 changed files with 711 additions and 677 deletions
@ -0,0 +1,33 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.locale.InterProviderFactory; |
||||
import junit.framework.TestCase; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.Locale; |
||||
|
||||
public class DesignerEnvManagerTest extends TestCase{ |
||||
|
||||
public void testGetLocale() { |
||||
DesignerEnvManager envManager = new DesignerEnvManager(); |
||||
assertEquals("默认值", envManager.getLocale(), Locale.CHINA); |
||||
|
||||
HashSet<Locale> result = new HashSet<>(); |
||||
Locale[] locales = envManager.supportLocale(); |
||||
int len = locales.length; |
||||
assertEquals(len, InterProviderFactory.getProvider().getSupportLocaleMap().size()); |
||||
for (int i = 0; i < len; i++) { |
||||
envManager.setLanguage(i + 1); |
||||
Locale locale = envManager.getLocale(); |
||||
result.add(locale); |
||||
} |
||||
assertEquals("每个int都有对应的locale", result.size(), len); |
||||
|
||||
envManager.setLanguage(998); |
||||
assertEquals("上边界", envManager.getLocale(), Locale.CHINA); |
||||
|
||||
envManager.setLanguage(-998); |
||||
assertEquals("下边界", envManager.getLocale(), Locale.CHINA); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.design.actions.help; |
||||
|
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.stable.ProductConstants; |
||||
import junit.framework.TestCase; |
||||
|
||||
import java.util.Locale; |
||||
import java.util.UUID; |
||||
|
||||
public class TutorialActionTest extends TestCase{ |
||||
|
||||
public void testCreateKey() { |
||||
TutorialAction action = new TutorialAction(); |
||||
GeneralContext.setLocale(Locale.US); |
||||
String enKey = action.createDocKey(); |
||||
assertTrue(enKey.indexOf(Locale.US.toString()) != -1); |
||||
assertTrue(enKey.indexOf(ProductConstants.MAIN_VERSION) != -1); |
||||
|
||||
GeneralContext.setLocale(Locale.CHINA); |
||||
String zhKey = action.createDocKey(); |
||||
assertTrue(zhKey.indexOf(Locale.CHINA.toString()) != -1); |
||||
|
||||
Locale pt = new Locale("pt", "PT"); |
||||
GeneralContext.setLocale(pt); |
||||
String ptKey = action.createDocKey(); |
||||
assertTrue(ptKey.indexOf(pt.toString()) != -1); |
||||
|
||||
GeneralContext.setLanguage(998); |
||||
assertTrue(action.createDocKey().indexOf(Locale.CHINA.toString()) != -1); |
||||
} |
||||
|
||||
public void testServerOnline() { |
||||
TutorialAction action = new TutorialAction(); |
||||
assertFalse(action.isServerOnline(null)); |
||||
assertFalse(action.isServerOnline("中文")); |
||||
assertTrue("百度暂时不会挂", action.isServerOnline("http://www.baidu.com")); |
||||
assertTrue("https测试", action.isServerOnline("https://www.baidu.com")); |
||||
assertFalse("连上是正常的", action.isServerOnline("https://www.fine-" + UUID.randomUUID() + ".com")); |
||||
} |
||||
} |
@ -1,63 +0,0 @@
|
||||
package com.fr.design.chart.axis; |
||||
|
||||
|
||||
import com.fr.general.NameObject; |
||||
import com.fr.stable.Nameable; |
||||
import com.fr.chart.chartattr.ChartAlertValue; |
||||
import com.fr.design.gui.controlpane.JListControlPane; |
||||
import com.fr.design.gui.controlpane.NameObjectCreator; |
||||
import com.fr.design.gui.controlpane.NameableCreator; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class ChartAlertLinePane extends JListControlPane { |
||||
|
||||
public NameableCreator[] createNameableCreators() { |
||||
return new NameableCreator[]{ |
||||
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("ChartF-Alert-Line"), |
||||
ChartAlertValue.class, ChartAlertValuePane.class) |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Edit", "ChartF-Alert-Line"}); |
||||
} |
||||
|
||||
public void populate(ChartAlertValue[] alertList) { |
||||
if (alertList == null) { |
||||
alertList = new ChartAlertValue[0]; |
||||
} |
||||
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
||||
|
||||
for (int i = 0; i < alertList.length; i++) { |
||||
ChartAlertValue value = alertList[i]; |
||||
nameObjectList.add(new NameObject(value.getAlertPaneSelectName(), value)); |
||||
} |
||||
|
||||
if (!nameObjectList.isEmpty()) { |
||||
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); |
||||
} |
||||
} |
||||
|
||||
public ChartAlertValue[] updateAlertValues() { |
||||
Nameable[] res = update(); |
||||
|
||||
NameObject[] res_array = new NameObject[res.length]; |
||||
java.util.Arrays.asList(res).toArray(res_array); |
||||
|
||||
if (res_array.length < 1) { |
||||
return new ChartAlertValue[0]; |
||||
} |
||||
|
||||
List alertValueList = new ArrayList(); |
||||
for (int i = 0; i < res_array.length; i++) { |
||||
NameObject nameObject = res_array[i]; |
||||
ChartAlertValue chartAlertValue = (ChartAlertValue) nameObject.getObject(); |
||||
chartAlertValue.setAlertPaneSelectName(nameObject.getName()); |
||||
alertValueList.add(chartAlertValue); |
||||
} |
||||
return (ChartAlertValue[]) alertValueList.toArray(new ChartAlertValue[alertValueList.size()]); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue