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

		<script id="sap-ui-bootstrap"
			type="text/javascript"
			src="../../../../resources/sap-ui-core.js"
			data-sap-ui-theme="sap_bluecrystal"
			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 type="text/javascript" src="../../../../resources/sap/ui/thirdparty/qunit.js"></script>
		<script type="text/javascript" src="../../../../resources/sap/ui/qunit/qunit-junit.js"></script>

		<script type="text/javascript" src="../../../../resources/sap/ui/qunit/QUnitUtils.js"></script>
		<script src="../../../../resources/sap/ui/thirdparty/sinon.js"></script>
		<script src="../../../../resources/sap/ui/thirdparty/sinon-qunit.js"></script>
		<style type="text/css">
			html {
				overflow: hidden;
			}
		</style>

		<script language="javascript">
			sinon.config.useFakeTimers = false;

			sap.ui.test.qunit.delayTestStart();

			var oActionSheet = new sap.m.ActionSheet("actionsheet", {
				showCancelButton: true,
				buttons: [
					new sap.m.Button({
						type: sap.m.ButtonType.Reject,
						text: "Reject Action"
					}),
					new sap.m.Button({
						type: sap.m.ButtonType.Accept,
						text: "Accept Action"
					}),
					new sap.m.Button({
						type: sap.m.ButtonType.Default,
						text: "Default Action"
					})
				],
				cancelButtonText: "Cancel",
				title: "Please choose one action",
				placement: sap.m.PlacementType.Bottom,
				cancelButtonPress: function(){
					jQuery.sap.log.info("sap.m.ActionSheet: cancelButton is pressed");
				},
				beforeOpen: function(){
					ok(jQuery.sap.byId("actionsheet").css("visibility") !== "visible", "ActionSheet should be hidden before it's opened");
				},
				afterOpen: function(){
					equal(jQuery.sap.byId("actionsheet").css("visibility"), "visible", "ActionSheet should be visible after it's opened");
					start();
				},
				beforeClose: function(){
					equal(jQuery.sap.byId("actionsheet").css("visibility"), "visible", "ActionSheet should be visible before it's closed");
				},
				afterClose: function(){
					ok(jQuery.sap.byId("actionsheet").css("visibility") !== "visible", "ActionSheet should be hidden after it's closed");
					ok(!oActionSheet.isOpen(), "ActionSheet is already closed");
					start();
				}
			});

			var oButton = new sap.m.Button({
				text : "Open ActionSheet",
				press : function() {
					oActionSheet.openBy(this);
				}
			});

			var page = new sap.m.Page("myFirstPage", {
				title : "ActionSheet Test",
				showNavButton : true,
				enableScrolling : true,
				content: oButton
			});

			var app = new sap.m.App("myApp", {
				initPage: "myFirstPage"
			});

			app.addPage(page).placeAt("content");

			module("Initial Check");

			test("Initialization", function() {
				ok(!jQuery.sap.domById("actionsheet"), "ActionSheet is not rendered before it's ever opened.");
			});

			module("Open and Close - with Title and Cancel Button");

			asyncTest("Open ActionSheet - - with Title and Cancel Button", function(){
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("header.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					if(!sap.ui.Device.system.phone){
						ok(!($header[0]), "Title is always ignored when doesn't run on phone");
					}else{
						ok($header[0], "Title is rendered");
					}
					if(!sap.ui.Device.system.phone){
						ok(!($cancelButton[0]), "Cancel button is never rendered when doesn't run on phone");
					}else{
						ok($cancelButton[0], "Cancel button is rendered");
					}

				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);
				oActionSheet.close();
			});

			module("Open and Close - with Title but no Cancel Button");

			asyncTest("Open ActionSheet - - with Title  but no Cancel Button", function(){
				oActionSheet.setShowCancelButton(false);
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("header.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					if(!sap.ui.Device.system.phone){
						ok(!($header[0]), "Title is always ignored in iPad");
					}else{
						ok($header[0], "Title is rendered");
					}
					ok(!($cancelButton[0]), "showCancelButton is set to false, there is no cancel button");
				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);

				oActionSheet.close();
			});

			module("Open and Close - no Title but with Cancel Button");

			asyncTest("Open ActionSheet - - no Title but with Cancel Button", function(){
				oActionSheet.setShowCancelButton(true);
				oActionSheet.setTitle(null);
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("div.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					ok(!($header[0]), "There is no title because title property is set to null");

					if(!sap.ui.Device.system.phone){
						ok(!($cancelButton[0]), "Cancel button is never rendered in iPad");
					}else{
						ok($cancelButton[0], "Cancel button is rendered");
					}
				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);
				oActionSheet.close();
			});

			module("Open and Close - no Title and no Cancel Button");

			asyncTest("Open ActionSheet - - no Title and no Cancel Button", function(){
				oActionSheet.setShowCancelButton(false);
				oActionSheet.setTitle(null);
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("div.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					ok(!($header[0]), "There is no title because title property is set to null");
					ok(!($cancelButton[0]), "showCancelButton is set to false, there is no cancel button");
				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);
				oActionSheet.close();
			});

			module("Additional Test");

			asyncTest("Open an ActionSheet which is already aggregated in dependents aggregation", function(){
				var oAC = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						new sap.m.Button({
							text: "Button1"
						}),
						new sap.m.Button({
							text: "Button2"
						})
					]
				});

				page.addDependent(oAC);

				var oSpyOfViewInvalidate = sinon.spy(page, "invalidate");

				oAC.attachAfterOpen(function(){
					equal(oSpyOfViewInvalidate.callCount, 0, "Former parent shouldn't be invalidated");

					oAC.destroy();
					start();
				});

				oAC.openBy(oButton);

				equal(oAC._parent.getParent(), page, "Popup of ActionSheet should be aggregated by the former parent of ActionSheet");

			});

			asyncTest("If first button is invinsible, focus goes to the second one", function () {
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var button1 = new sap.m.Button({ text: "Button1", id: "asButton1", visible: false });
				var button2 = new sap.m.Button({ text: "Button2", id: "asButton2" });
				var oActionSheet = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						button1,
						button2
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					ok(jQuery.sap.byId('asButton2').is(":focus"), 'The 2nd button should be focused');

					start();
					oActionSheet.close();
					oButton.destroy();
					oActionSheet.destroy();
				}, 500)
			});

			module("keyboard handling")

			asyncTest('PageDown keyboard handling mobile phone', function(){
				if (sap.ui.Device.browser.msie && sap.ui.Device.browser.version < 10) {
						// this test is not supported by IE9
						expect(0);
						start();
						return;
				}

				var oSystem = {
						desktop: false,
						phone: true,
						tablet: false
				};

				this.stub(sap.ui.Device, "system", oSystem);
				expect(2);
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var oActionSheet = new sap.m.ActionSheet({
					showCancelButton: true,
					buttons: [
						new sap.m.Button({
							id: 'oButton1',
							type: sap.m.ButtonType.Reject,
							text: "Reject Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Accept,
							text: "Accept Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton6',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton7',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						})
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);

					ok(jQuery.sap.byId('oButton6').is(":focus"), 'The 6th button should be focused');

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					ok(oActionSheet.$('cancelBtn').is(":focus"), 'The cancel button should be focused');
					start();
					oActionSheet.close();

					oButton.destroy();
					oActionSheet.destroy();
				}, 500)
			});

			asyncTest('PageDown keyboard handling desktop', function(){
				var oSystem = {
						desktop: true,
						phone: false
				};

				this.stub(sap.ui.Device, "system", oSystem);
				expect(2);
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var oActionSheet = new sap.m.ActionSheet({
					showCancelButton: true,
					buttons: [
						new sap.m.Button({
							id: 'oButton1',
							type: sap.m.ButtonType.Reject,
							text: "Reject Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Accept,
							text: "Accept Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton6',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton7',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						})
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);

					ok(jQuery.sap.byId('oButton6').is(":focus"), 'The 6th button should be focused');

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);

					ok(jQuery.sap.byId('oButton7').is(":focus"), 'The 7th button should be focused');

					start();
					oActionSheet.close();

					oButton.destroy();
					oActionSheet.destroy();
				}, 500)
			});

			asyncTest('PageUp keyboard handling', function(){
				expect(2);
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var oActionSheet = new sap.m.ActionSheet({
					showCancelButton: true,
					buttons: [
						new sap.m.Button({
							id: 'oButton1',
							type: sap.m.ButtonType.Reject,
							text: "Reject Action"
						}),
						new sap.m.Button({
							id: 'oButton2',
							type: sap.m.ButtonType.Accept,
							text: "Accept Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton6',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton7',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						})
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					jQuery.sap.byId('oButton7').focus();

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton7')[0], jQuery.sap.KeyCodes.PAGE_UP);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton7')[0], jQuery.sap.KeyCodes.PAGE_UP);

					ok(jQuery.sap.byId('oButton2').is(":focus"), 'The 2nd button should be focused');

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton2')[0], jQuery.sap.KeyCodes.PAGE_UP);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton2')[0], jQuery.sap.KeyCodes.PAGE_UP);

					ok(jQuery.sap.byId('oButton1').is(":focus"), 'The first button should be focused');
					start();
					oActionSheet.close();

					oButton.destroy();
					oActionSheet.destroy();
				}, 500)

			});

			module("Screen reader");

			asyncTest('Button should have ariaLabelledBy that points to itself and hidden text', function() {
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var button1 = new sap.m.Button({ text: "Button1", id: "asButton1" });
				var button2 = new sap.m.Button({ text: "Button2", id: "asButton2" });
				var oActionSheet = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						button1,
						button2
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					var oButton1 = sap.ui.getCore().byId('asButton1'),
						sInvisibleText = oButton1.getAriaLabelledBy()[1],
						oInvisibleTextObj = sap.ui.getCore().byId(sInvisibleText);

					strictEqual(oButton1.getAriaLabelledBy().length, 2 , "Button should be labelled by itself and a hidden text");
					strictEqual(oInvisibleTextObj instanceof sap.ui.core.InvisibleText, true, "Second label should be invisibleText");
					strictEqual(oInvisibleTextObj.getText(), "1 of 2", "Text should be the index of the button");

					start();
					oActionSheet.close();
					oButton.destroy();
					oActionSheet.destroy();
				}, 500);
			});

			asyncTest('Invisible buttons should not be counted', function() {
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var button1 = new sap.m.Button({ text: "Button1", id: "asButton1" });
				var button2 = new sap.m.Button({ text: "Button2", id: "asButton2", visible: false });
				var oActionSheet = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						button1,
						button2
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					var oButton1 = sap.ui.getCore().byId('asButton1'),
						sInvisibleText = sap.ui.getCore().byId('asButton1').getAriaLabelledBy()[1],
						oInvisibleTextObj = sap.ui.getCore().byId(sInvisibleText);

					strictEqual(oInvisibleTextObj.getText(), "1 of 1", "Total amount of buttons should be 1");

					start();
					oActionSheet.close();
					oButton.destroy();
					oActionSheet.destroy();
				}, 500);

			});

			QUnit.done(function() {
				// hide the content so that the QUnit results can be seen
				jQuery("#content").css('height', '0');
			});
		</script>
	</head>
	<body id="body" class="sapUiBody">
		<div id="contentHolder"></div>
		<div id="uiArea"></div>
		<div id="content"></div>
		<h1 id="qunit-header">qUnit Page for sap.m.ActionSheet</h1>
		<h2 id="qunit-banner"></h2>
		<h2 id="qunit-userAgent"></h2>
		<ol id="qunit-tests"></ol>

	</body>
