From 47540321b5829aa21eb03177b32625842a00b626 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 30 Jul 2019 11:35:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/AlphaFineHelperTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java new file mode 100644 index 000000000..3c14275b7 --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java @@ -0,0 +1,46 @@ +package com.fr.design.mainframe.alphafine; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; +import com.fr.general.GeneralContext; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; + +import static org.junit.Assert.*; + +@RunWith(PowerMockRunner.class) +public class AlphaFineHelperTest { + + @Test + @PrepareForTest({GeneralContext.class, DesignerEnvManager.class}) + @SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper") + public void testSwitchConfig4Locale() throws Exception { + + PowerMock.mockStatic(GeneralContext.class); + EasyMock.expect(GeneralContext.isChineseEnv()).andReturn(true).times(1).andReturn(false).times(1); + + DesignerEnvManager manager = EasyMock.mock(DesignerEnvManager.class); + EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(new AlphaFineConfigManager()).anyTimes(); + EasyMock.replay(manager); + + PowerMock.mockStatic(DesignerEnvManager.class); + EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes(); + + PowerMock.replayAll(); + + AlphaFineHelper.switchConfig4Locale(); + AlphaFineConfigManager config = manager.getAlphaFineConfigManager(); + Assert.assertEquals(true, config.isSearchOnLine()); + + AlphaFineHelper.switchConfig4Locale(); + Assert.assertEquals(false, config.isSearchOnLine()); + + + } +} \ No newline at end of file