michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var passed = 0; michael@0: var ran = 0; michael@0: if(tests.length < 1){ michael@0: dump("FAILED! tests.length was " + tests.length + "\n"); michael@0: } michael@0: michael@0: function logResult(didPass, testcase, extra) { michael@0: var start = didPass ? "PASS | " : "FAIL | "; michael@0: print(start + testcase.path + " | Test was: \"" + michael@0: testcase.desc + "\" | " + testcase.expect + " |"); michael@0: if (extra) { michael@0: print(extra); michael@0: } michael@0: } michael@0: michael@0: michael@0: function isIID(a,iid){ michael@0: var rv = false; michael@0: try{ michael@0: a.QueryInterface(iid); michael@0: rv = true; michael@0: }catch(e){} michael@0: return rv; michael@0: } michael@0: function TestListener(){} michael@0: michael@0: TestListener.prototype = { michael@0: handleResult: function(result){ michael@0: var feed = result.doc; michael@0: // QI to something michael@0: (isIID(feed, Components.interfaces.nsIFeed)); michael@0: try { michael@0: if(!eval(testcase.expect)){ michael@0: logResult(false, testcase); michael@0: michael@0: }else{ michael@0: logResult(true, testcase); michael@0: passed += 1; michael@0: } michael@0: } michael@0: catch(e) { michael@0: logResult(false, testcase, "ex: " + e.message); michael@0: } michael@0: michael@0: ran += 1; michael@0: result = null; michael@0: } michael@0: } michael@0: michael@0: var startDate = new Date(); michael@0: michael@0: for(var i=0; i