-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API alignment for UI5 managed objects between browser- and Node.js-scope, yet excluding fluent api support Co-authored-by: dominik.feininger <[email protected]> Co-authored-by: Volker Buzek <[email protected]>
- Loading branch information
1 parent
4e6be0c
commit 2bca472
Showing
11 changed files
with
344 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
async function clientSide_executeObjectMethod(uuid, methodName, args) { | ||
return await browser.executeAsync( | ||
(uuid, methodName, args, done) => { | ||
window.wdi5.waitForUI5( | ||
window.wdi5.waitForUI5Options, | ||
() => { | ||
// DOM to UI5 | ||
const oObject = window.wdi5.objectMap[uuid] | ||
|
||
// execute the function | ||
// TODO: if (methodName === "getName") { debugger } | ||
let result = oObject[methodName].apply(oObject, args) | ||
|
||
// result mus be a primitive | ||
if (window.wdi5.isPrimitive(result)) { | ||
// getter | ||
done({ status: 0, result: result, returnType: "result" }) | ||
} else { | ||
// create new object | ||
const uuid = window.wdi5.saveObject(result) | ||
const aProtoFunctions = window.wdi5.retrieveControlMethods(result, true) | ||
|
||
result = window.wdi5.collapseObject(result) | ||
|
||
const collapsedAndNonCyclic = JSON.parse( | ||
JSON.stringify(result, window.wdi5.getCircularReplacer()) | ||
) | ||
|
||
done({ | ||
status: 0, | ||
object: collapsedAndNonCyclic, | ||
uuid: uuid, | ||
returnType: "object", | ||
aProtoFunctions: aProtoFunctions | ||
}) | ||
} | ||
}, | ||
window.wdi5.errorHandling.bind(this, done) | ||
) | ||
}, | ||
uuid, | ||
methodName, | ||
args | ||
) | ||
} | ||
|
||
module.exports = { | ||
clientSide_executeObjectMethod | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
async function clientSide_getObject(uuid) { | ||
return await browser.executeAsync((uuid, done) => { | ||
const waitForUI5Options = Object.assign({}, window.wdi5.waitForUI5Options) | ||
|
||
window.wdi5.waitForUI5( | ||
waitForUI5Options, | ||
() => { | ||
window.wdi5.Log.info("[browser wdi5] locating object " + uuid) | ||
|
||
let object = window.wdi5.objectMap[uuid] | ||
if (!object) { | ||
const errorMessage = `[browser wdi5] ERR: no object with uuid: ${uuid} found` | ||
window.wdi5.Log.error(errorMessage) | ||
done({ status: 1, messsage: errorMessage }) | ||
} | ||
|
||
let className = "" | ||
if (object && object.getMetadata) { | ||
className = object.getMetadata()._sClassName | ||
} | ||
window.wdi5.Log.info(`[browser wdi5] object with uuid: ${uuid} located!`) | ||
|
||
// FIXME: extract, collapse and remove cylic in 1 step | ||
|
||
const aProtoFunctions = window.wdi5.retrieveControlMethods(object, true) | ||
|
||
object = window.wdi5.collapseObject(object) | ||
|
||
const collapsedAndNonCyclic = JSON.parse(JSON.stringify(object, window.wdi5.getCircularReplacer())) | ||
|
||
done({ | ||
status: 0, | ||
uuid: uuid, | ||
aProtoFunctions: aProtoFunctions, | ||
className: className, | ||
object: collapsedAndNonCyclic | ||
}) | ||
}, | ||
window.wdi5.errorHandling.bind(this, done) | ||
) | ||
}, uuid) | ||
} | ||
|
||
module.exports = { | ||
clientSide_getObject | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const Main = require("./pageObjects/Main") | ||
const marky = require("marky") | ||
const { wdi5 } = require("wdio-ui5-service") | ||
const Other = require("./pageObjects/Other") | ||
|
||
const titleSelector = { selector: { id: "container-Sample---Main--Title::NoAction.h1" } } | ||
|
||
const buttonSelector = { | ||
wdio_ui5_key: "allButtons", | ||
selector: { | ||
controlType: "sap.m.Button", | ||
viewName: "test.Sample.view.Main", | ||
properties: { | ||
text: new RegExp(/.*ialog.*/gm) | ||
} | ||
} | ||
} | ||
|
||
describe("ui5 object tests", () => { | ||
before(async () => { | ||
await Main.open() | ||
}) | ||
|
||
it("check getBinding returns a proper object", async () => { | ||
const title = await browser.asControl(titleSelector) | ||
const bindingInfo = await title.getBinding("text") | ||
// bindingInfo is an object and it's oValue property can be accessed | ||
const response = bindingInfo.oValue | ||
expect(response).toEqual("UI5 demo") | ||
}) | ||
|
||
it("check getBinding returns a wdi5 object with functions", async () => { | ||
const title = await browser.asControl(titleSelector) | ||
const bindingInfo = await title.getBinding("text") | ||
// bindingInfo is an object and it's oValue property can be accessed | ||
const response = await bindingInfo.getValue() | ||
expect(response).toEqual("UI5 demo") | ||
|
||
const bindingInfoMetadata = await bindingInfo.getMetadata() | ||
const bindingTypeName = await bindingInfoMetadata.getName() | ||
expect(bindingTypeName).toEqual("sap.ui.model.resource.ResourcePropertyBinding") | ||
|
||
// new uuid interface | ||
const fullBindingInfo = await browser.asObject(bindingInfo.getUUID()) | ||
const bindingInfoMetadata_new = await fullBindingInfo.getMetadata() | ||
const bindingTypeName_new = await bindingInfoMetadata_new.getName() | ||
expect(bindingTypeName_new).toEqual("sap.ui.model.resource.ResourcePropertyBinding") | ||
}) | ||
|
||
it("check new object implementation", async () => { | ||
const input = await browser.asControl({ | ||
selector: { | ||
id: "mainUserInput", | ||
viewName: "test.Sample.view.Main" | ||
} | ||
}) | ||
// new object interface | ||
const binding = await input.getBinding("value") | ||
const path = await binding.getPath() | ||
expect(path).toEqual("/Customers('TRAIH')/ContactName") | ||
}) | ||
|
||
it("getModel and Property", async () => { | ||
const mainView = await browser.asControl({ | ||
selector: { | ||
id: "container-Sample---Main" | ||
} | ||
}) | ||
// new object interface | ||
const northwaveModel = await mainView.getModel() | ||
const customerName = await northwaveModel.getProperty("/Customers('TRAIH')/ContactName") | ||
expect(customerName).toEqual("Helvetius Nagy") | ||
}) | ||
|
||
it("getModel via BindingContext and Object", async () => { | ||
// test equivalent of | ||
// sap.ui.getCore().byId("container-Sample---Other--PeopleList").getItems()[0].getBindingContext().getObject().FirstName | ||
|
||
await wdi5.goTo({ sHash: "#/Other" }) | ||
|
||
const table = await Other.getList(true) | ||
const firstItem = await table.getItems(0) | ||
const itemContext = await firstItem.getBindingContext() | ||
const myObject = await itemContext.getObject() | ||
|
||
expect(myObject.FirstName).toEqual("Nancy") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.