function exposeTestFunctionNames() { return [ 'testDatasetIsDefined', 'testItemLoaded', 'testItemLoadedInEventSource', 'testEarliestDate', 'testLatestDate', 'testItemAttributes', 'testItemEvent', 'testMarkerPlacemark', 'testNativeMarkerPlacemark', 'testPolylinePlacemark', 'testNativePolylinePlacemark' ]; } function testDatasetIsDefined() { assertNotUndefined("dataset is defined", tm.datasets["test"]); } function testItemLoaded() { var ds = tm.datasets["test"]; assertEquals("two items in item array", 2, ds.getItems().length); } function testItemLoadedInEventSource() { var ds = tm.datasets["test"]; assertEquals("two items in eventSource", 2, ds.eventSource.getCount()); } function testEarliestDate() { var ds = tm.datasets["test"]; assertDateMatches1980("Earliest date not correct", ds.eventSource.getEarliestDate()); } function testLatestDate() { var ds = tm.datasets["test"]; assertDateMatches2000("Latest date not correct", ds.eventSource.getLatestDate()); } function testItemAttributes() { var items = tm.datasets["test"].getItems(); // point var item = items[0]; assertEquals("title matches", item.getTitle(), "Test Event"); assertEquals("description matches", item.opts.description, "Test Description"); // polyline item = items[1]; assertEquals("title matches", item.getTitle(), "Test Event 2"); } function testItemEvent() { var items = tm.datasets["test"].getItems(); // point var item = items[0], title = item.getTitle(); assertNotNull(title + ": event not null", item.event); assertNotUndefined(title + ": event undefined", item.event); assertEquals(title + ": event title matches", item.event.getText(), "Test Event"); assertDateMatches1980(title + ": item event start wrong", item.getStart()); assertDateMatches2000(title + ": item event end wrong", item.getEnd()); // polyline item = items[1]; title = item.getTitle(); assertNotNull(title + ": event not null", item.event); assertNotUndefined(title + ": event undefined", item.event); assertEquals(title + ": event title matches", item.event.getText(), "Test Event 2"); assertDateMatches1980(title + ": item event start wrong", item.getStart()); } function testMarkerPlacemark() { var items = tm.datasets["test"].getItems(), item = items[0]; assertNotNull("placemark not null", item.placemark); assertNotUndefined("placemark undefined", item.placemark); assertEquals("item type matches", "marker", item.getType()); assertEquals("placemark type matches", "marker", TimeMap.util.getPlacemarkType(item.placemark)); assertEquals("marker title wrong", "Test Event", item.placemark.labelText); var point = new mxn.LatLonPoint(23.456, 12.345); assertTrue("marker point matches", item.placemark.location.equals(point)); assertTrue("info point matches", item.getInfoPoint().equals(point)); } function testNativeMarkerPlacemark() { var items = tm.datasets["test"].getItems(), item = items[0], nativePlacemark = item.getNativePlacemark(); assertNotNull("native placemark null", nativePlacemark); assertNotUndefined("native placemark undefined", nativePlacemark); switch (tm.map.api) { case "google": assertTrue("native marker not GMarker", nativePlacemark.constructor == GMarker); assertEquals("native marker title wrong", "Test Event", nativePlacemark.getTitle()); var point = new GLatLng(23.456, 12.345); assertTrue("marker point matches", nativePlacemark.getLatLng().equals(point)); break; case "googlev3": // ducktype assertTrue("native marker wrong", 'getMap' in nativePlacemark && 'setMap' in nativePlacemark && 'getIcon' in nativePlacemark); assertEquals("native marker title wrong", "Test Event", nativePlacemark.getTitle()); var point = new google.maps.LatLng(23.456, 12.345); assertTrue("marker point matches", nativePlacemark.getPosition().equals(point)); break; case "openlayers": assertTrue("native marker wrong", nativePlacemark.CLASS_NAME == "OpenLayers.Marker"); // OpenLayers markers have no titles // XXX: not thrilled with this test - I think Mapstraction is screwy here var point = new mxn.LatLonPoint(23.456, 12.345).toProprietary("openlayers"); assertTrue("marker point matches", nativePlacemark.lonlat.equals(point)); break; case "microsoft": assertTrue("native marker wrong", nativePlacemark.constructor == VEShape && nativePlacemark.GetShapeType() == "Point"); assertEquals("native marker title wrong", "Test Event", nativePlacemark.GetTitle()); assertEquals("native marker latitude wrong", 23.456, nativePlacemark.Latitude); assertEquals("native marker longitude wrong", 12.345, nativePlacemark.Longitude); break; default: fail("Map API not defined, or tests not defined for this API"); } } function testPolylinePlacemark() { var items = tm.datasets["test"].getItems(), item = items[1]; assertNotNull("placemark not null", item.placemark); assertNotUndefined("placemark undefined", item.placemark); assertEquals("item type matches", "polyline", item.getType()); assertEquals("placemark type matches", "polyline", TimeMap.util.getPlacemarkType(item.placemark)); var points = [ new mxn.LatLonPoint(45.256, -110.45), new mxn.LatLonPoint(46.46, -109.48), new mxn.LatLonPoint(43.84, -109.86) ]; assertNotUndefined("polyline points undefined", item.placemark.points); assertEquals("vertex count wrong", 3, item.placemark.points.length); assertTrue("info point doesn't match middle point", item.getInfoPoint().equals(points[1])); for (var x=0; x