|
|
|
package com.fr.design.actions.help;
|
|
|
|
|
|
|
|
import com.fr.base.svg.SystemScaleUtils;
|
|
|
|
import com.fr.design.i18n.Toolkit;
|
|
|
|
import com.fr.general.GeneralContext;
|
|
|
|
import com.fr.stable.ProductConstants;
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
import org.easymock.EasyMock;
|
|
|
|
import org.junit.Ignore;
|
|
|
|
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.Locale;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@RunWith(PowerMockRunner.class)
|
|
|
|
@PowerMockIgnore({"javax.management.*","javax.net.ssl.*"})
|
|
|
|
@PrepareForTest({Toolkit.class, SystemScaleUtils.class})
|
|
|
|
@Ignore("涉及到UI")
|
|
|
|
public class TutorialActionTest extends TestCase {
|
|
|
|
|
|
|
|
public void setUp() {
|
|
|
|
PowerMock.mockStatic(Toolkit.class);
|
|
|
|
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes();
|
|
|
|
PowerMock.mockStatic(SystemScaleUtils.class);
|
|
|
|
EasyMock.expect(SystemScaleUtils.sysScale()).andReturn(1F).anyTimes();
|
|
|
|
EasyMock.expect(SystemScaleUtils.isJreHiDPIEnabled()).andReturn(false).anyTimes();
|
|
|
|
PowerMock.replayAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testCreateKey() {
|
|
|
|
TutorialAction action = new TutorialAction();
|
|
|
|
GeneralContext.setLocale(Locale.US);
|
|
|
|
String enKey = action.createDocKey();
|
|
|
|
assertTrue(enKey.contains(Locale.US.toString()));
|
|
|
|
assertTrue(enKey.contains(ProductConstants.MAIN_VERSION));
|
|
|
|
|
|
|
|
GeneralContext.setLocale(Locale.CHINA);
|
|
|
|
String zhKey = action.createDocKey();
|
|
|
|
assertTrue(zhKey.contains(Locale.CHINA.toString()));
|
|
|
|
|
|
|
|
Locale pt = new Locale("pt", "PT");
|
|
|
|
GeneralContext.setLocale(pt);
|
|
|
|
String ptKey = action.createDocKey();
|
|
|
|
assertTrue(ptKey.contains(pt.toString()));
|
|
|
|
GeneralContext.setLocale(Locale.CHINA);
|
|
|
|
}
|
|
|
|
|
|
|
|
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"));
|
|
|
|
}
|
|
|
|
}
|