@Test public void testSetImageUrl() { WButton button = new WButton(); button.setLocked(true); String imageUrl = "http://127.0.0.1/image.jpg"; setActiveContext(createUIContext()); button.setImageUrl(imageUrl); button.setLocked(true); Assert.assertEquals("Uic 1 image url should be returned for uic 1", imageUrl, button. getImageUrl()); Assert. assertFalse("Button should not be in default state for uic1", button. isDefaultState()); resetContext(); Assert.assertNull("Default image url should be null", button.getImageUrl()); }
@Test public void testSetImagePosition() { WButton button = new WButton(); button.setLocked(true); setActiveContext(createUIContext()); button.setImagePosition(ImagePosition.EAST); button.setLocked(true); Assert.assertEquals("Uic 1 image position should be returned for uic 1", ImagePosition.EAST, button.getImagePosition()); Assert. assertFalse("Button should not be in default state for uic1", button. isDefaultState()); resetContext(); Assert.assertNull("Default image position should be null", button.getImagePosition()); }
@Test public void testSetActionCommand() { String text = "WButton_Test.text"; String sharedValue = "WButton_Test.sharedValue"; String value = "WButton_Test.value"; UIContext uic1 = new UIContextImpl(); WButton button = new WButton(text); button.setLocked(true); Assert.assertEquals("Default action command should be button text", text, button. getActionCommand()); button.setActionCommand(sharedValue); Assert.assertEquals("Incorrect shared action command returned", sharedValue, button. getActionCommand()); setActiveContext(uic1); button.setActionCommand(value); Assert.assertEquals("Uic 1 action command should be returned for uic 1", value, button. getActionCommand()); Assert. assertFalse("Button should not be in default state for uic1", button. isDefaultState()); resetContext(); Assert.assertEquals("Incorrect shared action command returned", sharedValue, button. getActionCommand()); }
@Test public void testSetPressed() { WButton button = new WButton("Test"); button.setLocked(true); setActiveContext(createUIContext()); button.setPressed(true, new MockRequest()); Assert.assertTrue("Button should be pressed", button.isPressed()); Assert.assertFalse("Button should not be in default state", button.isDefaultState()); button.setPressed(false, new MockRequest()); Assert.assertFalse("Button should be pressed", button.isPressed()); button.setDisabled(true); button.setPressed(true, new MockRequest()); Assert.assertTrue("Button should be disabled", button.isDisabled()); Assert.assertFalse("Button should be pressed when disabled", button.isPressed()); }