Assert.assertEquals(new Long(3), plistBox2.getValue(2));
Assert.assertEquals(new Long(4), plistBox2.getValue(3));
Assert.assertEquals(new Long(5), plistBox2.getValue(4));
Assert.assertEquals(new Long(6), plistBox2.getValue(5));
final Select select2 = new Select(listBox2);
select2.selectByIndex(4); // select item5
final PChangeEvent e2 = eventsListener.poll();
Assert.assertNotNull(e2);
Assert.assertEquals(4, plistBox2.getSelectedIndex());
Assert.assertEquals("Item 5", plistBox2.getSelectedItem());
Assert.assertEquals(new Long(5), plistBox2.getSelectedValue());
// remove
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PListBox listBox2 = get("listBox2");
listBox2.removeItem("Item 2");
listBox2.removeItem(2);
listBox2.removeValue(new Long(6));
}
});
options2 = listBox2.findElements(By.tagName("option"));
Assert.assertEquals(3, options2.size());
Assert.assertEquals("Item 1", options2.get(0).getText());
Assert.assertEquals("Item 3", options2.get(1).getText());
Assert.assertEquals("Item 5", options2.get(2).getText());
Assert.assertEquals(3, plistBox2.getItemCount());
Assert.assertEquals("Item 1", plistBox2.getItem(0));
Assert.assertEquals("Item 3", plistBox2.getItem(1));
Assert.assertEquals("Item 5", plistBox2.getItem(2));
Assert.assertEquals(new Long(1), plistBox2.getValue(0));
Assert.assertEquals(new Long(3), plistBox2.getValue(1));
Assert.assertEquals(new Long(5), plistBox2.getValue(2));
// server-side selection
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PListBox listBox2 = get("listBox2");
listBox2.setSelectedValue(new Long(3)); // select item3
}
});
final WebElement selectedOption2 = select2.getFirstSelectedOption();
Assert.assertEquals("Item 3", selectedOption2.getText());
Assert.assertEquals("Item 3", plistBox2.getSelectedItem());
Assert.assertEquals(new Long(3), plistBox2.getSelectedValue());
// TODO