Joe.Jiang
5 years ago
9 changed files with 289 additions and 90 deletions
@ -0,0 +1,39 @@
|
||||
package com.fr.design.designer.beans.adapters.layout; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XLayoutContainer; |
||||
|
||||
/** |
||||
* 针对tabpane的布局适配器 |
||||
* Created by kerry on 2019-12-10 |
||||
*/ |
||||
public class FRWCardTagLayoutAdapter extends AbstractLayoutAdapter { |
||||
public FRWCardTagLayoutAdapter(XLayoutContainer container) { |
||||
super(container); |
||||
} |
||||
|
||||
/** |
||||
* 对于这种布局方式,不允许其他组件添加 |
||||
* |
||||
* @param creator |
||||
* @param x |
||||
* @param y |
||||
*/ |
||||
@Override |
||||
protected void addComp(XCreator creator, int x, int y) { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 对于这种布局方式,不允许其他组件添加 |
||||
* |
||||
* @param creator 组件 |
||||
* @param x 添加的位置x,该位置是相对于container的 |
||||
* @param y 添加的位置y,该位置是相对于container的 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public boolean accept(XCreator creator, int x, int y) { |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.designer.beans.adapters.layout; |
||||
|
||||
import com.fr.design.designer.creator.XElementCase; |
||||
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; |
||||
import com.fr.form.ui.ElementCaseEditor; |
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.awt.Dimension; |
||||
|
||||
/** |
||||
* Created by kerry on 2019-12-10 |
||||
*/ |
||||
public class FRWCardTagLayoutAdapterTest { |
||||
@Test |
||||
public void testAccept() { |
||||
FRWCardTagLayoutAdapter adapter = new FRWCardTagLayoutAdapter( |
||||
new XWCardTagLayout(new WCardTagLayout(), new Dimension(100, 100))); |
||||
Assert.assertFalse(adapter.accept(new XElementCase( |
||||
new ElementCaseEditor(), new Dimension(100, 100)), 1, 1)); |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.design.designer.creator.cardlayout; |
||||
|
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.awt.Dimension; |
||||
|
||||
/** |
||||
* Created by kerry on 2019-12-10 |
||||
*/ |
||||
public class XWCardTagLayoutTest { |
||||
@Test |
||||
public void testGetLayoutAdapter() { |
||||
XWCardTagLayout tagLayout = new XWCardTagLayout(new WCardTagLayout(), new Dimension(100, 100)); |
||||
Assert.assertEquals("com.fr.design.designer.beans.adapters.layout.FRWCardTagLayoutAdapter", tagLayout.getLayoutAdapter().getClass().getName()); |
||||
} |
||||
} |
@ -0,0 +1,60 @@
|
||||
package com.fr.design.mainframe.socketio; |
||||
|
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.Workspace; |
||||
import io.socket.client.IO; |
||||
import io.socket.client.Socket; |
||||
|
||||
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.modules.junit4.PowerMockRunner; |
||||
|
||||
|
||||
/** |
||||
* @author: Maksim |
||||
* @Date: Created in 2019/12/9 |
||||
* @Description: |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({WorkContext.class,DesignerSocketIO.class, IO.class}) |
||||
public class DesignerSocketIOTest { |
||||
|
||||
@Test |
||||
public void close() throws Exception { |
||||
this.update(); |
||||
DesignerSocketIO.close(); |
||||
DesignerSocketIO.Status status = Reflect.on(DesignerSocketIO.class).field("status").get(); |
||||
Socket socket = Reflect.on(DesignerSocketIO.class).field("socket").get(); |
||||
|
||||
Assert.assertEquals(DesignerSocketIO.Status.Disconnecting,status); |
||||
Assert.assertNull(socket); |
||||
} |
||||
|
||||
@Test |
||||
public void update() throws Exception { |
||||
Workspace current = EasyMock.mock(Workspace.class); |
||||
EasyMock.expect(current.isLocal()).andReturn(false); |
||||
|
||||
PowerMock.mockStatic(WorkContext.class); |
||||
EasyMock.expect(WorkContext.getCurrent()).andReturn(current); |
||||
|
||||
String[] uri = {"http://127.0.0.1:8888/workspace","http://127.0.0.1:9999/workspace"}; |
||||
PowerMock.mockStaticPartial(DesignerSocketIO.class,"getSocketUri"); |
||||
PowerMock.expectPrivate(DesignerSocketIO.class,"getSocketUri").andReturn(uri); |
||||
|
||||
EasyMock.replay(current); |
||||
PowerMock.replayAll(); |
||||
|
||||
DesignerSocketIO.update(); |
||||
DesignerSocketIO.Status status = Reflect.on(DesignerSocketIO.class).field("status").get(); |
||||
Socket socket = Reflect.on(DesignerSocketIO.class).field("socket").get(); |
||||
|
||||
Assert.assertEquals(DesignerSocketIO.Status.Connected,status); |
||||
Assert.assertNotNull(socket); |
||||
} |
||||
} |
Loading…
Reference in new issue