1 /**
  2  * @fileoverview Utilities for XPath JSUnit tests.
  3  */
  4 
  5 goog.provide('xrx.xpath.test');
  6 
  7 goog.require('goog.testing.jsunit');
  8 goog.require('xrx.node');
  9 goog.require('xrx.node.Document');
 10 goog.require('xrx.pilot');
 11 goog.require('xrx.xpath');
 12 
 13 
 14 
 15 xrx.xpath.test = {};
 16 
 17 
 18 
 19 xrx.xpath.test.query = function(expression) {
 20   var pilot = new xrx.pilot('<dummy/>');
 21   var node = new xrx.node.Document(pilot);
 22 
 23   return xrx.xpath.evaluate(expression, node, null, xrx.xpath.XPathResultType.ANY_TYPE);
 24 };
 25 
 26 
 27 
 28 xrx.xpath.test.xpathAssertEquals = function(expected, expression) {
 29   var result = xrx.xpath.test.query(expression);
 30 
 31   switch (result.resultType) {
 32   case xrx.xpath.XPathResultType.NUMBER_TYPE:
 33     assertEquals(expected, result.numberValue);
 34     break;
 35   case xrx.xpath.XPathResultType.STRING_TYPE:
 36     assertEquals(expected, result.stringValue);
 37     break;
 38   case xrx.xpath.XPathResultType.BOOLEAN_TYPE:
 39     assertEquals(expected, result.booleanValue);
 40     break;
 41   default:
 42     assertEquals('Missing XPath Result Type', '');
 43     break;
 44   }
 45 };
 46