" {new: com.google.gwt.user.client.ui.Tree} {local-unique: tree} {/new Tree()/ /rootPanel.add(tree)/ /tree.addItem('Item text')/}",
" {implicit-factory} {local-unique: item} {/tree.addItem('Item text')/ /item.setState(true)/}");
}
public void test_parse_addItem_asWidget() throws Exception {
RootPanelInfo frame =
parseJavaInfo(
"public class Test implements EntryPoint {",
" public void onModuleLoad() {",
" RootPanel rootPanel = RootPanel.get();",
" {",
" Tree tree = new Tree();",
" rootPanel.add(tree);",
" {",
" Button button = new Button('Button text');",
" TreeItem item = tree.addItem(button);",
" item.setState(true);",
" }",
" }",
" }",
"}");
frame.refresh();
// check hierarchy
assertHierarchy(
"{RootPanel.get()} {local-unique: rootPanel} {/RootPanel.get()/ /rootPanel.add(tree)/}",
" {new: com.google.gwt.user.client.ui.Tree} {local-unique: tree} {/new Tree()/ /rootPanel.add(tree)/ /tree.addItem(button)/}",
" {implicit-factory} {local-unique: item} {/tree.addItem(button)/ /item.setState(true)/}",
" {new: com.google.gwt.user.client.ui.Button} {local-unique: button} {/new Button('Button text')/ /tree.addItem(button)/}");
TreeInfo tree = (TreeInfo) frame.getChildrenWidgets().get(0);
TreeItemInfo treeItem = tree.getItems().get(0);
WidgetInfo button = treeItem.getWidget();
// check association type, but not operations (see test for this association)
assertInstanceOf(ImplicitFactoryArgumentAssociation.class, button.getAssociation());
assertTrue(button.canDelete());