UNPKG

ui5-test-runner

Version:
90 lines (86 loc) 2.46 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script id='sap-ui-bootstrap' src='https://ui5.sap.com/resources/sap-ui-core.js' data-sap-ui-libs='sap.m' data-sap-ui-theme='sap_horizon' data-sap-ui-compatVersion='edge'> </script> <script id="myXml" type="text/xmldata"> <mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="myController" displayBlock="true"> <App> <Page title="Table Example"> <Table id="myTable" items="{/items}" mode="SingleSelectMaster" > <headerToolbar> <Toolbar> <Title text="Sample Table"/> </Toolbar> </headerToolbar> <columns> <Column> <Text text="Name"/> </Column> <Column> <Text text="Age"/> </Column> </columns> <items> <ColumnListItem> <cells> <Text text="{name}"/> <Text text="{age}"/> </cells> </ColumnListItem> </items> </Table> </Page> </App> </mvc:View> </script> <script> sap.ui.require([ "sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/m/Dialog", "sap/m/Button" ], function (Controller, XMLView, Dialog, Button) { Controller.extend("myController", { onInit: function () { var model = new sap.ui.model.json.JSONModel(); model.setData({ items: [ {name: "John Doe", age: 30}, {name: "Jane Smith", age: 25}, {name: "Max Mustermann", age: 40} ] }); this.getView().setModel(model); // Set focus on the second row this.getView().byId("myTable").attachEventOnce("updateFinished", function() { // Need to do it asynchronously or the first item is selected instead setTimeout(() => { const listItem = this.getItems()[1]; listItem.focus(); // Notify the test framework const xhr = new XMLHttpRequest(); xhr.open('POST', '/_/log'); xhr.send(JSON.stringify({ 'is-focus-set': document.activeElement.id === listItem.getFocusDomRef()?.id, })); }, 0); }); } }); XMLView.create({definition: jQuery('#myXml').html()}).then(function (oView) { oView.placeAt(document.querySelector('body')); }); }); </script> </head> <body class='sapUiBody'></body> </html>