mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 03:06:20 +02:00
Persist list of marketplace items in test
The list of resources between runs of the marketplace item tester now persist between runs of the tester.
This commit is contained in:
parent
f9c25f2f32
commit
697f556a60
3 changed files with 91 additions and 15 deletions
|
@ -29,10 +29,35 @@ Rectangle {
|
|||
signal sendToScript(var message)
|
||||
|
||||
HifiStylesUit.HifiConstants { id: hifi }
|
||||
ListModel { id: resourceListModel }
|
||||
ListModel {
|
||||
id: resourceListModel
|
||||
property var nextId: 0
|
||||
}
|
||||
|
||||
color: hifi.colors.white
|
||||
|
||||
AnimatedImage {
|
||||
id: spinner;
|
||||
source: "spinner.gif"
|
||||
width: 74;
|
||||
height: width;
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
anchors.horizontalCenter: parent.horizontalCenter;
|
||||
}
|
||||
|
||||
function fromScript(message) {
|
||||
switch (message.method) {
|
||||
case "newResourceObjectInTest":
|
||||
var resourceObject = message.resourceObject;
|
||||
resourceListModel.append(resourceObject);
|
||||
spinner.visible = false;
|
||||
break;
|
||||
case "marketplaceTestBackendIsAlive":
|
||||
spinner.visible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function buildResourceObj(resource) {
|
||||
resource = resource.trim();
|
||||
var assetType = (resource.match(/\.app\.json$/) ? "application" :
|
||||
|
@ -40,14 +65,14 @@ Rectangle {
|
|||
resource.match(/\.json\.gz$/) ? "content set" :
|
||||
resource.match(/\.json$/) ? "entity or wearable" :
|
||||
"unknown");
|
||||
return { "resource": resource, "assetType": assetType };
|
||||
return { "id": resourceListModel.nextId++,
|
||||
"resource": resource,
|
||||
"assetType": assetType };
|
||||
}
|
||||
|
||||
function installResourceObj(resourceObj) {
|
||||
if ("application" == resourceObj["assetType"]) {
|
||||
Commerce.installApp(resourceObj["resource"]);
|
||||
} else {
|
||||
print("Cannot install resource object type " + resourceObj["assetType"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,11 +97,6 @@ Rectangle {
|
|||
itemType: entityType});
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// On startup, list includes all tester-installed assets.
|
||||
addAllInstalledAppsToList();
|
||||
}
|
||||
|
||||
ListView {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
|
@ -157,7 +177,13 @@ Rectangle {
|
|||
currentIndex: ("entity or wearable" == assetType) ? model.indexOf("unknown") : model.indexOf(assetType)
|
||||
|
||||
Component.onCompleted: {
|
||||
onActivated.connect(function() { assetType = currentText; });
|
||||
onCurrentIndexChanged.connect(function() {
|
||||
assetType = model[currentIndex];
|
||||
sendToScript({
|
||||
method: 'tester_updateResourceObjectAssetType',
|
||||
objectId: resourceListModel.get(index)["id"],
|
||||
assetType: assetType });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,17 +246,17 @@ Rectangle {
|
|||
// ahead as though we are sure the present signal is one
|
||||
// we expect.
|
||||
if ("load file" == currentAction) {
|
||||
print("disconnecting load file");
|
||||
Window.browseChanged.disconnect(onResourceSelected);
|
||||
} else if ("load url" == currentAction) {
|
||||
print("disconnecting load url");
|
||||
Window.promptTextChanged.disconnect(onResourceSelected);
|
||||
}
|
||||
if (resource) {
|
||||
var resourceObj = buildResourceObj(resource);
|
||||
installResourceObj(resourceObj);
|
||||
resourceListModel.append(resourceObj);
|
||||
}
|
||||
sendToScript({
|
||||
method: 'tester_newResourceObject',
|
||||
resourceObject: resourceObj });
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
|
@ -800,6 +800,18 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
}, 150);
|
||||
}
|
||||
|
||||
function signalNewResourceObjectInTest(resourceObject) {
|
||||
sendToQml({
|
||||
method: "newResourceObjectInTest",
|
||||
resourceObject: resourceObject });
|
||||
}
|
||||
|
||||
var resourceObjectsInTest = [];
|
||||
function storeResourceObjectInTest(resourceObject) {
|
||||
resourceObjectsInTest.push(resourceObject);
|
||||
signalNewResourceObjectInTest(resourceObject);
|
||||
}
|
||||
|
||||
// Function Name: fromQml()
|
||||
//
|
||||
// Description:
|
||||
|
@ -856,9 +868,22 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
case 'checkout_rezClicked':
|
||||
case 'purchases_rezClicked':
|
||||
case 'tester_rezClicked':
|
||||
print("marketplace.js going to rez");
|
||||
rezEntity(message.itemHref, message.itemType);
|
||||
break;
|
||||
case 'tester_newResourceObject':
|
||||
storeResourceObjectInTest(message.resourceObject);
|
||||
break;
|
||||
case 'tester_updateResourceObjectAssetType':
|
||||
var objectId = message.objectId;
|
||||
for (var i = 0, size = resourceObjectsInTest.length; i < size; ++i) {
|
||||
if (i in resourceObjectsInTest &&
|
||||
objectId === resourceObjectsInTest[i]["id"]
|
||||
) {
|
||||
resourceObjectsInTest[i]["assetType"] = message.assetType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'header_marketplaceImageClicked':
|
||||
case 'purchases_backClicked':
|
||||
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||
|
@ -1027,6 +1052,22 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
}
|
||||
}
|
||||
|
||||
function pushResourceObjectsInTest() {
|
||||
var isQmlSignaled = false;
|
||||
for (var i = 0, size = resourceObjectsInTest.length; i < size; ++i) {
|
||||
if (i in resourceObjectsInTest) {
|
||||
signalNewResourceObjectInTest(resourceObjectsInTest[i]);
|
||||
isQmlSignaled = true;
|
||||
}
|
||||
}
|
||||
// Be sure that the QML has heard from us, at least so that it
|
||||
// can indicate to the user that all of the resoruce objects in
|
||||
// test have been transmitted to it.
|
||||
if (!isQmlSignaled) {
|
||||
sendToQml({ method: "marketplaceTestBackendIsAlive" });
|
||||
}
|
||||
}
|
||||
|
||||
// Function Name: onTabletScreenChanged()
|
||||
//
|
||||
// Description:
|
||||
|
@ -1070,6 +1111,9 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
onMarketplaceItemTesterScreen);
|
||||
|
||||
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
||||
// FIXME: There is a race condition here. The event bridge
|
||||
// may not be up yet. Suggest Script.setTimeout(..., 750) to
|
||||
// help avoid the condition.
|
||||
sendToQml({
|
||||
method: 'updatePurchases',
|
||||
referrerURL: referrerURL,
|
||||
|
@ -1103,6 +1147,12 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
|||
method: 'inspectionCertificate_resetCert'
|
||||
});
|
||||
}
|
||||
|
||||
if (onMarketplaceItemTesterScreen) {
|
||||
// Why? The QML event bridge, wired above, needs time to
|
||||
// come up.
|
||||
Script.setTimeout(pushResourceObjectsInTest, 750);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue