<commit_before><!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>QUnit Page for sap.m.Table</title>

		<script src="../shared-config.js"></script>
		<script id="sap-ui-bootstrap"
			src="../../../../resources/sap-ui-core.js"
			data-sap-ui-noConflict="true"
			data-sap-ui-libs="sap.m">
		</script>

		<link rel="stylesheet" href="../../../../resources/sap/ui/thirdparty/qunit.css" type="text/css" media="screen">
		<script src="../../../../resources/sap/ui/thirdparty/qunit.js"></script>
		<script src="../../../../resources/sap/ui/qunit/qunit-junit.js"></script>
		<script src="../../../../resources/sap/ui/qunit/QUnitUtils.js"></script>
		<script src="../../../../resources/sap/ui/thirdparty/sinon.js"></script>

		<script>

		jQuery.sap.require("sap.m.TablePersoDialog");

		function createSUT(sId, bCreateColumns, bCreateHeader, sMode) {
			var oData = {
				items: [
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "David", color: "green", number: 0 },
				],
				cols: ["Name", "Color", "Number"]
			};
			// sap.m.Table is the system under test
			var sut = new sap.m.Table(sId);

			if(bCreateColumns) {

				var aColumns = oData.cols.map(function (colname) {
					return new sap.m.Column({ header: new sap.m.Label({ text: colname })})
					}),
					i = aColumns.length;
				while(i--){
					sut.addColumn(aColumns[aColumns.length - i - 1]);
				}
			}

			if(bCreateHeader) {
				sut.setHeaderToolbar(new sap.m.Toolbar({
					content: [
								new sap.m.Label({text: "Random Data"}),
								new sap.m.ToolbarSpacer({}),
								new sap.m.Button("idPersonalizationButton", {
									icon: "sap-icon://person-placeholder"
								})
							]
				}));
			}

			if(sMode) {
				sut.setMode(sMode);
			}

			sut.setModel(new sap.ui.model.json.JSONModel(oData));
			sut.bindAggregation("items", "/items", new sap.m.ColumnListItem({
				cells: oData.cols.map(function (colname) {
					return new sap.m.Label({ text: "{" + colname.toLowerCase() + "}" })
				})
			}));


			return sut;
		}


		QUnit.module("Display");

		QUnit.test("Basic Properties", function(assert) {
			var sut = createSUT('idBasicPropertiesTable');
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check if table has been added to dom tree
			assert.ok(sut.$().length > 0, "Table in DOM tree");

			sut.setVisible(false);
			sap.ui.getCore().applyChanges();
			assert.ok(sut.$().length === 0, "Table has been removed from DOM")

			//clean up
			sut.destroy()
		});

		QUnit.test("Column Display", function(assert) {
			var sut = createSUT('idColumnDisplayTable', true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check table columns (should be three)
			var aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 3, "Table has three columns rendered");
			assert.ok(aLabels[0].textContent == "Name", "First column named 'Name'");
			assert.ok(aLabels[1].textContent == "Color", "First column named 'Color'");
			assert.ok(aLabels[2].textContent == "Number", "First column named 'Number'");

			//Remove first column
			var oFirstColumn = sut.removeColumn("__column0");
			sap.ui.getCore().applyChanges();

			//Check table columns (should be two)
			aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 2, "Table has three columns" );

			//Insert column again
			sut.insertColumn(oFirstColumn, 1);
			sap.ui.getCore().applyChanges();

			//Check table columns and their positions
			aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 3, "Table has three columns rendered");
			assert.ok(aLabels[1].textContent == "Name", "First column named 'Name'");
			assert.ok(aLabels[0].textContent == "Color", "First column named 'Color'");
			assert.ok(aLabels[2].textContent == "Number", "First column named 'Number'");

			//remove all columns
			sut.removeAllColumns();
			sap.ui.getCore().applyChanges();
			aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 0, "Table has no more columns rendered");

			//clean up
			sut.destroy();
		});

		QUnit.test("Header Toolbar Display", function(assert) {
			var sut = createSUT('idHeaderToolbarDisplayTable', true, true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check if header toolbar is in DOM
			var oToolBar = sut.getHeaderToolbar();
			assert.ok(oToolBar.$().length > 0, "HeaderToolbar in DOM tree");

			//clean up
			sut.destroy();
		});


		QUnit.test("Empty Table", function(assert) {
			var sut = createSUT('idEmptyTable', true, true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();


			//Check if header toolbar is in DOM

			var oData = {
				items: [],
				cols: ["Name", "Color", "Number"]
			};
			sut.setModel(new sap.ui.model.json.JSONModel(oData));
			sap.ui.getCore().applyChanges();

			var aNoDataRow = sut.$().find("#" + sut.getId() + "-nodata");

			assert.ok(aNoDataRow.length === 1, "Table displays 'No Data'");

			//clean up
			sut.destroy();
		});

		QUnit.test("Fixed Layout", function(assert) {
			var sut = createSUT('FixedLayoutTestTable');
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			// check initial rendering
			assert.strictEqual(sut.$().find("table").css("table-layout"), "fixed", "Table has fixed layout after initial rendering");

			sut.setFixedLayout(false);
			sap.ui.getCore().applyChanges();
			assert.strictEqual(sut.$().find("table").css("table-layout"), "auto", "Table has correct layout after disabling fix layout.");

			//clean up
			sut.destroy()
		});

		QUnit.module("Modes");

		QUnit.test("MultiSelect", function(assert) {
			var sut = createSUT('idMultiSelectTable', true, true, "MultiSelect");
            var oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.m");
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check if multiselect checkboxes are visible
			var aSelectionChecks = sut.$().find(".sapMCb");
			assert.ok(aSelectionChecks.length === 4, "Table displays selection checkboxes");

			// Check if select all checkbox has aria-label attribute
            var $selectAllCheckBox = sut.$().find(".sapMListTblHeader .sapMCb").first();
            assert.strictEqual($selectAllCheckBox.attr('aria-label'), oBundle.getText("TABLE_CHECKBOX_SELECT_ALL"), "The select all checkbox has an aria-label assigned");

			//Check if checkboxes are initially not selected
			var aSelectionChecksMarked = sut.$().find(".sapMCbMarkChecked");
			assert.ok(aSelectionChecksMarked.length === 0, "Selection checkboxes not checked");

			//Check if 'selectAll' marks all rows as selected
			sut.selectAll();
			sap.ui.getCore().applyChanges();

			aSelectionChecksMarked = sut.$().find(".sapMCbMarkChecked");
			assert.ok(aSelectionChecksMarked.length === 4, "Selection checkboxes ALL checked");

			//clean up
			sut.destroy();
		});

		QUnit.test("Container Padding Classes", function (assert) {
			// System under Test + Act
			var oContainer = new sap.m.Table(),
				sResponsiveSize = (sap.ui.Device.resize.width <= 599 ? "0px" : (sap.ui.Device.resize.width <= 1023 ? "16px" : "16px 32px")),
				aResponsiveSize = sResponsiveSize.split(" "),
				$container,
				$containerContent;

			// Act
			oContainer.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();
			oContainer.addStyleClass("sapUiNoContentPadding");
			$containerContent = oContainer.$();

			// Assert
			assert.strictEqual($containerContent.css("padding-left"), "0px", "The container has no left content padding when class \"sapUiNoContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-right"), "0px", "The container has no right content padding when class \"sapUiNoContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-top"), "0px", "The container has no top content padding when class \"sapUiNoContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-bottom"), "0px", "The container has no bottom content padding when class \"sapUiNoContentPadding\" is set");

			// Act
			oContainer.removeStyleClass("sapUiNoContentPadding");
			oContainer.addStyleClass("sapUiContentPadding");

			// Assert
			assert.strictEqual($containerContent.css("padding-left"), "16px", "The container has 1rem left content padding when class \"sapUiContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-right"), "16px", "The container has 1rem right content padding when class \"sapUiContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-top"), "16px", "The container has 1rem top content padding when class \"sapUiContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-bottom"), "16px", "The container has 1rem bottom content padding when class \"sapUiContentPadding\" is set");

			// Act
			oContainer.removeStyleClass("sapUiContentPadding");
			oContainer.addStyleClass("sapUiResponsiveContentPadding");

			// Assert
			assert.strictEqual($containerContent.css("padding-left"), (aResponsiveSize[1] ? aResponsiveSize[1] : aResponsiveSize[0]), "The container has " + sResponsiveSize + " left content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");
			assert.strictEqual($containerContent.css("padding-right"), (aResponsiveSize[1] ? aResponsiveSize[1] : aResponsiveSize[0]) , "The container has " + sResponsiveSize + " right content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");
			assert.strictEqual($containerContent.css("padding-top"), aResponsiveSize[0], "The container has " + sResponsiveSize + " top content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");
			assert.strictEqual($containerContent.css("padding-bottom"), aResponsiveSize[0], "The container has " + sResponsiveSize + " bottom content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");

			// Cleanup
			oContainer.destroy();
		});

		QUnit.module("TypeColumn");

		QUnit.test("TypeColumn visibility should updated correctly", function(assert) {
			var oTable = createSUT('idTypeTable', true);
			oTable.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible by default");
			assert.strictEqual(oTable.$().find("th").last().attr("aria-hidden"), "true", "Aria hidden set correctly");

			oTable.getItems()[0].setType("Navigation");
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible when an item type is Navigation");

			oTable.getItems()[0].setType("Active");
			sap.ui.getCore().applyChanges();
			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible since Active type does not need column");

			oTable.getItems()[0].setType("Detail");
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible when an item type is Detail");

			oTable.getItems()[0].setVisible(false);
			sap.ui.getCore().applyChanges();
			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible since item is not visible");

			var oClone = oTable.getItems()[1].clone().setType("DetailAndActive");
			oTable.addItem(oClone);
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible because new type is DetailAndActive");

			oClone.destroy();
			sap.ui.getCore().applyChanges();
			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible since new item is destroyed");

			oTable.getItems()[0].setVisible(true);
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible because first item with type detail is visible again");

			oTable.rerender();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible rerender did not change the visibility of the type column");

			oTable.destroy();
		});

		QUnit.module("Event");

		QUnit.test("SelectAll in selectionChange event", function(assert) {
			var sut = createSUT('idMultiSelectTable', true, true, "MultiSelect");
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			sut.attachEventOnce("selectionChange", function(e) {
				assert.ok(e.getParameter("selectAll"), "selectAll parameter is true when the 'selectAll' checkbox is pressed");
			});
			var $SelectAllCheckbox = sut.$().find(".sapMCb").first().trigger("tap");

			sut.attachEventOnce("selectionChange", function(e) {
				assert.ok(!e.getParameter("selectAll"), "selectAll parameter is false when the 'selectAll' checkbox is unpressed");
			});
			$SelectAllCheckbox.trigger("tap");

			//clean up
			sut.destroy();
		});
		</script>
	</head>
	<body id="body" class="sapUiBody">
		<h1 id="qunit-header">QUnit tests: sap.m.Table</h1>
		<h2 id="qunit-banner"></h2>
		<h2 id="qunit-userAgent"></h2>
		<div id="qunit-testrunner-toolbar"></div>
		<ol id="qunit-tests"></ol>
		<div id="qunit-fixture"></div>
	</body>
