@@ -1,8 +1,10 @@
/*global QUnit */
sap.ui.define([
'sap/ui/core/Component',
'sap/ui/core/UIComponent',
"sap/ui/core/XMLTemplateProcessor",
"jquery.sap.xml"
], function(XMLTemplateProcessor, jQuery) {
], function(Component, UIComponent, XMLTemplateProcessor, jQuery) {
"use strict";

QUnit.module("enrichTemplateIdsPromise", {
Expand Down Expand Up @@ -235,4 +237,194 @@ sap.ui.define([

assert.ok(sError,"Not ending with binding in {model: 'model', path: '/path'}{path: '/path', name: 'context1'},{path: '/any', name: 'context2'}huhuhuh is detected");
});
});

QUnit.module("Propagation of processingMode: 'sequential'");

QUnit.test("Async rootView & childView", function(assert) {
var done = assert.async();

sap.ui.define("test/XMLTemplateProcessor/Component", function() {
return UIComponent.extend("test.XMLTemplateProcessor", {
metadata: {
rootView: {
viewName: "testdata/view/XMLTemplateProcessorAsync_nested",
type: "XML",
async: true
}
}
});
});

Component.create({
name: "test.XMLTemplateProcessor",
manifest: false
}).then(function(oComponent) {
var oRootView = oComponent.getRootControl();

oRootView.loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());

oView.getContent()[0].loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());
done();
});
});
});
});

QUnit.test("Async rootView & sync childView", function(assert) {
var done = assert.async();

sap.ui.define("test/XMLTemplateProcessor2/Component", function() {
return UIComponent.extend("test.XMLTemplateProcessor2", {
metadata: {
rootView: {
viewName: "testdata/view/XMLTemplateProcessorAsync_nested_2",
type: "XML",
async: true
}
}
});
});

Component.create({
name: "test.XMLTemplateProcessor2",
manifest: false
}).then(function(oComponent) {
var oRootView = oComponent.getRootControl();

oRootView.loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.ok(oView.oAsyncState, "View is an async view.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());

oView.getContent()[0].loaded().then(function(oChildView1) {
assert.ok(oChildView1, "View is loaded.");
assert.notOk(oChildView1.oAsyncState, "View is a sync view.");
assert.equal(oChildView1._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oChildView1.getViewName());

oChildView1.getContent()[0].loaded().then(function(oChildView2) {
assert.ok(oChildView2, "View is loaded.");
assert.ok(oChildView2.oAsyncState, "View is an async view.");
assert.equal(oChildView2._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oChildView2.getViewName());
done();
});
});
});
});
});

QUnit.test("Async rootView & nested fragments", function(assert) {
var done = assert.async();

sap.ui.define("test/XMLTemplateProcessor3/Component", function() {
return UIComponent.extend("test.XMLTemplateProcessor3", {
metadata: {
rootView: {
viewName: "testdata/fragments/XMLViewWithXMLFragment",
type: "XML",
async: true
}
}
});
});

Component.create({
name: "test.XMLTemplateProcessor3",
manifest: false
}).then(function(oComponent) {
var oRootView = oComponent.getRootControl();

oRootView.loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.ok(oView.oAsyncState, "View is an async view.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());

var oFragment = oView.byId("fragment");
oFragment.loaded().then(function(oChildView) {
assert.ok(oChildView, "View is loaded.");
assert.notOk(oChildView.oAsyncState, "View is a sync view.");
assert.equal(oChildView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oChildView.getViewName());

done();
});
});
});
});

QUnit.test("Async XML rootView with HTML tags with nested XML view", function(assert) {
var done = assert.async();

sap.ui.define("test/XMLTemplateProcessor4/Component", function() {
return UIComponent.extend("test.XMLTemplateProcessor4", {
metadata: {
rootView: {
viewName: "testdata/fragments/XMLViewWithHTML",
type: "XML",
async: true
}
}
});
});

Component.create({
name: "test.XMLTemplateProcessor4",
manifest: false
}).then(function(oComponent) {
var oRootView = oComponent.getRootControl();

oRootView.loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.ok(oView.oAsyncState, "View is an async view.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());

var xmlViewInHtml = oView.byId("xmlViewInHTML");
xmlViewInHtml.loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());

done();
});
});
});
});

