From 3da9ed939914d4c7d593848eaacbff425c372b19 Mon Sep 17 00:00:00 2001 From: Sergey Gaychuk Date: Thu, 22 Oct 2009 17:59:39 +0300 Subject: [PATCH] app: added test class for fill resource object on resource page --- app/test/aaUITestFrame.jsm | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/app/test/aaUITestFrame.jsm b/app/test/aaUITestFrame.jsm index 7ac40a1..924fcb0 100644 --- a/app/test/aaUITestFrame.jsm +++ b/app/test/aaUITestFrame.jsm @@ -524,3 +524,93 @@ function aaJSTestPageEntityModule(testNumber) { return base; } +/* +example for fill +{ + name: "test name", + contractID: "contract id", + cid: Components.ID(""), + object: { + isMoney: true or false + tag: 'asdsad' + code: //if isMoney set to true, that field will be used for set money code; + } +} +*/ +function aaJSTestNewResource(input) { + var me = new JSTest(); + me._name = input.name; + me._contractID = input.contractID; + me._CID = input.cid; + + me.isMoneyID = 'resource.isMoney'; + me.tagID = 'resource.tag'; + me.codeID = 'resource.code'; + + me.isMoney = false; + me.code = null; + me.tag = input.object.tag; + if (input.object.isMoney) { + me.isMoney = input.object.isMoney; + me.code = input.object.code; + } + + me._test = function(runner) { + var _tag = getElement(runner, this.tagID); + if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource] tag element not found"); + else { + //if is money + if (this.isMoney == true) { + var _isMoney = getElement(runner, this.isMoneyID); + var _code = getElement(runner, this.codeID); + if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element not found"); + else { + _isMoney.checked = true; + _isMoney.doCommand(); + if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource] code element not found"); + else if(_code.getAttribute('readonly') == 'true') { + this.addJSFailure(runner, "[aaJSTestNewResource] code element is readonly"); + } + else { + _code.value = this.code; + sendOnInput(_code); + } + } + } + _tag.value = this.tag; + sendOnInput(_tag); + } + if (this._check) { + this._check(runner); + } + } + me._check = function(runner) { + var _tag = getElement(runner, this.tagID); + if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource] tag element not found"); + else { + if (_tag.value != this.tag) { + this.addJSFailure(runner, "[aaJSTestNewResource] tag element is not equal: " + this.tag); + } + //if is money + if (this.isMoney == true) { + var _isMoney = getElement(runner, this.isMoneyID); + var _code = getElement(runner, this.codeID); + if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element not found"); + else { + if (_isMoney.checked != true) { + this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element is not checked"); + } + if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource] code element not found"); + else if(_code.getAttribute('readonly') == 'true') { + this.addJSFailure(runner, "[aaJSTestNewResource] code element is readonly"); + } + else if(_code.value != this.code){ + this.addJSFailure(runner, "[aaJSTestNewResource] code element is not equal: " + this.code); + } + } + } + } + } + return me; +} + -- 2.11.4.GIT