<commit_before>define(["intern!object",
	"intern/chai!assert",
	"require"
	], function (registerSuite, assert, require) {

	var loadFile = function (remote, fileName) {
		return remote
			.get(require.toUrl(fileName))
			.waitForCondition("ready", 5000);
	};

	var checkScrollAmount = function (remote, scrollContainerId, expectedScroll) {
		remote.execute("return document.getElementById('" + 
			scrollContainerId + "').getCurrentScroll();")
			.then(function (scroll) {
				assert.equal(scroll.x, expectedScroll.x, "unexpected scrollLeft!");
				assert.equal(scroll.y, expectedScroll.y, "unexpected scrollTop!");
		});
	};

	var checkScrollTopLeft = function (remote, wd, scrollContainerId, scrollTo, expectedScroll) {
		// Executes scrolling by modifying the scrollTop/scrollLeft properties of
		// widget's scrollableNode. 
		return wd
			.then(function () {
				var scrollableNodeStr = "document.getElementById('" +
					scrollContainerId + "').scrollableNode";
				remote.execute(scrollableNodeStr + ".scrollLeft = '" + scrollTo.x + "'; " +
					scrollableNodeStr + ".scrollTop = '" + scrollTo.y + "';")
					.then(function () {
						checkScrollAmount(remote, scrollContainerId, expectedScroll);
					});
			});
	};

	var checkScrollBy = function (remote, wd, scrollContainerId, scrollBy, expectedScroll) {
		// Executes scrolling by calling the scrollBy() method of the widget.
		return wd
			.then(function () {
				remote.execute("document.getElementById('" + 
					scrollContainerId + "').scrollBy({" +
					"x: " + scrollBy.x + ", y: " + scrollBy.y + "});")
					.then(function () {
						checkScrollAmount(remote, scrollContainerId, expectedScroll);
					});
			});
	};
	
	var checkScroll = function (remote, fileName, scrollContainerId,
								scrollAmount, expectedScroll, checkScrollFunction) {
		var wd = loadFile(remote, fileName);
		return checkScrollFunction(remote, wd, scrollContainerId, scrollAmount, expectedScroll);
	};

	registerSuite({
		name: "ScrollableContainer",

		"scroll with animation (via button, inside LinearLayout, scrollDirection=vertical)": function () {
			var remote = this.remote;
			return loadFile(remote, "./ScrollableContainer.html")
			.then(function () {
				remote.elementById("scrollButton")
				.clickElement()
				.end()
				// Check that the scroll arrives at 100:
				.waitForCondition("document.getElementById('scrollContainer').scrollableNode.scrollTop=='100'", 5000)
				// Check that it stays at 100 even after waiting a while (that is,
				// that it does not continue to scroll):
				.wait(200)
				.then(function () {
					remote.execute("return document.getElementById('scrollContainer').scrollableNode.scrollTop;")
					.then(function (value) {
						assert.equal(value, "100", "scrollTop should have stayed at 100!");
					});
				});
			});
		},

		"scrollBy (without LinearLayout, scrollDirection=vertical)": function () {
			checkScroll(this.remote, "./ScrollableContainer-alone.html", "scrollContainer",
				{x: 100, y: 100}, // scroll amount
				// Since this container has scrollDirection="vertical", the horizontal part of
				// scrollBy should have no effect on the amount of scroll.
				{x: 0, y: 100}, // expected scroll
				checkScrollBy); // checking function<commit_msg>ScrollableContainer functional test: strongly increase timeouts to help running on sauce<commit_after>define(["intern!object",
	"intern/chai!assert",
	"require"
	], function (registerSuite, assert, require) {

	var loadFile = function (remote, fileName) {
		return remote
			.get(require.toUrl(fileName))
			.waitForCondition("ready", 15000); // large timeout because of sauce...
	};

	var checkScrollAmount = function (remote, scrollContainerId, expectedScroll) {
		remote.execute("return document.getElementById('" + 
			scrollContainerId + "').getCurrentScroll();")
			.then(function (scroll) {
				assert.equal(scroll.x, expectedScroll.x, "unexpected scrollLeft!");
				assert.equal(scroll.y, expectedScroll.y, "unexpected scrollTop!");
		});
	};

	var checkScrollTopLeft = function (remote, wd, scrollContainerId, scrollTo, expectedScroll) {
		// Executes scrolling by modifying the scrollTop/scrollLeft properties of
		// widget's scrollableNode. 
		return wd
			.then(function () {
				var scrollableNodeStr = "document.getElementById('" +
					scrollContainerId + "').scrollableNode";
				remote.execute(scrollableNodeStr + ".scrollLeft = '" + scrollTo.x + "'; " +
					scrollableNodeStr + ".scrollTop = '" + scrollTo.y + "';")
					.then(function () {
						checkScrollAmount(remote, scrollContainerId, expectedScroll);
					});
			});
	};

	var checkScrollBy = function (remote, wd, scrollContainerId, scrollBy, expectedScroll) {
		// Executes scrolling by calling the scrollBy() method of the widget.
		return wd
			.then(function () {
				remote.execute("document.getElementById('" + 
					scrollContainerId + "').scrollBy({" +
					"x: " + scrollBy.x + ", y: " + scrollBy.y + "});")
					.then(function () {
						checkScrollAmount(remote, scrollContainerId, expectedScroll);
					});
			});
	};
	
	var checkScroll = function (remote, fileName, scrollContainerId,
								scrollAmount, expectedScroll, checkScrollFunction) {
		var wd = loadFile(remote, fileName);
		return checkScrollFunction(remote, wd, scrollContainerId, scrollAmount, expectedScroll);
	};

	registerSuite({
		name: "ScrollableContainer - functional",

		"scroll with animation (via button, inside LinearLayout, scrollDirection=vertical)": function () {
			var remote = this.remote;
			return loadFile(remote, "./ScrollableContainer.html")
			.then(function () {
				remote.elementById("scrollButton")
				.clickElement()
				.end()
				// Check that the scroll arrives at 100:
				.waitForCondition("document.getElementById('scrollContainer').scrollableNode.scrollTop=='100'", 15000) // large timeout because of sauce...
				// Check that it stays at 100 even after waiting a while (that is,
				// that it does not continue to scroll):
				.wait(200)
				.then(function () {
					remote.execute("return document.getElementById('scrollContainer').scrollableNode.scrollTop;")
					.then(function (value) {
						assert.equal(value, "100", "scrollTop should have stayed at 100!");
					});
				});
			});
		},

		"scrollBy (without LinearLayout, scrollDirection=vertical)": function () {
			checkScroll(this.remote, "./ScrollableContainer-alone.html", "scrollContainer",
				{x: 100, y: 100}, // scroll amount
				// Since this container has scrollDirection="vertical", the horizontal part of
				// scrollBy should have no effect on the amount of scroll.
				{x: 0, y: 100}, // expected scroll
				checkScrollBy); // checking function
{'fraction_non_alphanumeric': 0.13617276544691062, 'fraction_numerical': 0.011097780443911218, 'mean_word_length': 3.976865671641791, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '3002955', 'n_tokens_mistral': 2279, 'n_tokens_neox': 1858, 'n_words': 482}