QUnit.test("Async XML rootView with HTML fragment with nested XML view", function(assert) {
var done = assert.async();

sap.ui.define("test/XMLTemplateProcessor5/Component", function() {
return UIComponent.extend("test.XMLTemplateProcessor4", {
metadata: {
rootView: {
viewName: "testdata/fragments/XMLViewWithHTMLFragments",
type: "XML",
async: true
}
}
});
});

Component.create({
name: "test.XMLTemplateProcessor5",
manifest: false
}).then(function(oComponent) {
var oRootView = oComponent.getRootControl();

oRootView.loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.ok(oView.oAsyncState, "View is an async view.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());

var xmlView = oView.byId("XVwithFrags");
xmlView.loaded().then(function(oView) {
assert.ok(oView, "View is loaded.");
assert.equal(oView._sProcessingMode, "sequential", "ProcessingMode 'sequential' is set on " + "View:" + oView.getViewName());

done();
});
});
});
});
});
Expand Up @@ -141,7 +141,7 @@ sap.ui.define(function() {
},
loader: {
paths: {
"testdata/view": "test-resources/sap/ui/core/qunit/testdata/view",
"testdata": "test-resources/sap/ui/core/qunit/testdata",
"my": "test-resources/sap/ui/core/qunit/fragment/"
}
}
Expand Down
Expand Up @@ -79,9 +79,6 @@ sap.ui.define([

QUnit.module("XMLView " + (bAsyncView ? "async" : "sync") + (sSyncProcessingMode ? " with " + sSyncProcessingMode + " processing" : ""), {
beforeEach: function() {
this._sSyncProcessingModeBefore = sap.ui.getCore().getConfiguration().getXMLProcessingMode();
sap.ui.getCore().getConfiguration().setXMLProcessingMode(sSyncProcessingMode);

var fnOldSyncPromiseAll = SyncPromise.all;
MyGlobal.reset();
this.SyncPromiseAllStub = sinon.stub(SyncPromise, "all").callsFake(function(args) {
Expand All @@ -102,7 +99,6 @@ sap.ui.define([
ctrl.destroy();
});
this.SyncPromiseAllStub.restore();
sap.ui.getCore().getConfiguration().setXMLProcessingMode(this._sSyncProcessingModeBefore);
}
});

Expand Down
@@ -0,0 +1,5 @@
<div data-sap-ui-type="sap.ui.layout.HorizontalLayout">
<div id="btnInHtmlFragment" data-sap-ui-type="sap.ui.commons.Button" data-text="Hello HTML World"></div>
<div data-sap-ui-type="sap.ui.commons.Button" data-text="{/someText}"></div>
<div data-sap-ui-type="sap.ui.core.mvc.XMLView" id="XVwithFrags" data-view-name="testdata.fragments.XMLViewWithFragments"></div>
</div>
@@ -0,0 +1,5 @@
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:layout="sap.ui.layout">
<mvc:XMLView id="fragment" viewName="testdata/fragments/XMLViewWithFragments">
</mvc:XMLView>
</core:FragmentDefinition>

@@ -0,0 +1,7 @@
<mvc:XMLView xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml">
<Button></Button>
<html:div style="background: #FF0085;">
<mvc:XMLView id="xmlViewInHTML" viewName="testdata.fragments.XMLViewWithFragments" />
</html:div>
<Input></Input>
</mvc:XMLView>
@@ -0,0 +1,5 @@
<mvc:XMLView xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:core="sap.ui.core">
<Button></Button>
<core:Fragment type="HTML" fragmentName="testdata.fragments.HTMLTestFragmentWithXMLView" />
<Input></Input>
</mvc:XMLView>
@@ -0,0 +1,7 @@
<mvc:XMLView xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core" xmlns:layout="sap.ui.layout">
<layout:HorizontalLayout>
<layout:content>
<core:Fragment fragmentName="testdata.fragments.XMLView" type="XML" />
</layout:content>
</layout:HorizontalLayout>
</mvc:XMLView>
@@ -0,0 +1,3 @@
<mvc:XMLView height="100%" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="child">
<Button></Button>
</mvc:XMLView>
@@ -0,0 +1,3 @@
<mvc:XMLView height="100%" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="child">
<mvc:XMLView viewName="testdata.view.XMLTemplateProcessorAsync_child" async="true"></mvc:XMLView>
</mvc:XMLView>
@@ -0,0 +1,4 @@
<mvc:XMLView height="100%" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="root">
<mvc:XMLView viewName="testdata.view.XMLTemplateProcessorAsync_child" async="true"></mvc:XMLView>
<Button></Button>
</mvc:XMLView>
@@ -0,0 +1,4 @@
<mvc:XMLView height="100%" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" id="root">
<mvc:XMLView viewName="testdata.view.XMLTemplateProcessorAsync_child_sync" async="false"></mvc:XMLView>
<Button></Button>
</mvc:XMLView>