OpenAgent"
From Documentation
(Created page with "{{ZATSEssentialsPageHeader}} <!-- open a tree item --> <tt> OpenAgent </tt> is used to expand a ''treeitem'', ''listgroup'', ''detail'', ''bandbox'', ''groupbox'' or ''combob...") |
|||
Line 8: | Line 8: | ||
− | Here we use a ''tree'' with binary structure to demonstrate this agent's usage. Each 'treeitem'' has two children. | + | Here we use a ''tree'' with binary structure to demonstrate this agent's usage. Each ''treeitem'' has two children. |
[[File:Smalltalk-mimic-open.png]] | [[File:Smalltalk-mimic-open.png]] |
Revision as of 09:17, 15 May 2012
OpenAgent is used to expand a treeitem, listgroup, detail, bandbox, groupbox or combobutton etc.
Here we use a tree with binary structure to demonstrate this agent's usage. Each treeitem has two children.
In the test case below, we expand the first treeitem (node1) and its first child treeitem (node3), then first treeitem's visible item count should be 5. Before expanding, its visible item count is 1(only itself).
OpenTest.java
@Test
public void testAgent() {
DesktopAgent desktop = Zats.newClient().connect("/open-tree.zul");
ComponentAgent firstItem = desktop.query("#tree").query("treeitem");
Assert.assertEquals(1, firstItem.as(Treeitem.class).getVisibleItemCount());
//open first item
firstItem.as(OpenAgent.class).open(true);
firstItem.query("treechildren").query("treeitem").as(OpenAgent.class).open(true);
Assert.assertEquals(5, firstItem.as(Treeitem.class).getVisibleItemCount());
//collapse first item
firstItem.as(OpenAgent.class).open(false);
Assert.assertEquals(1, firstItem.as(Treeitem.class).getVisibleItemCount());
}
- Although there are two treeitem, query() only returns the first one. (line 3)
- Before expanding, its visible item count is one(only itself). (line 6)
- After we expand the first treeitem and its first child item, its visible item count should now be five as shown in the image above. (line 8-9)
- Call open(false) to collapse first treeitem, and its visible item count comes back to one. (line 12)