<commit_before>Tests.prototype.GeoLocationTests = function() {	
	module('Geolocation (navigator.geolocation)');
	test("should exist", function() {
  		expect(1);
  		ok(navigator.geolocation != null, "navigator.geolocation should not be null.");
	});
	test("should contain a getCurrentPosition function", function() {
		expect(2);
		ok(typeof navigator.geolocation.getCurrentPosition != 'undefined' && navigator.geolocation.getCurrentPosition != null, "navigator.geolocation.getCurrentPosition should not be null.");
		ok(typeof navigator.geolocation.getCurrentPosition == 'function', "navigator.geolocation.getCurrentPosition should be a function.");
	});
	test("should contain a watchPosition function", function() {
		expect(2);
		ok(typeof navigator.geolocation.watchPosition != 'undefined' && navigator.geolocation.watchPosition != null, "navigator.geolocation.watchPosition should not be null.");
		ok(typeof navigator.geolocation.watchPosition == 'function', "navigator.geolocation.watchPosition should be a function.");
	});
	test("should contain a clearWatch function", function() {
		expect(2);
		ok(typeof navigator.geolocation.clearWatch != 'undefined' && navigator.geolocation.clearWatch != null, "navigator.geolocation.watchPosition should not be null.");
		ok(typeof navigator.geolocation.clearWatch == 'function', "navigator.geolocation.clearWatch should be a function.");
	});
	test("getCurrentPosition success callback should be called with a Position object", function() {
		expect(2);
		QUnit.stop(Tests.TEST_TIMEOUT);
		var win = function(p) {
			ok(p.coords != null, "Position object returned in getCurrentPosition success callback has a 'coords' property.");
			ok(p.timestamp != null, "Position object returned in getCurrentPosition success callback has a 'timestamp' property.");
			start();
		};
		var fail = function() { start(); };
		navigator.geolocation.getCurrentPosition(win, fail);
	});
	// TODO: Need to test error callback... how?
	// TODO: Need to test watchPosition success callback, test that makes sure clearPosition works (how to test that a timer is getting cleared?)
	// TODO: Need to test options object passed in. Members that need to be tested so far include:
	//				- options.frequency: this is also labelled differently on some implementations (internval on iPhone/BlackBerry currently). 
	module('Geolocation model');
	test("should be able to define a Position object with coords and timestamp properties", function() {
		expect(3);
		var pos = new Position({}, new Date());
		ok(pos != null, "new Position() should not be null.");
		ok(typeof pos.coords != 'undefined' && pos.coords != null, "new Position() should include a 'coords' property.");<commit_msg>added more geolocation tests for timeout + maximumage parameters<commit_after>Tests.prototype.GeoLocationTests = function() {	
	module('Geolocation (navigator.geolocation)');
	test("should exist", function() {
  		expect(1);
  		ok(navigator.geolocation != null, "navigator.geolocation should not be null.");
	});
	test("should contain a getCurrentPosition function", function() {
		expect(2);
		ok(typeof navigator.geolocation.getCurrentPosition != 'undefined' && navigator.geolocation.getCurrentPosition != null, "navigator.geolocation.getCurrentPosition should not be null.");
		ok(typeof navigator.geolocation.getCurrentPosition == 'function', "navigator.geolocation.getCurrentPosition should be a function.");
	});
	test("should contain a watchPosition function", function() {
		expect(2);
		ok(typeof navigator.geolocation.watchPosition != 'undefined' && navigator.geolocation.watchPosition != null, "navigator.geolocation.watchPosition should not be null.");
		ok(typeof navigator.geolocation.watchPosition == 'function', "navigator.geolocation.watchPosition should be a function.");
	});
	test("should contain a clearWatch function", function() {
		expect(2);
		ok(typeof navigator.geolocation.clearWatch != 'undefined' && navigator.geolocation.clearWatch != null, "navigator.geolocation.watchPosition should not be null.");
		ok(typeof navigator.geolocation.clearWatch == 'function', "navigator.geolocation.clearWatch should be a function.");
	});
	test("getCurrentPosition success callback should be called with a Position object", function() {
		expect(2);
		QUnit.stop(15000);
		var win = function(p) {
			ok(p.coords != null, "Position object returned in getCurrentPosition success callback has a 'coords' property.");
			ok(p.timestamp != null, "Position object returned in getCurrentPosition success callback has a 'timestamp' property.");
			QUnit.start();
		};
		var fail = function() { 
        ok(false, "Error callback fired, test failed.");
        QUnit.start();
    };
		navigator.geolocation.getCurrentPosition(win, fail, {
        maximumAge:300000 // 5 minutes maximum age of cached position
    });
	});
  test("getCurrentPosition success callback should be called with a cached Position", function() {
    expect(1);
    QUnit.stop(Tests.TEST_TIMEOUT);
    var win = function(p) {
      ok(p.coords instanceof Position, "Position object returned is an instance of Position");
      QUnit.start();
    };
    var fail = function(e) {
      ok(false, "Error callback called, test failed.");
    };
    navigator.geolocation.getCurrentPosition(win, fail, {
        maximumAge:300000 // 5 minutes
    });
  });
  test("getCurrentPosition error callback should be called if we set timeout to 0 and maximumAge to a very small number", function() {
    expect(1);
    QUnit.stop(Tests.TEST_TIMEOUT);
    var win = function(p) {
      ok(false, "success callback called, test failed.");
      QUnit.start();
    };
    var fail = function(e) {
      ok(true, "error callback called");
      QUnit.start();
    };
    navigator.geolocation.getCurrentPosition(win, fail, {
        maximumAge: 0,
        timeout: 0
    });
  });
	// TODO: Need to test error callback... how?
	// TODO: Need to test watchPosition success callback, test that makes sure clearPosition works (how to test that a timer is getting cleared?)
	module('Geolocation model');
	test("should be able to define a Position object with coords and timestamp properties", function() {
		expect(3);
		var pos = new Position({}, new Date());
		ok(pos != null, "new Position() should not be null.");
		ok(typeof pos.coords != 'undefined' && pos.coords != null, "new Position() should include a 'coords' property.");
{'fraction_non_alphanumeric': 0.1254295532646048, 'fraction_numerical': 0.005623242736644799, 'mean_word_length': 4.616666666666666, 'pattern_counts': {'":': 0, '<': 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': '651787', 'n_tokens_mistral': 1821, 'n_tokens_neox': 1764, 'n_words': 560}