|
|
@ -1,7 +1,17 @@ |
|
|
|
package com.fr.design.update.push; |
|
|
|
package com.fr.design.update.push; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.event.DesignerOpenedListener; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.DesignerFrame; |
|
|
|
import com.fr.invoke.Reflect; |
|
|
|
import com.fr.invoke.Reflect; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import org.easymock.EasyMock; |
|
|
|
|
|
|
|
import org.junit.BeforeClass; |
|
|
|
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.PrepareForTest; |
|
|
|
|
|
|
|
import org.powermock.modules.junit4.PowerMockRunner; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertSame; |
|
|
|
import static org.junit.Assert.assertSame; |
|
|
@ -9,7 +19,21 @@ import static org.junit.Assert.assertSame; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by plough on 2019/4/8. |
|
|
|
* Created by plough on 2019/4/8. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@RunWith(value = PowerMockRunner.class) |
|
|
|
|
|
|
|
@PrepareForTest(DesignerContext.class) |
|
|
|
public class DesignerPushUpdateManagerTest { |
|
|
|
public class DesignerPushUpdateManagerTest { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeClass |
|
|
|
|
|
|
|
public static void setUp() { |
|
|
|
|
|
|
|
DesignerFrame mockFrame = EasyMock.mock(DesignerFrame.class); |
|
|
|
|
|
|
|
mockFrame.addDesignerOpenedListener(EasyMock.anyObject(DesignerOpenedListener.class)); |
|
|
|
|
|
|
|
EasyMock.replay(mockFrame); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PowerMock.mockStatic(DesignerContext.class); |
|
|
|
|
|
|
|
EasyMock.expect(DesignerContext.getDesignerFrame()).andReturn(mockFrame).anyTimes(); |
|
|
|
|
|
|
|
PowerMock.replayAll(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testSingleton() { |
|
|
|
public void testSingleton() { |
|
|
|
DesignerPushUpdateManager m1 = DesignerPushUpdateManager.getInstance(); |
|
|
|
DesignerPushUpdateManager m1 = DesignerPushUpdateManager.getInstance(); |
|
|
@ -29,4 +53,24 @@ public class DesignerPushUpdateManagerTest { |
|
|
|
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", false, false).get()); |
|
|
|
assertEquals(false, Reflect.on(pushUpdateManager).call("isAutoPushUpdateSupported", false, false).get()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void testSkipCurrentPushVersion() { |
|
|
|
|
|
|
|
DesignerPushUpdateManager pushUpdateManager = DesignerPushUpdateManager.getInstance(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. updateInfo 为 null 的情况
|
|
|
|
|
|
|
|
pushUpdateManager.skipCurrentPushVersion(); |
|
|
|
|
|
|
|
assertEquals(StringUtils.EMPTY, DesignerPushUpdateConfigManager.getInstance().getLastIgnoredVersion()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. updateInfo 有值的情况
|
|
|
|
|
|
|
|
final String PUSH_VERSION = "stable-2019.02.03.12.44.22"; |
|
|
|
|
|
|
|
DesignerUpdateInfo mockInfo = EasyMock.mock(DesignerUpdateInfo.class); |
|
|
|
|
|
|
|
EasyMock.expect(mockInfo.getPushVersion()).andReturn(PUSH_VERSION).anyTimes(); |
|
|
|
|
|
|
|
Reflect.on(pushUpdateManager).set("updateInfo", mockInfo); |
|
|
|
|
|
|
|
EasyMock.replay(mockInfo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pushUpdateManager.skipCurrentPushVersion(); |
|
|
|
|
|
|
|
assertEquals(PUSH_VERSION, DesignerPushUpdateConfigManager.getInstance().getLastIgnoredVersion()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|