</html>
<commit_msg>[INTERNAL] sap.m.ActionSheet: Updated qUnits to support internationalization<commit_after><!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>qUnit Page for sap.m.ActionSheet</title>

		<script id="sap-ui-bootstrap"
			type="text/javascript"
			src="../../../../resources/sap-ui-core.js"
			data-sap-ui-theme="sap_bluecrystal"
			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 type="text/javascript" src="../../../../resources/sap/ui/thirdparty/qunit.js"></script>
		<script type="text/javascript" src="../../../../resources/sap/ui/qunit/qunit-junit.js"></script>

		<script type="text/javascript" src="../../../../resources/sap/ui/qunit/QUnitUtils.js"></script>
		<script src="../../../../resources/sap/ui/thirdparty/sinon.js"></script>
		<script src="../../../../resources/sap/ui/thirdparty/sinon-qunit.js"></script>
		<style type="text/css">
			html {
				overflow: hidden;
			}
		</style>

		<script language="javascript">
			sinon.config.useFakeTimers = false;

			sap.ui.test.qunit.delayTestStart();

			var oResourceBundle = sap.ui.getCore().getLibraryResourceBundle("sap.m");

			var oActionSheet = new sap.m.ActionSheet("actionsheet", {
				showCancelButton: true,
				buttons: [
					new sap.m.Button({
						type: sap.m.ButtonType.Reject,
						text: "Reject Action"
					}),
					new sap.m.Button({
						type: sap.m.ButtonType.Accept,
						text: "Accept Action"
					}),
					new sap.m.Button({
						type: sap.m.ButtonType.Default,
						text: "Default Action"
					})
				],
				cancelButtonText: "Cancel",
				title: "Please choose one action",
				placement: sap.m.PlacementType.Bottom,
				cancelButtonPress: function(){
					jQuery.sap.log.info("sap.m.ActionSheet: cancelButton is pressed");
				},
				beforeOpen: function(){
					ok(jQuery.sap.byId("actionsheet").css("visibility") !== "visible", "ActionSheet should be hidden before it's opened");
				},
				afterOpen: function(){
					equal(jQuery.sap.byId("actionsheet").css("visibility"), "visible", "ActionSheet should be visible after it's opened");
					start();
				},
				beforeClose: function(){
					equal(jQuery.sap.byId("actionsheet").css("visibility"), "visible", "ActionSheet should be visible before it's closed");
				},
				afterClose: function(){
					ok(jQuery.sap.byId("actionsheet").css("visibility") !== "visible", "ActionSheet should be hidden after it's closed");
					ok(!oActionSheet.isOpen(), "ActionSheet is already closed");
					start();
				}
			});

			var oButton = new sap.m.Button({
				text : "Open ActionSheet",
				press : function() {
					oActionSheet.openBy(this);
				}
			});

			var page = new sap.m.Page("myFirstPage", {
				title : "ActionSheet Test",
				showNavButton : true,
				enableScrolling : true,
				content: oButton
			});

			var app = new sap.m.App("myApp", {
				initPage: "myFirstPage"
			});

			app.addPage(page).placeAt("content");

			module("Initial Check");

			test("Initialization", function() {
				ok(!jQuery.sap.domById("actionsheet"), "ActionSheet is not rendered before it's ever opened.");
			});

			module("Open and Close - with Title and Cancel Button");

			asyncTest("Open ActionSheet - - with Title and Cancel Button", function(){
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("header.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					if(!sap.ui.Device.system.phone){
						ok(!($header[0]), "Title is always ignored when doesn't run on phone");
					}else{
						ok($header[0], "Title is rendered");
					}
					if(!sap.ui.Device.system.phone){
						ok(!($cancelButton[0]), "Cancel button is never rendered when doesn't run on phone");
					}else{
						ok($cancelButton[0], "Cancel button is rendered");
					}

				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);
				oActionSheet.close();
			});

			module("Open and Close - with Title but no Cancel Button");

			asyncTest("Open ActionSheet - - with Title  but no Cancel Button", function(){
				oActionSheet.setShowCancelButton(false);
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("header.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					if(!sap.ui.Device.system.phone){
						ok(!($header[0]), "Title is always ignored in iPad");
					}else{
						ok($header[0], "Title is rendered");
					}
					ok(!($cancelButton[0]), "showCancelButton is set to false, there is no cancel button");
				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);

				oActionSheet.close();
			});

			module("Open and Close - no Title but with Cancel Button");

			asyncTest("Open ActionSheet - - no Title but with Cancel Button", function(){
				oActionSheet.setShowCancelButton(true);
				oActionSheet.setTitle(null);
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("div.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					ok(!($header[0]), "There is no title because title property is set to null");

					if(!sap.ui.Device.system.phone){
						ok(!($cancelButton[0]), "Cancel button is never rendered in iPad");
					}else{
						ok($cancelButton[0], "Cancel button is rendered");
					}
				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);
				oActionSheet.close();
			});

			module("Open and Close - no Title and no Cancel Button");

			asyncTest("Open ActionSheet - - no Title and no Cancel Button", function(){
				oActionSheet.setShowCancelButton(false);
				oActionSheet.setTitle(null);
				oButton.firePress();
				ok(oActionSheet.isOpen(), "ActionSheet is already open");
				setTimeout(function(){
					var $actionSheet = jQuery.sap.byId("actionsheet"),
						$parentControl = !sap.ui.Device.system.phone ? $actionSheet.closest(".sapMActionSheetPopover") : $actionSheet.closest(".sapMActionSheetDialog"),
						$header = $parentControl.children("div.sapMBar"),
						$cancelButton = $actionSheet.children("button.sapMActionSheetCancelButton");
					expect(8);
					ok(jQuery.sap.domById("actionsheet"), "ActionSheet is rendered after it's opened.");
					ok($actionSheet.closest("#sap-ui-static")[0], "ActionSheet should be rendered inside the static uiArea.");
					ok($parentControl[0], "ActionSheet is wrapped either in Popover or Dialog");

					ok(!($header[0]), "There is no title because title property is set to null");
					ok(!($cancelButton[0]), "showCancelButton is set to false, there is no cancel button");
				}, 50);
			});

			asyncTest("Close ActionSheet", function(){
				expect(3);
				oActionSheet.close();
			});

			module("Additional Test");

			asyncTest("Open an ActionSheet which is already aggregated in dependents aggregation", function(){
				var oAC = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						new sap.m.Button({
							text: "Button1"
						}),
						new sap.m.Button({
							text: "Button2"
						})
					]
				});

				page.addDependent(oAC);

				var oSpyOfViewInvalidate = sinon.spy(page, "invalidate");

				oAC.attachAfterOpen(function(){
					equal(oSpyOfViewInvalidate.callCount, 0, "Former parent shouldn't be invalidated");

					oAC.destroy();
					start();
				});

				oAC.openBy(oButton);

				equal(oAC._parent.getParent(), page, "Popup of ActionSheet should be aggregated by the former parent of ActionSheet");

			});

			asyncTest("If first button is invinsible, focus goes to the second one", function () {
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var button1 = new sap.m.Button({ text: "Button1", id: "asButton1", visible: false });
				var button2 = new sap.m.Button({ text: "Button2", id: "asButton2" });
				var oActionSheet = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						button1,
						button2
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					ok(jQuery.sap.byId('asButton2').is(":focus"), 'The 2nd button should be focused');

					start();
					oActionSheet.close();
					oButton.destroy();
					oActionSheet.destroy();
				}, 500)
			});

			module("keyboard handling")

			asyncTest('PageDown keyboard handling mobile phone', function(){
				if (sap.ui.Device.browser.msie && sap.ui.Device.browser.version < 10) {
						// this test is not supported by IE9
						expect(0);
						start();
						return;
				}

				var oSystem = {
						desktop: false,
						phone: true,
						tablet: false
				};

				this.stub(sap.ui.Device, "system", oSystem);
				expect(2);
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var oActionSheet = new sap.m.ActionSheet({
					showCancelButton: true,
					buttons: [
						new sap.m.Button({
							id: 'oButton1',
							type: sap.m.ButtonType.Reject,
							text: "Reject Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Accept,
							text: "Accept Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton6',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton7',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						})
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);

					ok(jQuery.sap.byId('oButton6').is(":focus"), 'The 6th button should be focused');

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					ok(oActionSheet.$('cancelBtn').is(":focus"), 'The cancel button should be focused');
					start();
					oActionSheet.close();

					oButton.destroy();
					oActionSheet.destroy();
				}, 500)
			});

			asyncTest('PageDown keyboard handling desktop', function(){
				var oSystem = {
						desktop: true,
						phone: false
				};

				this.stub(sap.ui.Device, "system", oSystem);
				expect(2);
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var oActionSheet = new sap.m.ActionSheet({
					showCancelButton: true,
					buttons: [
						new sap.m.Button({
							id: 'oButton1',
							type: sap.m.ButtonType.Reject,
							text: "Reject Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Accept,
							text: "Accept Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton6',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton7',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						})
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton1')[0], jQuery.sap.KeyCodes.PAGE_DOWN);

					ok(jQuery.sap.byId('oButton6').is(":focus"), 'The 6th button should be focused');

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton6')[0], jQuery.sap.KeyCodes.PAGE_DOWN);

					ok(jQuery.sap.byId('oButton7').is(":focus"), 'The 7th button should be focused');

					start();
					oActionSheet.close();

					oButton.destroy();
					oActionSheet.destroy();
				}, 500)
			});

			asyncTest('PageUp keyboard handling', function(){
				expect(2);
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var oActionSheet = new sap.m.ActionSheet({
					showCancelButton: true,
					buttons: [
						new sap.m.Button({
							id: 'oButton1',
							type: sap.m.ButtonType.Reject,
							text: "Reject Action"
						}),
						new sap.m.Button({
							id: 'oButton2',
							type: sap.m.ButtonType.Accept,
							text: "Accept Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton6',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						}),
						new sap.m.Button({
							id: 'oButton7',
							type: sap.m.ButtonType.Default,
							text: "Default Action"
						})
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					jQuery.sap.byId('oButton7').focus();

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton7')[0], jQuery.sap.KeyCodes.PAGE_UP);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton7')[0], jQuery.sap.KeyCodes.PAGE_UP);

					ok(jQuery.sap.byId('oButton2').is(":focus"), 'The 2nd button should be focused');

					sap.ui.test.qunit.triggerKeydown(jQuery.sap.byId('oButton2')[0], jQuery.sap.KeyCodes.PAGE_UP);
					sap.ui.test.qunit.triggerKeyup(jQuery.sap.byId('oButton2')[0], jQuery.sap.KeyCodes.PAGE_UP);

					ok(jQuery.sap.byId('oButton1').is(":focus"), 'The first button should be focused');
					start();
					oActionSheet.close();

					oButton.destroy();
					oActionSheet.destroy();
				}, 500)

			});

			module("Screen reader");

			asyncTest('Button should have ariaLabelledBy that points to itself and hidden text', function() {
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var button1 = new sap.m.Button({ text: "Button1", id: "asButton1" });
				var button2 = new sap.m.Button({ text: "Button2", id: "asButton2" });
				var oActionSheet = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						button1,
						button2
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					var oButton1 = sap.ui.getCore().byId('asButton1'),
						sInvisibleText = oButton1.getAriaLabelledBy()[1],
						oInvisibleTextObj = sap.ui.getCore().byId(sInvisibleText);

					strictEqual(oButton1.getAriaLabelledBy().length, 2 , "Button should be labelled by itself and a hidden text");
					strictEqual(oInvisibleTextObj instanceof sap.ui.core.InvisibleText, true, "Second label should be invisibleText");
					strictEqual(oInvisibleTextObj.getText(), oResourceBundle.getText('ACTIONSHEET_BUTTON_INDEX', [1, 2]), "Text should be the index of the button");

					start();
					oActionSheet.close();
					oButton.destroy();
					oActionSheet.destroy();
				}, 500);
			});

			asyncTest('Invisible buttons should not be counted', function() {
				var oButton = new sap.m.Button({
					text : "Open ActionSheet",
					press : function() {
						oActionSheet.openBy(this);
					}
				});

				var button1 = new sap.m.Button({ text: "Button1", id: "asButton1" });
				var button2 = new sap.m.Button({ text: "Button2", id: "asButton2", visible: false });
				var oActionSheet = new sap.m.ActionSheet({
					cancelButtonText: "Cancel",
					title: "Title",
					buttons: [
						button1,
						button2
					]
				});

				page.addContent(oButton);
				sap.ui.getCore().applyChanges();
				oButton.firePress();

				setTimeout(function(){
					var oButton1 = sap.ui.getCore().byId('asButton1'),
						sInvisibleText = sap.ui.getCore().byId('asButton1').getAriaLabelledBy()[1],
						oInvisibleTextObj = sap.ui.getCore().byId(sInvisibleText);

					strictEqual(oInvisibleTextObj.getText(), oResourceBundle.getText('ACTIONSHEET_BUTTON_INDEX', [1, 1]), "Total amount of buttons should be 1");

					start();
					oActionSheet.close();
					oButton.destroy();
					oActionSheet.destroy();
				}, 500);

			});

			QUnit.done(function() {
				// hide the content so that the QUnit results can be seen
				jQuery("#content").css('height', '0');
			});
		</script>
	</head>
	<body id="body" class="sapUiBody">
		<div id="contentHolder"></div>
		<div id="uiArea"></div>
		<div id="content"></div>
		<h1 id="qunit-header">qUnit Page for sap.m.ActionSheet</h1>
		<h2 id="qunit-banner"></h2>
		<h2 id="qunit-userAgent"></h2>
		<ol id="qunit-tests"></ol>

	</body>
</html>

{'fraction_non_alphanumeric': 0.16150584607477836, 'fraction_numerical': 0.008017473981755107, 'mean_word_length': 3.0507962943686895, 'pattern_counts': {'":': 14, '<': 87, '<?xml version=': 0, '>': 85, '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': '6607525', 'n_tokens_mistral': 16398, 'n_tokens_neox': 12415, 'n_words': 2553}