From 826da6f76578bb2fe406a89eef82611f6a8d5f73 Mon Sep 17 00:00:00 2001 From: martinhaeuser Date: Thu, 31 Aug 2023 08:50:32 +0200 Subject: [PATCH] [INTERNAL] mdc.p13n: delete unused code Change-Id: I9a383795677214aa086897dd6e48461f311343fb --- .../src/sap/ui/mdc/p13n/UIManager.js | 497 ------------------ .../sap/ui/mdc/qunit/p13n/BasePanel.qunit.js | 223 -------- .../ui/mdc/qunit/p13n/SelectionPanel.qunit.js | 23 - .../sap/ui/mdc/qunit/p13n/SortPanel.qunit.js | 81 --- .../sap/ui/mdc/qunit/p13n/UIManager.qunit.js | 271 ---------- .../ui/mdc/qunit/p13n/testsuite.p13n.qunit.js | 9 - 6 files changed, 1104 deletions(-) delete mode 100644 src/sap.ui.mdc/src/sap/ui/mdc/p13n/UIManager.js delete mode 100644 src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/BasePanel.qunit.js delete mode 100644 src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SelectionPanel.qunit.js delete mode 100644 src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SortPanel.qunit.js delete mode 100644 src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/UIManager.qunit.js diff --git a/src/sap.ui.mdc/src/sap/ui/mdc/p13n/UIManager.js b/src/sap.ui.mdc/src/sap/ui/mdc/p13n/UIManager.js deleted file mode 100644 index 52fcbf1de197..000000000000 --- a/src/sap.ui.mdc/src/sap/ui/mdc/p13n/UIManager.js +++ /dev/null @@ -1,497 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([ - "sap/ui/base/Object", - "sap/ui/mdc/p13n/P13nBuilder", - "sap/m/p13n/Container", - "sap/m/p13n/AbstractContainerItem", - "sap/base/util/UriParameters", - "sap/base/Log", - "sap/ui/thirdparty/jquery" -], function (BaseObject, P13nBuilder, P13nContainer, AbstractContainerItem, SAPUriParameters, Log, jQuery) { - "use strict"; - - var ERROR_INSTANCING = "UIManager: This class is a singleton and should not be used without an AdaptationProvider. Please use 'sap.ui.mdc.p13n.Engine.getInstance().uimanager' instead"; - - //Singleton storage - var oUIManager; - - //Used for experimental features (such as livemode) - var oURLParams = SAPUriParameters.fromQuery(window.location.search); - - /** - * Constructor for a new UIManager. - * This registry creates and manages default persistence providers for each persistence mode. - * It is intended for use cases where no dedicated provider can or should be created by an application. - * The UIManager currently resides in the Engine and must never be called separately. - * - * @class - * @extends sap.ui.base.Object - * - * @author SAP SE - * @version ${version} - * - * @private - * @ui5-restricted sap.ui.mdc - * @experimental As of version 1.90 - * @since 1.90 - * @alias sap.ui.mdc.p13n.UIManager - */ - var UIManager = BaseObject.extend("sap.ui.mdc.p13n.UIManager", { - constructor: function(oAdaptationProvider) { - - if (oUIManager) { - throw Error(ERROR_INSTANCING); - } - - this.oAdaptationProvider = oAdaptationProvider; - - BaseObject.call(this); - } - }); - - /** - * Opens a personalization Dialog according to the provided Controller - * in the registration that the Engine can find for the Control and key. - * - * @private - * @ui5-restricted sap.ui.mdc - * - * @param {sap.ui.mdc.Control} vControl The registered control instance - * @param {string} vKey The key(s) for the according Controller - * @param {sap.ui.core.Control} oSource The source to be used. This may only - * be relevant in case the corresponding Controller is configured - * for liveMode - * - * @returns {Promise} A Promise resolving in the P13n UI. - */ - UIManager.prototype.show = function(vControl, vKey, oSource) { - - this.bLiveMode = false; - - //!!!Warning: experimental and only for testing purposes!!!---------- - if (oURLParams.get("sap-ui-xx-p13nLiveMode") === "true"){ - this.bLiveMode = true; - Log.warning("Please note that the p13n liveMode is experimental"); - } - - if (!this.hasActiveP13n(vControl)){ - this.setActiveP13n(vControl, vKey); - return this.create(vControl, vKey).then(function(oP13nDialog){ - this._openP13nControl(vControl, vKey, oP13nDialog, oSource); - return oP13nDialog; - }.bind(this), function(eContainerFailure){ - this.setActiveP13n(vControl, null); - Log.error("Engine UI failure:" + eContainerFailure.stack); - }.bind(this)); - } else { - return Promise.resolve(); - } - }; - - /** - * This method can be used to create a customized P13nUI without using the default - * implementation of Engine#showUI which will use all - * properties available by default. - * - * @private - * @ui5-restricted sap.ui.mdc - * - * @param {sap.ui.mdc.Control} vControl The registered control instance - * @param {string|string[]} vKey The key for the according Controller - * @param {Object[]} aCustomInfo A custom set of propertyinfos as base to create the UI - * - * @returns {Promise} A Promise resolving in the P13n UI. - */ - UIManager.prototype.create = function(vControl, vKey, aCustomInfo) { - var aKeys = vKey instanceof Array ? vKey : [vKey]; - var oControl = typeof vControl == "string" ? sap.ui.getCore().byId(vControl) : vControl; - return this.oAdaptationProvider.initAdaptation(vControl, aKeys, aCustomInfo).then(function(){ - return this._retrieveP13nContainer(oControl, aKeys).then(function(oContainer){ - oControl.addDependent(oContainer); - return oContainer; - }); - }.bind(this)); - }; - - - /** - * This method can be used to open the p13n UI. - * - * @private - * - * @param {sap.ui.mdc.Control} vControl The registered control instance. - * @param {string} vKey The registerd key to get the corresponding Controller. - * @param {sap.ui.core.Control} oP13nControl The created p13n UI to be displayed. - * @param {sap.ui.core.Control} oSource The source control (only for livemode). - */ - UIManager.prototype._openP13nControl = function(vControl, vKey, oP13nControl, oSource){ - var aKeys = vKey instanceof Array ? vKey : [vKey]; - if (this.bLiveMode) { - oP13nControl.openBy(oSource); - delete this.bLiveMode; - } else { - oP13nControl.open(); - } - - if (this.oAdaptationProvider && this.oAdaptationProvider.validateP13n instanceof Function) { - aKeys.forEach(function(sKey){ - var bWrapperUsed = aKeys.length > 1; - var oAdaptationUI; - var oContent = oP13nControl.getContent()[0]; - if (bWrapperUsed && oContent.isA("sap.m.p13n.Container") && oContent.getView(sKey)) { - oAdaptationUI = oContent.getView(sKey).getContent(); - } else { - oAdaptationUI = oContent; - } - this.oAdaptationProvider.validateP13n(vControl, sKey, oAdaptationUI); - }.bind(this)); - } - }; - - - /** - * This method can be used to retrieve the p13n container. - * - * @private - * - * @param {sap.ui.mdc.Control} oControl The registered control instance. - * @param {string} aKeys The registered key to get the corresponding Controller. - * - * @returns {Promise} A Promise resolving in the according container - * (Depending on the Controllers livemode config). - */ - UIManager.prototype._retrieveP13nContainer = function (oControl, aKeys) { - - var aPAdaptationUI = []; - var bUseP13nContainer = aKeys instanceof Array && aKeys.length > 1; - - //Note: Engine#getUISettings triggers BaseController#getAdaptationUI, which should only be executed again - //after the according p13n ui content has been cleaned up properly. - var oUISettings = this.oAdaptationProvider.getUISettings(oControl, aKeys); - - aKeys.forEach(function(sRelevantKey){ - //Ignore unknown keys for now.. - if (!oUISettings[sRelevantKey]) { - aKeys.splice(aKeys.indexOf(sRelevantKey), 1); - return; - } - }); - - aKeys.forEach(function(sRelevantKey){ - var pAdaptationUI = oUISettings[sRelevantKey].adaptationUI; - pAdaptationUI._key = sRelevantKey; - var pWrapped = pAdaptationUI.then(function(oAdaptationUI){ - if (this.bLiveMode && oAdaptationUI && oAdaptationUI.attachChange) { - oAdaptationUI.attachChange(function(){ - this.oAdaptationProvider.handleP13n(oControl, aKeys); - }.bind(this)); - } - if (oAdaptationUI && oAdaptationUI.attachChange) { - oAdaptationUI.attachChange(function(oEvt){ - this.oAdaptationProvider.validateP13n(oControl, pAdaptationUI._key, oAdaptationUI); - }.bind(this)); - } - var oSetting = oUISettings[pAdaptationUI._key]; - return { - key: pAdaptationUI._key, - tab: oSetting.containerSettings && oSetting.containerSettings.tabText ? oSetting.containerSettings.tabText : pAdaptationUI._key, - panel: oAdaptationUI - }; - }.bind(this)); - - aPAdaptationUI.push(pWrapped); - }.bind(this)); - - return Promise.all(aPAdaptationUI).then(function(aUIs){ - var oPopupContent = bUseP13nContainer ? new P13nContainer({ - afterViewSwitch: function(oEvt) { - this.oAdaptationProvider.validateP13n(oControl, oEvt.getParameter("target"), oEvt.getSource().getCurrentViewContent()); - }.bind(this) - }) : aUIs[0].panel; - if (bUseP13nContainer) { - aUIs.forEach(function(mUI){ - if (mUI.panel) { - oPopupContent.addView(new AbstractContainerItem({ - key: mUI.key, - text: mUI.tab, - content: mUI.panel - })); - } - }); - oPopupContent.switchView(aUIs[0].key); - } - - return this._createUIContainer(oControl, aKeys, oPopupContent, oUISettings).then(function(oDialog){ - return oDialog; - }); - }.bind(this)); - - }; - - /** - * This method can be used to create the p13n container instance. - * - * @private - * - * @param {sap.ui.mdc.Control} oControl The registered control instance. - * @param {string[]} aKeys The registered keys to get the corresponding Controller. - * @param {*} oPopupContent - * @param {*} oUISettings - * - * @returns {Promise} Returns a Promise resolving in the container instance - */ - UIManager.prototype._createUIContainer = function (oControl, aKeys, oPopupContent, oUISettings) { - - var oContainerPromise; - var mContainerSettings = aKeys.length > 1 ? this._getDefaultContainerConfig(oUISettings) : oUISettings[aKeys[0]]; - - if (this.bLiveMode) { - oContainerPromise = this._createPopover(oControl, aKeys, oPopupContent, mContainerSettings); - } else { - oContainerPromise = this._createModalDialog(oControl, aKeys, oPopupContent, mContainerSettings); - } - - return oContainerPromise.then(function(oContainer){ - // Add custom style class in order to display marked items accordingly - oContainer.addStyleClass("sapUiMdcPersonalizationDialog"); - - oContainer.isPopupAdaptationAllowed = function () { - return false; - }; - - //EscapeHandler is required for non-liveMode - if (this.bLiveMode === false){ - oContainer.setEscapeHandler(function(oDialogClose){ - this.setActiveP13n(oControl, null); - aKeys.forEach(function(sKey){ - if (oUISettings[sKey].containerSettings && oUISettings[sKey].containerSettings.afterClose instanceof Function) { - oUISettings[sKey].containerSettings.afterClose({ - getSource: function() { - return oContainer; - } - }); - } - }); - oContainer.close(); - oContainer.destroy(); - oDialogClose.resolve(); - }.bind(this)); - } - - // Set compact style class if the table is compact too - oContainer.toggleStyleClass("sapUiSizeCompact", !!jQuery(oControl).closest(".sapUiSizeCompact").length); - - //TODO: Clarify whether we really want this - //If the container has a header itself, don't show any shadows from the dialog - //if (oContainer && oContainer.getCustomHeader()){ - // oContainer.getCustomHeader().addStyleClass("sapUiMdcContainerBar"); - //} - - - return oContainer; - }.bind(this)); - - }; - - /** - * This method can be used to create a Popover as container instance. - * - * @private - * - * @param {sap.ui.mdc.Control} oControl The registered control instance. - * @param {string[]} aKeys The registerd key to get the corresponding Controller. - * @param {sap.ui.core.Control} oPanel The control instance which is set in the content area of the container. - * @param {object} mUISettings - * - * @returns {sap.m.ResponsivePopover} The popover instance. - */ - UIManager.prototype._createPopover = function(oControl, aKeys, oPanel, mUISettings){ - - var fnAfterDialogClose = function (oEvt) { - var oPopover = oEvt.getSource(); - this.setActiveP13n(oControl, null); - oPopover.destroy(); - }.bind(this); - - var mSettings = Object.assign({ - verticalScrolling: true, - reset: mUISettings.reset, - afterClose: fnAfterDialogClose - }, mUISettings.containerSettings); - - if (mUISettings.resetEnabled){ - mSettings.reset = { - onExecute: function() { - aKeys.forEach(function(sKey){ - this.oAdaptationProvider.reset(oControl, sKey); - }.bind(this)); - } - }; - } - - return P13nBuilder.createP13nPopover(oPanel, mSettings); - - }; - - /** - * This method can be used to create a Dialog as container instance. - * - * @private - * - * @param {sap.ui.mdc.Control} oControl The registered control instance. - * @param {string} aKeys The registerd key to get the corresponding Controller. - * @param {sap.ui.core.Control} oPanel The control instance which is set in the content area of the container. - * - * @returns {sap.m.Dialog} The dialog instance. - */ - UIManager.prototype._createModalDialog = function(oControl, aKeys, oPanel, mUISettings){ - - var fnDialogOk = function (oEvt) { - var oDialog = oEvt.getSource().getParent(); - - var pConfirmContainer = this._confirmContainer(oControl, aKeys, oPanel); - - pConfirmContainer.then(function(){ - this.setActiveP13n(oControl, null); - oDialog.close(); - }.bind(this)); - - }.bind(this); - - var fnDialogCancel = function(oEvt) { - var oContainer = oEvt.getSource().getParent(); - this.setActiveP13n(oControl, null); - oContainer.close(); - }.bind(this); - - var mSettings = Object.assign({ - verticalScrolling: true, - reset: mUISettings.reset || {}, - afterClose: function(oEvt) { - var oDialog = oEvt.getSource(); - if (oDialog) { - oDialog.destroy(); - } - }, - cancel: fnDialogCancel - }, mUISettings.containerSettings); - - if (mUISettings.resetEnabled){ - mSettings.reset.onExecute = function() { - this.oAdaptationProvider.reset(oControl, aKeys); - }.bind(this); - } - - mSettings.confirm = { - handler: function(oEvt) { - fnDialogOk(oEvt); - } - }; - - return P13nBuilder.createP13nDialog(oPanel, mSettings); - }; - - UIManager.prototype.setActiveP13n = function(vControl, vKeys) { - if (this.oAdaptationProvider.setActiveP13n instanceof Function) { - this.oAdaptationProvider.setActiveP13n(vControl, vKeys); - } - }; - - UIManager.prototype.hasActiveP13n = function(vControl) { - var bActiveP13n = false; - if (this.oAdaptationProvider.hasActiveP13n instanceof Function) { - bActiveP13n = this.oAdaptationProvider.hasActiveP13n(vControl); - } - return bActiveP13n; - }; - - /** - * Retrieves the uimanager default setting for the container, these defaults - * may only be used in case multiple keys are shown at once. - * - * @returns {object} The default settings for the container creation - */ - UIManager.prototype._getDefaultContainerConfig = function(oUISettings) { - var oRB = sap.ui.getCore().getLibraryResourceBundle("sap.ui.mdc"); - var aKeys = Object.keys(oUISettings); - var oContainerConfig = { - containerSettings: { - title: oRB.getText("p13nDialog.VIEW_SETTINGS"), - verticalScrolling: false, //The Wrapper already takes care of the scrolling - contentHeight: oUISettings.contentHeight, - contentWidth: oUISettings.contentWidth, - afterClose: function(oEvt) { - aKeys.forEach(function(sKey){ - if (oUISettings[sKey] && oUISettings[sKey].containerSettings && oUISettings[sKey].containerSettings.afterClose instanceof Function) { - oUISettings[sKey].containerSettings.afterClose(oEvt); - } - }); - oEvt.getSource().destroy(); - } - } - }; - - if (oUISettings.resetEnabled !== false) { - oContainerConfig.reset = { - onExecute: function(oControl) { - this.oAdaptationProvider.reset(oControl, aKeys); - }.bind(this), - warningText: oRB.getText("p13nDialog.RESET_WARNING_TEXT") - }; - } - - return oContainerConfig; - - }; - - /** - * This method can be used to confirm a Dialog container instance. - * - * @private - * - * @param {sap.ui.mdc.Control} vControl The registered control instance - * @param {array} aKeys The keys of the controllers that should be called for synchronizations - * - */ - UIManager.prototype._confirmContainer = function(vControl, aKeys){ - return this.oAdaptationProvider.handleP13n(vControl, aKeys); - }; - - /** - * Checks if the UIManager has been initialized with a valid AdaptationProvider interface. - * - * @private - * @ui5-restricted sap.ui.mdc - * - * @param {sap.m.p13n.modules.AdaptationProvider|sap.ui.mdc.p13n.AdaptationProvider} oAdaptationProvider - */ - UIManager._checkValidInterface = function(oAdaptationProvider) { - if (!oAdaptationProvider || !(oAdaptationProvider.isA("sap.ui.mdc.p13n.AdaptationProvider") || oAdaptationProvider.isA("sap.m.p13n.modules.AdaptationProvider")) ){ - throw Error("The UIManager singleton must not be accessed without an AdaptationProvider interface!"); - } - }; - - /** - * This method is the central point of access to the UIManager Singleton. - * - * @private - * @ui5-restricted sap.ui.mdc - */ - UIManager.getInstance = function(oAdaptationProvider) { - if (!oUIManager) { - this._checkValidInterface(oAdaptationProvider); - oUIManager = new UIManager(oAdaptationProvider); - } - return oUIManager; - }; - - UIManager.prototype.destroy = function() { - BaseObject.prototype.destroy.apply(this, arguments); - oUIManager = null; - }; - - return UIManager; -}); diff --git a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/BasePanel.qunit.js b/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/BasePanel.qunit.js deleted file mode 100644 index 28faffa81fd3..000000000000 --- a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/BasePanel.qunit.js +++ /dev/null @@ -1,223 +0,0 @@ -/* global QUnit */ -sap.ui.define([ - "sap/ui/mdc/p13n/panels/BasePanel", "sap/m/StandardListItem", "sap/ui/thirdparty/sinon", "sap/ui/base/Event", "sap/ui/model/json/JSONModel", "sap/m/MessageStrip", "sap/ui/core/Core" -], function (BasePanel, StandardListItem, sinon, Event, JSONModel, MessageStrip, oCore) { - "use strict"; - - QUnit.module("BasePanel API tests", { - before: function() { - this.oBasePanel = new BasePanel(); - var oTemplate = new StandardListItem({ - title: "{" + this.oBasePanel.P13N_MODEL + ">label}" - }); - - var oModel = new JSONModel({ - items: [ - { - label: "Test", - name: "test", - visible: true - }, { - label: "Test2", - name: "test2", - visible: true - }, { - label: "Test3", - name: "test3", - visible: true - }, { - label: "Test4", - name: "test4", - visible: false - } - ] - }); - this.oBasePanel.setP13nModel(oModel); - this.oBasePanel.setTemplate(oTemplate); - this.oBasePanel.setPanelColumns([ - "Name", "Country", "Year" - ]); - this.oBasePanel.placeAt("qunit-fixture"); - oCore.applyChanges(); - this.oBtnShowSelected = this.oBasePanel._oListControl.getHeaderToolbar().getContent()[6]; - }, - after: function() { - this.oBasePanel.destroy(); - } - }); - - QUnit.test("instantiate", function(assert) { - assert.ok(this.oBasePanel, "Panel has been instantiated"); - assert.ok(this.oBasePanel._oListControl, "Inner table has been instantiated"); - - assert.ok(!this.oBasePanel.getModel(), "BasePanel does not create an undefined model"); - assert.ok(this.oBasePanel.getP13nModel().isA("sap.ui.model.json.JSONModel"), "BasePanel creates a named model '$p13n' "); - - // Check if columns have been created with correct text in header - var aColumns = this.oBasePanel._oListControl.getColumns(); - assert.equal(aColumns[0].getHeader().getText(), "Name", "Added 'Name' column"); - assert.equal(aColumns[1].getHeader().getText(), "Country", "Added 'Country' column"); - assert.equal(aColumns[2].getHeader().getText(), "Year", "Added 'Year' column"); - }); - - QUnit.test("check 'Reorder / Select mode' eventhandler", function(assert) { - //Reorder mode - this.oBtnShowSelected.firePress(); - assert.equal(this.oBasePanel._oListControl.getItems().length, 3, "only selected items are visible in the dialog");// we only see the selected item - this.oBasePanel._oListControl.getItems().forEach(function(oItem){ - assert.equal(oItem.getType(), "Active", "Type is active in 'Reorder' mode");//type is active in 'Reorder' - }); - - //all buttons for movement should be disabled upon reordering - assert.equal(this.oBasePanel._getMoveTopButton().getEnabled(), false); - assert.equal(this.oBasePanel._getMoveUpButton().getEnabled(), false); - assert.equal(this.oBasePanel._getMoveDownButton().getEnabled(), false); - assert.equal(this.oBasePanel._getMoveBottomButton().getEnabled(), false); - - //Select mode - this.oBtnShowSelected.firePress(); - assert.equal(this.oBasePanel._oListControl.getItems().length, 4, "all items are visible in the dialog");// we see all items - this.oBasePanel._oListControl.getItems().forEach(function(oItem){ - assert.equal(oItem.getType(), "Inactive", "Type is inactive in 'Select' mode");//type is inactive in 'Select' - }); - }); - - QUnit.test("check drag & drop eventhandler", function(assert) { - // Go to "Reorder" mode first - this.oBtnShowSelected.firePress(); - - // Setup Fake drop event - var oDropItem = this.oBasePanel._oListControl.getItems()[0]; - var oDragItem = this.oBasePanel._oListControl.getItems()[2]; - var oFakeSession = { - getDropControl: function() { - return oDropItem; - }, - getDragControl: function() { - return oDragItem; - }, - setIndicatorConfig: sinon.stub(), - setDropControl: sinon.stub(), - getDropPosition: sinon.stub() - }; - - var oFakeEvent = new Event("fakeDropEvent", this.oBasePanel, { - dropPosition: "After", - dragSession: oFakeSession, - draggedControl: oDragItem, - droppedControl: oDropItem - }); - - // fire event for drag and drop - this.oBasePanel._onRearrange(oFakeEvent); - - // Test results - var aItems = this.oBasePanel._oListControl.getItems(); - assert.equal(aItems[0].getTitle(), "Test"); - assert.equal(aItems[1].getTitle(), "Test3"); - assert.equal(aItems[2].getTitle(), "Test2"); - - }); - - QUnit.test("Change selection", function(assert) { - var done = assert.async(); - this.oBasePanel.attachEvent("change", function(oEvt) { - assert.ok(oEvt);// we just need to check if the event is being fired - done(); - }); - - // fire single event - this.oBasePanel._oListControl.fireSelectionChange({ - selectAll: false, - listItems: this.oBasePanel._oListControl.getItems() - }); - }); - - QUnit.test("press item and check the enablement of move buttons (item at the top)", function(assert) { - // fire single event - this.oBasePanel._oListControl.fireItemPress({ - listItem: this.oBasePanel._oListControl.getItems()[0] - }); - - assert.equal(this.oBasePanel._getMoveTopButton().getEnabled(), false, "'move top' button is disabled (item is at the top)"); - assert.equal(this.oBasePanel._getMoveUpButton().getEnabled(), false, "'move up' button is disabled (item is at the top)"); - assert.equal(this.oBasePanel._getMoveDownButton().getEnabled(), true, "'move down' button is enabled"); - assert.equal(this.oBasePanel._getMoveBottomButton().getEnabled(), true, "'move bottom' button is enabled"); - }); - - QUnit.test("press item and check the enablement of move buttons (item at the bottom)", function(assert) { - // fire single event - this.oBasePanel._oListControl.fireItemPress({ - listItem: this.oBasePanel._oListControl.getItems()[this.oBasePanel._oListControl.getItems().length - 1] - }); - - assert.equal(this.oBasePanel._getMoveTopButton().getEnabled(), true, "'move top' button is enabled"); - assert.equal(this.oBasePanel._getMoveUpButton().getEnabled(), true, "'move up' button is enabled"); - assert.equal(this.oBasePanel._getMoveDownButton().getEnabled(), false, "'move down' button is disabled (item is at the top)"); - assert.equal(this.oBasePanel._getMoveBottomButton().getEnabled(), false, "'move bottom' button is disabled (item is at the top)"); - }); - - QUnit.test("press item and check the enablement of move buttons (item inbetween)", function(assert) { - // fire single event - this.oBasePanel._oListControl.fireItemPress({ - listItem: this.oBasePanel._oListControl.getItems()[1] - }); - - assert.equal(this.oBasePanel._getMoveTopButton().getEnabled(), true, "'move top' button is enabled"); - assert.equal(this.oBasePanel._getMoveUpButton().getEnabled(), true, "'move up' button is enabled"); - assert.equal(this.oBasePanel._getMoveDownButton().getEnabled(), true, "'move down' button is enabled"); - assert.equal(this.oBasePanel._getMoveBottomButton().getEnabled(), true, "'move bottom' button is enabled"); - - }); - - QUnit.test("Check 'messagerStrip' aggregation, provide a message strip", function(assert){ - - var oMessageStrip = new MessageStrip(); - this.oBasePanel.setMessageStrip(oMessageStrip); - - var oFirstItem = this.oBasePanel.getAggregation("_content").getItems()[0]; - - assert.deepEqual(oFirstItem, oMessageStrip, "The message strip has been placed in the content area of the BasePanel"); - - }); - - QUnit.test("Check 'messagerStrip' aggregation, remove a message strip", function(assert){ - - var oMessageStrip = new MessageStrip(); - this.oBasePanel.setMessageStrip(oMessageStrip); - this.oBasePanel.setMessageStrip(); - - assert.equal(this.oBasePanel.getAggregation("_content").getItems().length, 1, "Only table in content area of the BasePanel"); - - }); - - QUnit.test("Check 'messagerStrip' aggregation, provide a message strip twice (only once added)", function(assert){ - - var oMessageStrip = new MessageStrip(); - this.oBasePanel.setMessageStrip(oMessageStrip); - - var oMessageStrip2 = new MessageStrip(); - this.oBasePanel.setMessageStrip(oMessageStrip2); - - assert.equal(this.oBasePanel.getAggregation("_content").getItems().length, 2, "Only one strip has been added to the BasePanel"); - - }); - - QUnit.test("Check 'messagerStrip' aggregation, provide a message strip twice (new one is being used)", function(assert){ - - var oMessageStrip = new MessageStrip({ - text: "First" - }); - this.oBasePanel.setMessageStrip(oMessageStrip); - - var oMessageStrip2 = new MessageStrip({ - text: "Second" - }); - this.oBasePanel.setMessageStrip(oMessageStrip2); - - assert.ok(oMessageStrip.bIsDestroyed, "First MessageStrip has been destroyed, as a second one has been provided"); - assert.equal(this.oBasePanel.getAggregation("_content").getItems()[0].getText(), "Second", "Second provided message strip is being used"); - - }); - -}); diff --git a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SelectionPanel.qunit.js b/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SelectionPanel.qunit.js deleted file mode 100644 index 1f64e45fa4c0..000000000000 --- a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SelectionPanel.qunit.js +++ /dev/null @@ -1,23 +0,0 @@ -/* global QUnit */ -sap.ui.define([ - "sap/ui/mdc/p13n/panels/SelectionPanel", - "sap/ui/core/Core" -], function (SelectionPanel, oCore) { - "use strict"; - - this.oSelectionPanel = new SelectionPanel(); - this.oSelectionPanel.placeAt("qunit-fixture"); - oCore.applyChanges(); - - QUnit.module("SelectionPanel API tests", { - beforeEach: function(){ - }, - afterEach: function(){ - } - }); - - QUnit.test("instantiate SelectionPanel", function(assert){ - assert.ok(this.oSelectionPanel); - }.bind(this)); - -}); diff --git a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SortPanel.qunit.js b/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SortPanel.qunit.js deleted file mode 100644 index e105444d5073..000000000000 --- a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/SortPanel.qunit.js +++ /dev/null @@ -1,81 +0,0 @@ -/* global QUnit */ -sap.ui.define([ - "sap/ui/mdc/p13n/panels/SortPanel", "sap/ui/model/json/JSONModel", "sap/ui/core/Core" -], function (SortPanel, JSONModel, oCore) { - "use strict"; - - QUnit.module("SelectionPanel API tests", { - beforeEach: function(){ - this.oSortPanel = new SortPanel(); - var oModel = new JSONModel({ - items: [ - { - label: "Test", - name: "test", - sorted: true, - descending: false - }, - { - label: "Test2", - name: "test2", - sorted: false, - descending: false - }, - { - label: "Test3", - name: "test3", - sorted: false, - descending: false - } - ] - }); - this.oSortPanel.setP13nModel(oModel); - this.oSortPanel.setPanelColumns(["Name", "Sort Order"]); - this.oSortPanel.placeAt("qunit-fixture"); - oCore.applyChanges(); - }, - afterEach: function(){ - this.oSortPanel.destroy(); - } - }); - - QUnit.test("instantiate SelectionPanel - check that sortorder 'Select' control fires a change event", function(assert){ - var done = assert.async(); - assert.ok(this.oSortPanel); - - //check if the change event has been fired - this.oSortPanel.attachEvent("change", function(oEvent){ - assert.ok(oEvent, "change event has been fired"); - done(); - }); - - //fire the change event which is being used for the change of sort order maunally - this.oSortPanel._oListControl.getItems()[0].getCells()[1].fireChange({ - - //Select control instance - selectedItem: this.oSortPanel._oListControl.getItems()[0].getCells()[1].getItems()[1] - }); - }); - - QUnit.test("Check change in 'sortOrder' - model should keep a boolean (and not a string)", function(assert){ - - var done = assert.async(); - assert.ok(this.oSortPanel); - - //check if the change event has been fired - this.oSortPanel.attachEvent("change", function(oEvent){ - assert.ok(typeof this.oSortPanel.getP13nModel().getProperty("/items")[0].descending == "boolean", "'Descending' is still a boolean after the change"); - assert.ok(this.oSortPanel.getP13nModel().getProperty("/items")[0].descending === true, "'Descending' is still a boolean after the change (+ value changed to true)"); - done(); - }.bind(this)); - - //fire the change event which is being used for the change of sort order maunally - this.oSortPanel._oListControl.getItems()[0].getCells()[1].fireChange({ - - //Select control instance - selectedItem: this.oSortPanel._oListControl.getItems()[0].getCells()[1].getItems()[1] // Item index 0: false, 1:true - }); - - }); - -}); diff --git a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/UIManager.qunit.js b/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/UIManager.qunit.js deleted file mode 100644 index ecf4b8377f43..000000000000 --- a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/UIManager.qunit.js +++ /dev/null @@ -1,271 +0,0 @@ -/* global QUnit*/ -sap.ui.define([ - "sap/m/p13n/modules/AdaptationProvider", - "sap/ui/mdc/p13n/UIManager", - "sap/ui/mdc/Control", - "sap/ui/core/Core" -], function (AdaptationProvider, UIManager, Control, oCore) { - "use strict"; - - QUnit.module("Basics", { - beforeEach: function() { - this.oAdaptationProvider = new AdaptationProvider(); - }, - afterEach: function() { - this.oAdaptationProvider.destroy(); - this.oAdaptationProvider = null; - } - }); - - QUnit.test("Use UIManager as Singleton", function(assert){ - - UIManager.getInstance(this.oAdaptationProvider); - - assert.throws( - function() { - return new UIManager(); - }, - function(oError) { - return ( - oError instanceof Error && - oError.message === "UIManager: This class is a singleton and should not be used without an AdaptationProvider. Please use 'sap.ui.mdc.p13n.Engine.getInstance().uimanager' instead" - ); - }, - "calling the constructor subsequently throws an error." - ); - - UIManager.getInstance().destroy(); - }); - - QUnit.test("Use UIManager only with a valid AdaptationProvider", function(assert){ - - assert.throws( - function() { - return UIManager.getInstance(); - }, - function(oError) { - return ( - oError instanceof Error && - oError.message === "The UIManager singleton must not be accessed without an AdaptationProvider interface!" - ); - }, - "calling then UIManager without a valid interface throws an Error" - ); - }); - - QUnit.module("Check UI popup + P13nWrapper creation", { - beforeEach: function() { - this.oAdaptationProvider = new AdaptationProvider(); - this.oAdaptationProvider.initAdaptation = function(){ - return Promise.resolve(); - }; - this.oAdaptationProvider.handleP13n = function(){ - return Promise.resolve(); - }; - this.oAdaptationProvider.reset = function(){ - return Promise.resolve(); - }; - - this.oAdaptationProvider.getUISettings = function(){ - return this.oUISettings; - }.bind(this); - - this.oControl = new Control(); - this.oAdaptationUI = new Control({id: "SomeTestUI"}); - }, - afterEach: function() { - this.oAdaptationProvider.destroy(); - this.oAdaptationProvider = null; - UIManager.getInstance().destroy(); - this.oUISettings = null; - this.oAdaptationUI.destroy(); - this.oAdaptationUI = null; - } - }); - - QUnit.test("call 'create' - check UI creation (only with a string as key), livemode: false (default)", function(assert) { - var done = assert.async(); - UIManager.getInstance(this.oAdaptationProvider); - var sTestTitle = "Some Test UI Title"; - - this.oUISettings = { - TestKey: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - } - }; - - UIManager.getInstance().create(this.oControl, "TestKey", []).then(function(oPopup){ - assert.ok(oPopup, "Popup created"); - assert.ok(oPopup.isA("sap.m.Dialog"), "Popup is a modal Dialog"); - assert.equal(oPopup.getTitle(), sTestTitle, "Only one key provided - use the controller UI settings"); - done(); - }); - }); - - QUnit.test("call 'create' - check UI creation (only with a string as key), livemode: true (experimental)", function(assert) { - var done = assert.async(); - UIManager.getInstance(this.oAdaptationProvider); - var sTestTitle = "Some Test UI Title"; - UIManager.getInstance().bLiveMode = true; - - this.oUISettings = { - TestKey: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - } - }; - - UIManager.getInstance().create(this.oControl, "TestKey", []).then(function(oPopup){ - assert.ok(oPopup, "Popup created"); - assert.ok(oPopup.isA("sap.m.ResponsivePopover"), "Popup is a Popover for livemode"); - assert.equal(oPopup.getTitle(), sTestTitle, "Only one key provided - use the controller UI settings"); - UIManager.getInstance().bLiveMode = false; - done(); - }); - }); - - QUnit.test("call 'create' - check UI creation (only with one key in an array)", function(assert) { - var done = assert.async(); - UIManager.getInstance(this.oAdaptationProvider); - var sTestTitle = "Some Test UI Title"; - - this.oUISettings = { - TestKey: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - } - }; - - UIManager.getInstance().create(this.oControl, ["TestKey"], []).then(function(oPopup){ - assert.ok(oPopup, "Popup created"); - assert.ok(oPopup.isA("sap.m.Dialog"), "Popup is a modal Dialog"); - assert.equal(oPopup.getTitle(), sTestTitle, "Only one key provided - use the controller UI settings"); - done(); - }); - }); - - QUnit.test("call 'create' - check UI creation (with multiple keys in an array)", function(assert) { - var done = assert.async(); - UIManager.getInstance(this.oAdaptationProvider); - var sTestTitle = "Some Test UI Title"; - - this.oUISettings = { - TestKey: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - }, - TestKey2: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - } - }; - - UIManager.getInstance().create(this.oControl, ["TestKey", "TestKey2"], []).then(function(oPopup){ - assert.ok(oPopup, "Popup created"); - assert.ok(oPopup.isA("sap.m.Dialog"), "Popup is a modal Dialog"); - assert.ok(oPopup.getContent()[0].isA("sap.m.p13n.Container"), "Use an additional wrapper in case multiple keys have been provided"); - assert.ok(oPopup.getContent()[0].oLayout.getEnableScrolling(), "The inner wrapper has scrolling enabled"); - assert.notOk(oPopup.getVerticalScrolling(), "The outer container should not have vertical scrolling enabled, as the Wrapper takes care of it"); - assert.equal(oPopup.getTitle(), oCore.getLibraryResourceBundle("sap.ui.mdc").getText("p13nDialog.VIEW_SETTINGS"), "Multiple keys provided - use the default settings"); - done(); - }); - }); - - QUnit.test("call 'show' - popup should open ", function(assert) { - var done = assert.async(); - UIManager.getInstance(this.oAdaptationProvider); - var sTestTitle = "Some Test UI Title"; - - this.oUISettings = { - TestKey: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - } - }; - - UIManager.getInstance().show(this.oControl, ["TestKey"]).then(function(oPopup){ - assert.ok(oPopup, "Popup created"); - assert.ok(oPopup.isOpen(), "Dialog has been created + opened"); - oPopup.destroy(); - done(); - }); - }); - - QUnit.test("call 'show' and check 'ativeP13n' set/has", function(assert) { - var done = assert.async(2); - UIManager.getInstance(this.oAdaptationProvider); - var sTestTitle = "Some Test UI Title"; - - var mParams = { - control: null, - keys: null - }; - - this.oUISettings = { - TestKey: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - } - }; - - this.oAdaptationProvider.setActiveP13n = function(vControl, aKeys) { - mParams.control = vControl; - mParams.keys = aKeys; - }; - - this.oAdaptationProvider.hasActiveP13n = function(vControl) { - assert.ok(vControl, "'hasActiveP13n' executed"); - done(); - }; - - UIManager.getInstance().show(this.oControl, ["TestKey"]).then(function(oPopup){ - assert.ok(mParams.control, "'setActiveP13n' executed"); - assert.equal(mParams.keys[0], "TestKey", "The opened key hs been provided"); - oPopup.destroy(); - done(); - }); - }); - - - QUnit.test("Check 'validateP13n' execution (if provided)", function(assert) { - var done = assert.async(); - UIManager.getInstance(this.oAdaptationProvider); - var sTestTitle = "Some Test UI Title"; - - this.oUISettings = { - TestKey: { - containerSettings: { - title: sTestTitle - }, - adaptationUI: Promise.resolve(this.oAdaptationUI) - } - }; - - this.oAdaptationProvider.validateP13n = function(vControl, sKey, oAdaptationUI) { - assert.ok(vControl.isA("sap.ui.mdc.Control"), "Control provided"); - assert.ok(typeof sKey == "string", "Key provided"); - assert.ok(oAdaptationUI.isA("sap.ui.core.Control"), "Adaptation UI provided"); - done(); - }; - - UIManager.getInstance().show(this.oControl, ["TestKey"], []).then(function(oPopup){ - oPopup.destroy(); - }); - }); - -}); diff --git a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/testsuite.p13n.qunit.js b/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/testsuite.p13n.qunit.js index 5aee04452b9b..e96c2a18f8f3 100644 --- a/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/testsuite.p13n.qunit.js +++ b/src/sap.ui.mdc/test/sap/ui/mdc/qunit/p13n/testsuite.p13n.qunit.js @@ -118,15 +118,6 @@ sap.ui.define(["sap/ui/Device"], function (Device) { ] } }, - "UIManager": { - group: "P13n logic", - module: "./UIManager.qunit", - ui5: { - libs: [ - "sap.ui.mdc" - ] - } - }, "P13nBuilder": { group: "P13n logic", module: "./P13nBuilder.qunit",