You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.1 KiB
59 lines
2.1 KiB
package com.fr.design.mainframe; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
import com.fr.invoke.Reflect; |
|
import org.easymock.EasyMock; |
|
import org.junit.Assert; |
|
import org.junit.Before; |
|
import org.junit.Ignore; |
|
import org.junit.Test; |
|
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; |
|
|
|
/** |
|
* Created by kerry on 2020-07-28 |
|
*/ |
|
@RunWith(PowerMockRunner.class) |
|
@PrepareForTest({Toolkit.class}) |
|
@PowerMockIgnore("javax.swing.*") |
|
public class JFormSliderPaneTest { |
|
|
|
@Before |
|
public void setUp() throws Exception { |
|
PowerMock.mockStatic(Toolkit.class); |
|
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); |
|
PowerMock.replayAll(); |
|
} |
|
|
|
@Ignore("涉及到UI") |
|
@Test |
|
public void testGetPreferredValue() { |
|
JFormSliderPane sliderPane = new JFormSliderPane(); |
|
int result = Reflect.on(sliderPane).call("getPreferredValue", 100).get(); |
|
Assert.assertEquals(100, result); |
|
result = Reflect.on(sliderPane).call("getPreferredValue", 0).get(); |
|
Assert.assertEquals(10, result); |
|
result = Reflect.on(sliderPane).call("getPreferredValue", 1000).get(); |
|
Assert.assertEquals(400, result); |
|
} |
|
|
|
@Ignore("涉及到UI") |
|
@Test |
|
public void testCalSliderValue() { |
|
JFormSliderPane sliderPane = new JFormSliderPane(); |
|
int result = Reflect.on(sliderPane).call("calSliderValue", 10).get(); |
|
Assert.assertEquals(0, result); |
|
result = Reflect.on(sliderPane).call("calSliderValue", 90).get(); |
|
Assert.assertEquals(44, result); |
|
result = Reflect.on(sliderPane).call("calSliderValue", 100).get(); |
|
Assert.assertEquals(50, result); |
|
result = Reflect.on(sliderPane).call("calSliderValue", 200).get(); |
|
Assert.assertEquals(66, result); |
|
result = Reflect.on(sliderPane).call("calSliderValue", 400).get(); |
|
Assert.assertEquals(100, result); |
|
|
|
} |
|
}
|
|
|