SceneBuilderTest.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:openjfx-8u-dev-tests 作者:
@Test
public void testPrototype() {
    //find Scene Builder scene
    final SceneDock sceneBuilder = new SceneDock(new ByTitleSceneLookup<>("Scene Builder", StringComparePolicy.SUBSTRING));
    //find library panel  by node ID using Scene Builder's scene as Parent
    ListViewDock library = new ListViewDock(sceneBuilder.asParent(), ID_LIBRARY_PANEL_LIST_VIEW);

    //find button in library
    ListItemDock button = new ListItemDock(library.asList(), new ByID("Button"));

    //show list item with button by scrolling listview
    button.shower().show();

    //find design surface by node ID "Anchor Pane".
    NodeDock designSurface = new NodeDock(sceneBuilder.asParent(), "AnchorPane");

    //drag list item with button and drop in center of design surface
    button.drag().dnd(designSurface.wrap(), designSurface.wrap().getClickPoint());

    //find properties panel by node ID
    TitledPaneDock titledPaneDock = new TitledPaneDock(sceneBuilder.asParent(), "Properties");

    //find text field for property "Text"
    TextInputControlDock textField = new TextInputControlDock(new NodeDock(titledPaneDock.asParent(), "TextValue").asParent());
    //clear and type text
    textField.clear();
    textField.type("Submit");
    //push enter to complete
    textField.keyboard().pushKey(Keyboard.KeyboardButtons.ENTER);

    //Add text field/////////////////////////////////////////////////////////////////////////////////////////////////////

    //find text field in library
    ListItemDock textFieldControl = new ListItemDock(library.asList(), new ByID("Text Field"));

    //show list item with text field by scrolling listview
    textFieldControl.shower().show();

    //drag list item with text field and drop on design surface near button
    textFieldControl.drag().dnd(designSurface.wrap(), designSurface.wrap().getClickPoint().translate(70, 50));

    //find text field on design surface and double click to invoke inline editing
    new TextInputControlDock(designSurface.asParent()).mouse().click(2);

    //find inline text field and type text "Name".
    TextInputControlDock inline = new TextInputControlDock(sceneBuilder.asParent(), ID_TEXT_INLINE_EDITING);
    inline.clear();
    inline.type("Name");
    inline.keyboard().pushKey(Keyboard.KeyboardButtons.ENTER);


    //show preview
    //find menu bar by ID then push "Preview" menu. Finally push "Show preview" menu item. All menu item have id's that help to find them.
    new MenuBarDock(sceneBuilder.asParent(), ID_MENU_BAR).menu().push(new ByIdMenuItem(ID_PREVIEW_MENU), new ByIdMenuItem(ID_PREVIEW_MENU_ITEM));

    //find preview scene. Criteria: scene is not existing scene builder scene and scene.getWindow is not PopupWindow
    SceneDock previewScene = new SceneDock(new LookupCriteria<Scene>() {
        @Override
        public boolean check(Scene cntrl) {
            return (cntrl != sceneBuilder.wrap().getControl() && !(cntrl.getWindow() instanceof PopupWindow));
        }
    });

    //find Button with text "Submit" on preview scene
    new LabeledDock(previewScene.asParent(), Button.class, new ByText<Button>("Submit"));
    //find TextField with text "Name" on preview scene
    new TextInputControlDock(previewScene.asParent(), TextField.class, new ByText<TextField>("Name"));


    try {
        Thread.sleep(5000);
    } catch (InterruptedException ex) {
        Logger.getLogger(SceneBuilderTest.class.getName()).log(Level.SEVERE, null, ex);
    }


}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号