</html><commit_msg>[INTERNAL] sap.m.Table: Improve code coverage<commit_after><!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>QUnit Page for sap.m.Table</title>

		<script src="../shared-config.js"></script>
		<script id="sap-ui-bootstrap"
			src="../../../../resources/sap-ui-core.js"
			data-sap-ui-noConflict="true"
			data-sap-ui-libs="sap.m">
		</script>

		<link rel="stylesheet" href="../../../../resources/sap/ui/thirdparty/qunit.css" type="text/css" media="screen">
		<script src="../../../../resources/sap/ui/thirdparty/qunit.js"></script>
		<script src="../../../../resources/sap/ui/qunit/qunit-junit.js"></script>
		<script src="../../../../resources/sap/ui/qunit/QUnitUtils.js"></script>
		<script src="../../../../resources/sap/ui/thirdparty/sinon.js"></script>
		<script src="../../../../resources/sap/ui/qunit/qunit-coverage.js" data-sap-ui-cover-only="sap/m/Table"></script>

		<script>

		jQuery.sap.require("sap.m.TablePersoDialog");

		function createSUT(sId, bCreateColumns, bCreateHeader, sMode) {
			var oData = {
				items: [
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "David", color: "green", number: 0 },
				],
				cols: ["Name", "Color", "Number"]
			};
			// sap.m.Table is the system under test
			var sut = new sap.m.Table(sId);

			if(bCreateColumns) {

				var aColumns = oData.cols.map(function (colname) {
					return new sap.m.Column({ header: new sap.m.Label({ text: colname })})
					}),
					i = aColumns.length;
				while(i--){
					sut.addColumn(aColumns[aColumns.length - i - 1]);
				}
			}

			if(bCreateHeader) {
				sut.setHeaderToolbar(new sap.m.Toolbar({
					content: [
								new sap.m.Label({text: "Random Data"}),
								new sap.m.ToolbarSpacer({}),
								new sap.m.Button("idPersonalizationButton", {
									icon: "sap-icon://person-placeholder"
								})
							]
				}));
			}

			if(sMode) {
				sut.setMode(sMode);
			}

			sut.setModel(new sap.ui.model.json.JSONModel(oData));
			sut.bindAggregation("items", "/items", new sap.m.ColumnListItem({
				cells: oData.cols.map(function (colname) {
					return new sap.m.Label({ text: "{" + colname.toLowerCase() + "}" })
				})
			}));


			return sut;
		}


		QUnit.module("Display");

		QUnit.test("Basic Properties", function(assert) {
			var sut = createSUT('idBasicPropertiesTable');
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check if table has been added to dom tree
			assert.ok(sut.$().length > 0, "Table in DOM tree");

			assert.ok(!sut.$().children().hasClass("sapMTableOverlay"), "Table overlay is not rendered as showOverlay=false");
			sut.setShowOverlay(true);
			sap.ui.getCore().applyChanges();
			assert.ok(sut.$().children().hasClass("sapMTableOverlay"), "Table overlay is rendered as showOverlay=true");

			sut.setVisible(false);
			sap.ui.getCore().applyChanges();
			assert.ok(sut.$().length === 0, "Table has been removed from DOM");

			assert.equal(sut.getItemsContainerDomRef(), sut.$("tblBody")[0]);

			//clean up
			sut.destroy()
		});

		QUnit.test("Column Display", function(assert) {
			var sut = createSUT('idColumnDisplayTable', true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check table columns (should be three)
			var aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 3, "Table has three columns rendered");
			assert.ok(aLabels[0].textContent == "Name", "First column named 'Name'");
			assert.ok(aLabels[1].textContent == "Color", "First column named 'Color'");
			assert.ok(aLabels[2].textContent == "Number", "First column named 'Number'");

			//Remove first column
			var oFirstColumn = sut.removeColumn("__column0");
			sap.ui.getCore().applyChanges();

			//Check table columns (should be two)
			aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 2, "Table has three columns" );

			//Insert column again
			sut.insertColumn(oFirstColumn, 1);
			sap.ui.getCore().applyChanges();

			//Check table columns and their positions
			aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 3, "Table has three columns rendered");
			assert.ok(aLabels[1].textContent == "Name", "First column named 'Name'");
			assert.ok(aLabels[0].textContent == "Color", "First column named 'Color'");
			assert.ok(aLabels[2].textContent == "Number", "First column named 'Number'");

			//remove all columns
			sut.removeAllColumns();
			sap.ui.getCore().applyChanges();
			aLabels = sut.$().find('th>label');
			assert.ok(aLabels.length === 0, "Table has no more columns rendered");

			//clean up
			sut.destroy();
		});

		QUnit.test("Header Toolbar Display", function(assert) {
			var sut = createSUT('idHeaderToolbarDisplayTable', true, true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check if header toolbar is in DOM
			var oToolBar = sut.getHeaderToolbar();
			assert.ok(oToolBar.$().length > 0, "HeaderToolbar in DOM tree");

			//clean up
			sut.destroy();
		});


		QUnit.test("Empty Table", function(assert) {
			var sut = createSUT('idEmptyTable', true, true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();


			//Check if header toolbar is in DOM

			var oData = {
				items: [],
				cols: ["Name", "Color", "Number"]
			};
			sut.setModel(new sap.ui.model.json.JSONModel(oData));
			sap.ui.getCore().applyChanges();

			var aNoDataRow = sut.$().find("#" + sut.getId() + "-nodata");

			assert.ok(aNoDataRow.length === 1, "Table displays 'No Data'");

			//clean up
			sut.destroy();
		});

		QUnit.test("Fixed Layout", function(assert) {
			var sut = createSUT('FixedLayoutTestTable');
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			// check initial rendering
			assert.strictEqual(sut.$().find("table").css("table-layout"), "fixed", "Table has fixed layout after initial rendering");

			sut.setFixedLayout(false);
			sap.ui.getCore().applyChanges();
			assert.strictEqual(sut.$().find("table").css("table-layout"), "auto", "Table has correct layout after disabling fix layout.");

			//clean up
			sut.destroy()
		});

		QUnit.module("Modes");

		QUnit.test("MultiSelect", function(assert) {
			var sut = createSUT('idMultiSelectTable', true, true, "MultiSelect");
            var oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.m");
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			//Check if multiselect checkboxes are visible
			var aSelectionChecks = sut.$().find(".sapMCb");
			assert.ok(aSelectionChecks.length === 4, "Table displays selection checkboxes");

			// Check if select all checkbox has aria-label attribute
            var $selectAllCheckBox = sut.$().find(".sapMListTblHeader .sapMCb").first();
            assert.strictEqual($selectAllCheckBox.attr('aria-label'), oBundle.getText("TABLE_CHECKBOX_SELECT_ALL"), "The select all checkbox has an aria-label assigned");

			//Check if checkboxes are initially not selected
			var aSelectionChecksMarked = sut.$().find(".sapMCbMarkChecked");
			assert.ok(aSelectionChecksMarked.length === 0, "Selection checkboxes not checked");

			//Check if 'selectAll' marks all rows as selected
			sut.selectAll();
			sap.ui.getCore().applyChanges();

			aSelectionChecksMarked = sut.$().find(".sapMCbMarkChecked");
			assert.ok(aSelectionChecksMarked.length === 4, "Selection checkboxes ALL checked");

			//clean up
			sut.destroy();
		});

		QUnit.test("Container Padding Classes", function (assert) {
			// System under Test + Act
			var oContainer = new sap.m.Table(),
				sResponsiveSize = (sap.ui.Device.resize.width <= 599 ? "0px" : (sap.ui.Device.resize.width <= 1023 ? "16px" : "16px 32px")),
				aResponsiveSize = sResponsiveSize.split(" "),
				$container,
				$containerContent;

			// Act
			oContainer.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();
			oContainer.addStyleClass("sapUiNoContentPadding");
			$containerContent = oContainer.$();

			// Assert
			assert.strictEqual($containerContent.css("padding-left"), "0px", "The container has no left content padding when class \"sapUiNoContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-right"), "0px", "The container has no right content padding when class \"sapUiNoContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-top"), "0px", "The container has no top content padding when class \"sapUiNoContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-bottom"), "0px", "The container has no bottom content padding when class \"sapUiNoContentPadding\" is set");

			// Act
			oContainer.removeStyleClass("sapUiNoContentPadding");
			oContainer.addStyleClass("sapUiContentPadding");

			// Assert
			assert.strictEqual($containerContent.css("padding-left"), "16px", "The container has 1rem left content padding when class \"sapUiContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-right"), "16px", "The container has 1rem right content padding when class \"sapUiContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-top"), "16px", "The container has 1rem top content padding when class \"sapUiContentPadding\" is set");
			assert.strictEqual($containerContent.css("padding-bottom"), "16px", "The container has 1rem bottom content padding when class \"sapUiContentPadding\" is set");

			// Act
			oContainer.removeStyleClass("sapUiContentPadding");
			oContainer.addStyleClass("sapUiResponsiveContentPadding");

			// Assert
			assert.strictEqual($containerContent.css("padding-left"), (aResponsiveSize[1] ? aResponsiveSize[1] : aResponsiveSize[0]), "The container has " + sResponsiveSize + " left content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");
			assert.strictEqual($containerContent.css("padding-right"), (aResponsiveSize[1] ? aResponsiveSize[1] : aResponsiveSize[0]) , "The container has " + sResponsiveSize + " right content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");
			assert.strictEqual($containerContent.css("padding-top"), aResponsiveSize[0], "The container has " + sResponsiveSize + " top content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");
			assert.strictEqual($containerContent.css("padding-bottom"), aResponsiveSize[0], "The container has " + sResponsiveSize + " bottom content padding when class \"sapUiResponsiveContentPadding\" is set (tested value depends on window size)");

			// Cleanup
			oContainer.destroy();
		});

		QUnit.module("TypeColumn");

		QUnit.test("TypeColumn visibility should updated correctly", function(assert) {
			var oTable = createSUT('idTypeTable', true);
			oTable.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible by default");
			assert.strictEqual(oTable.$().find("th").last().attr("aria-hidden"), "true", "Aria hidden set correctly");

			oTable.getItems()[0].setType("Navigation");
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible when an item type is Navigation");

			oTable.getItems()[0].setType("Active");
			sap.ui.getCore().applyChanges();
			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible since Active type does not need column");

			oTable.getItems()[0].setType("Detail");
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible when an item type is Detail");

			oTable.getItems()[0].setVisible(false);
			sap.ui.getCore().applyChanges();
			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible since item is not visible");

			var oClone = oTable.getItems()[1].clone().setType("DetailAndActive");
			oTable.addItem(oClone);
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible because new type is DetailAndActive");

			oClone.destroy();
			sap.ui.getCore().applyChanges();
			assert.notOk(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is not visible since new item is destroyed");

			oTable.getItems()[0].setVisible(true);
			sap.ui.getCore().applyChanges();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible because first item with type detail is visible again");

			oTable.rerender();
			assert.ok(oTable.$().find("table").hasClass("sapMListTblHasNav"), "Type column is visible rerender did not change the visibility of the type column");

			oTable.destroy();
		});

		QUnit.module("Event");

		QUnit.test("SelectAll in selectionChange event", function(assert) {
			var sut = createSUT('idMultiSelectTable', true, true, "MultiSelect");
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			sut.attachEventOnce("selectionChange", function(e) {
				assert.ok(e.getParameter("selectAll"), "selectAll parameter is true when the 'selectAll' checkbox is pressed");
			});
			var $SelectAllCheckbox = sut.$().find(".sapMCb").first().trigger("tap");

			sut.attachEventOnce("selectionChange", function(e) {
				assert.ok(!e.getParameter("selectAll"), "selectAll parameter is false when the 'selectAll' checkbox is unpressed");
			});
			$SelectAllCheckbox.trigger("tap");

			//clean up
			sut.destroy();
		});

		QUnit.module("Functionalities");

		QUnit.test("Test for removeAllItems", function(assert) {
			var sut = createSUT("idTableRemoveAllItems", true, true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			assert.ok(sut.getItems().length > 0, "Table contains items");
			sut.removeAllItems();
			assert.ok(sut.getItems().length === 0, "Items are removed from the Table");

			sut.destroy();
		});

		QUnit.test("Test for destroyItems", function(assert) {
			var sut = createSUT("idTableDestroyItems", true, true);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			assert.ok(sut.getItems().length > 0, "Table contains items");
			sut.destroyItems();
			assert.ok(sut.getItems().length === 0, "Items are removed from the Table");

			sut.destroy();
		});

		QUnit.test("Test for onColumnResize", function(assert) {
			this.clock = sinon.useFakeTimers();
			var oColumn = new sap.m.Column({
				minScreenWidth : "tablet",
				demandPopin: true
			}),
			sut = new sap.m.Table({
				columns : oColumn
			}),
			tableResizeSpy = sinon.spy(sut, "onColumnResize");

			// The table needs to be rendered for the column media object to be initialized
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			oColumn._notifyResize({from: 600}); // this is the default value for minScreenWidth="phone"
			this.clock.tick(1);

			assert.ok(!tableResizeSpy.called, "Table resize not called, if media is the same");

			oColumn._notifyResize({from: 240});
			this.clock.tick(1);

			assert.ok(tableResizeSpy.called, "Table resize called, if media is different");

			sut.destroy();
		});

		QUnit.test("Test for onItemSelectedChange", function(assert) {
			var sut = createSUT("idTableSelectedChange", true, false, "MultiSelect");
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();
			var fnOnItemSelectedChange = sinon.spy(sut, "onItemSelectedChange");

			var oItem = sut.getItems()[0];
			oItem.setSelected(true);
			assert.ok(fnOnItemSelectedChange.called, "function called as the selection changed");

			sut.destroy();
		});

		QUnit.test("Test for accessibility content", function(assert) {
			var sut = createSUT("idTableAcc", true, false, "MultiSelect");
			var oColumn = sut.getColumns()[0];
			var oBinding = sut.getBinding("items");
			oColumn.setFooter(new sap.m.Label({text: "Greetings"}));
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			// accessibility role
			assert.equal(sut.getAccessibilityType(), "Table", "Accessilitiy role correctly set");

			// _setHeaderAnnouncement() test
			var $tblHeader = sut.$("tblHeader").first().trigger("focusin");
			var $invisibleText = document.getElementById($tblHeader.attr("aria-labelledBy"));
			assert.equal($invisibleText.innerHTML, "Header Row Name Color Number", "Text correctly assigned for screen reader announcement");

			// _setFooterAnnouncment() test
			var $tblFooter = sut.$("tblFooter").first().trigger("focusin");
			sap.ui.getCore().applyChanges();
			$invisibleText = document.getElementById($tblHeader.attr("aria-labelledBy"));
			assert.equal($invisibleText.innerHTML, "Footer Row Name Greetings", "Text correctly assigned for screen reader announcement");

			// noDataText test
			oBinding.filter([new sap.ui.model.Filter("name", "Contains", "xxx")]);
			sap.ui.getCore().applyChanges();
			var $noData = sut.$("nodata").first().trigger("focusin");
			$invisibleText = document.getElementById($tblHeader.attr("aria-labelledBy"));
			assert.equal($invisibleText.innerHTML, "No data", "Text correctly assinged for screen reader announcement");

			sut.destroy();
		});

		QUnit.test("Test for isHeaderRowEvent and isFooterRowEvent using saptabnext", function(assert) {
			var sut = createSUT("idHeaderFooterEvents", true);
			var oColumn = sut.getColumns()[0];
			var fnIsHeaderRowEvent = sinon.spy(sut, "isHeaderRowEvent");
			var fnIsFooterRowEvent = sinon.spy(sut, "isFooterRowEvent");
			oColumn.setFooter(new sap.m.Label({text: "Greetings"}));
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			// saptabnext event on tblHeader
			var $tblHeader = sut.$("tblHeader").first().trigger("focusin");
			qutils.triggerKeydown($tblHeader, jQuery.sap.KeyCodes.TAB);
			assert.ok(fnIsHeaderRowEvent.called, "Event was triggered on the header");

			// saptabnext on tblFooter
			var $tblFooter = sut.$("tblFooter").first().trigger("focusin");
			qutils.triggerKeydown($tblFooter, jQuery.sap.KeyCodes.TAB);
			assert.ok(fnIsFooterRowEvent.called, "Event was triggered on the footer");

			sut.destroy();
		});

		QUnit.test("Test for onsaptabprevious", function(assert) {
			var sut = createSUT("idTableKeyboardNavigation", true, false, "MultiSelect");
			sut.setGrowing(true);
			sut.setGrowingThreshold(5);
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			var $tblHeader = sut.$("tblHeader").first().trigger("focusin");
			// shift-tab on header row
			qutils.triggerKeyboardEvent($tblHeader, jQuery.sap.KeyCodes.TAB, true, false, false);
			assert.equal(document.activeElement, sut.$("before")[0]);
			
			// trigger onsaptabnext
			qutils.triggerKeydown($tblHeader, jQuery.sap.KeyCodes.TAB);
			assert.equal(document.activeElement, sut.$("after")[0]);

			var $trigger = sut.$("trigger").first();
			assert.ok(!sut.bAnnounceDetails, "Focus is not in the table");

			// shift-tab on from the trigger button
			qutils.triggerKeyboardEvent($trigger, jQuery.sap.KeyCodes.TAB, true, false, false);
			window.setTimeout(function() {
				assert.ok(sut.bAnnounceDetails, "Focus in back in the table");
				assert.equal(document.activeElement, $tblHeader[0]);

				sut.destroy();
			}, 0);
		});

		QUnit.test("Test for checkGrowingFromScratch", function(assert) {
			var oData = {
				items: [
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "David", color: "green", number: 0 },
					{ name: "David", color: "green", number: 0 },
					{ name: "David", color: "green", number: 0 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "David", color: "green", number: 0 },
					{ name: "David", color: "green", number: 0 },
					{ name: "David", color: "green", number: 0 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Michelle", color: "orange", number: 3.14 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "Joseph", color: "blue", number: 1.618 },
					{ name: "David", color: "green", number: 0 },
					{ name: "David", color: "green", number: 0 },
					{ name: "David", color: "green", number: 0 }
				],
				cols: ["Name", "Color", "Number"]
			};

			var sut = new sap.m.Table("idResponsiveTable", {
				growing: true,
				growingThreshold: 5
			});

			var aColumns = oData.cols.map(function (colname) {
				if (colname === "Name") {
					return new sap.m.Column({ header: new sap.m.Label({ text: colname }), mergeDuplicates: true});
				}
				return new sap.m.Column({ header: new sap.m.Label({ text: colname })});
			}),
			i = aColumns.length;
			while(i--){
				sut.addColumn(aColumns[aColumns.length - i - 1]);
			}

			sut.setModel(new sap.ui.model.json.JSONModel(oData));
			sut.bindAggregation("items", "/items", new sap.m.ColumnListItem({
				cells: oData.cols.map(function (colname) {
					return new sap.m.Label({ text: "{" + colname.toLowerCase() + "}" })
				})
			}));

			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			var fnCheckGrowingFromScratch = sinon.spy(sut, "checkGrowingFromScratch");

			var iItemsLength = sut.getItems().length;
			assert.equal(iItemsLength, 5, "5 items are shown in the table, growing is not triggered");

			var $trigger = sut.$("trigger").trigger("focusin");
			qutils.triggerKeydown($trigger, jQuery.sap.KeyCodes.SPACE);
			assert.ok(iItemsLength < sut.getItems().length, "Growing triggered via onsapspace event");
			assert.ok(fnCheckGrowingFromScratch.called, "checkGrowingFromScratch called in order to recalculate merging cells");

			sut.destroy();
		});

		QUnit.test("Test onsapspace on SelectAll checkbox", function(assert) {
			var sut = createSUT("idResponsiveTable", true, false, "MultiSelect");
			sut.placeAt("qunit-fixture");
			sap.ui.getCore().applyChanges();

			var $tblHeader = sut.$('tblHeader').first().trigger("focusin");

			assert.ok(!sut._selectAllCheckBox.getSelected(), "SelectAll checkbox is not selected");
			qutils.triggerKeydown($tblHeader, jQuery.sap.KeyCodes.SPACE);
			assert.ok(sut._selectAllCheckBox.getSelected(), "SelectAll checkbox is selected, relevant event for updating the checkboxes was triggered");
			sut.getItems().map(function(oItem) {
				assert.ok(oItem.getSelected());
			});

			sut.destroy();
		});
		</script>
	</head>
	<body id="body" class="sapUiBody">
		<h1 id="qunit-header">QUnit tests: sap.m.Table</h1>
		<h2 id="qunit-banner"></h2>
		<h2 id="qunit-userAgent"></h2>
		<div id="qunit-testrunner-toolbar"></div>
		<ol id="qunit-tests"></ol>
		<div id="qunit-fixture"></div>
	</body>
</html>
{'fraction_non_alphanumeric': 0.17280422416374078, 'fraction_numerical': 0.006886040118668517, 'mean_word_length': 4.1814976731067555, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5618650', 'n_tokens_mistral': 13523, 'n_tokens_neox': 11688, 'n_words': 2560}