app: added class module for rule page
[abstract.git] / app / test / aaUITestFrame.jsm
blob542312c382c95433d17f8fe408b01dd78082fdab
1 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=javascript: */
2 /*
3 * Copyright (C) 2009 Sergey Yanovich <ynvich@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 Components.utils.import("resource:///modules/nsTestFrame.jsm");
23 /* Page specific class  */
25 example for actions on page
27     {
28         name: "open",
29         data: null //some data for special page 
30     },
31     {
32         name: "close",
33         data: null //some data for special page 
34     },
37 function JSTestPageModuleUI() {
38     var base = JSTestModule();
39     base.addOpenPage = null;
40     base.addClosePage = null;
41     base.parseAction = function(action) {
42         switch(action.name) {
43             case 'open':
44                 this.addOpenPage(action.data);
45                 return true;
46                 break;
47             case 'close':
48                 this.addClosePage(action.data);
49                 return true;
50                 break;
51         }
52         return false;
53     }
54     return base;
56 /* End page specific class */
59 example
61     cid: Components.ID(),
62     contractID: "",
63     name: "",
64     object: {
65         command: ''
66         checkF: null //function to check
67         checkInTest: true or false
68     }
71 function aaJSDoCommandTest(input) {
72     var base = new JSTest();
73     
74     base._name = input.name;
75     base._contractID = input.contractID;
76     base._CID = input.cid;
77     
78     base._command = input.object.command;
79     base._checkInTest = false;
80     if (input.object.checkInTest) {
81         base._checkInTest = input.object.checkInTest;
82     }
83     
84     base._test = function(runner) {
85         if (!this._command) 
86             this.addJSFailure(runner, "JSDoCommandTest::_test - command is not defined");
87         else {
88             runner.doCommand(this._command);
89             if (this._checkInTest && this._check) {
90                 this._check(runner);
91             }
92         }
93     }
94     base._check = input.object.checkF;
95     return base;
99 example
101     cid: Components.ID(),
102     contractID: "",
103     name: "",
104     object: {
105         command: '' || click: ''
106         checkF: null //function to check
107     }
110 function aaJSCommandOpenPageTest(input) {
111     var base = null;
112     if (input.object.command) {
113         base = aaJSDoCommandTest(input);
114         base.aaJSDoCommandTest_test = base._test;
115         base._test = function(runner) {
116             try {
117                 this.aaJSDoCommandTest_test(runner);
118             } catch(e) {
119                 this.addJSFailure(runner, "[aaJSCommandOpenPageTest] cann't do command. Exception: " + e);
120             }
121             runner.watchWindow = getFrame(runner).contentWindow;
122         }
123     } else if(input.object.click) {
124         base = new JSTest();
125         base._CID = input.cid;
126         base._contractID = input.contractID;
127         base._name = input.name;
128         
129         base._clickID = input.object.click;
130         
131         base._test = function(runner) {
132             sendOnClick(getElement(runner, this._clickID));
133             runner.watchWindow = getFrame(runner).contentWindow;
134         }
135         base._check = input.object.checkF;
136     }
137     return base;
141 example for:
142 1. open
144     cid: Components.ID(),
145     object: { 
146         command: "cmd_view_entity"
147     }
149 2. close
151     cid: Components.ID(),
152     object: { 
153         command: "cmd_page1_submit",
154         checkF: null //function for check result page
155     }
157 example for extended actions:
159     {
160         name: fill,
161         data: null //page specific data
162     },
165 function aaJSTestPageModule(pgName) {
166     var base = JSTestPageModuleUI();
167         
168     base._contractIDBase = "@aasii.org/abstract/test/";
169     base._pageName = pgName;
170     base._version = 1;
171     
172     base._contractID = base._contractIDBase + base._pageName + "/page;" + base._version;
173     base._name = "aaPage_" + base._pageName;
174     
175     base.generateContractID = function(inner_str) {
176         return this._contractIDBase + this._pageName + "/" + inner_str + ";" + this._version;
177     }
178     
179     base.JSTestPage_parseAction = base.parseAction;
180     base.parseAction = function(action) {
181         switch(action.name) {
182             case 'fill':
183                 this.addFillTest(action.data);
184                 return true;
185                 break;
186         }
187         return this.JSTestPage_parseAction(action);
188     }
189     base.addCommandPageOpenTest = function(data) {
190         this._add(aaJSCommandOpenPageTest(data));
191     }
192     base.addCommandTest = function(data) {
193         this._add(aaJSDoCommandTest(data));
194     }
195     base.addFillTest = null;
196     base.checkPage = function(runner) {
197         this.addJSFailure(runner, "aaJSTestPage.checkPage - not implemented");
198     }
199     base.addOpenPage = function(data) {
200         data.contractID = this.generateContractID("open" + this._parse_counter + "/" + data.object.command);
201         data.name = "aaPage_" + this._pageName + "_Open" + this._parse_counter + "_" + data.object.command;
202         data.object.checkF = this.checkPage;
203         this.addCommandPageOpenTest(data);
204     }
205     base.addClosePage = function(data) {
206         data.contractID = this.generateContractID("close" + this._parse_counter + "/" + data.object.command);
207         data.name = "aaPage_" + this._pageName + "_Close" + this._parse_counter + "_" + data.object.command;
208         this.addCommandPageOpenTest(data);
209     }
210     return base;
214 example for cids
216     name: 'page1_cids',
217     data: {
218         cid_new: Components.ID(),
219         cid_change: Components.ID(),
220         cid_cancel: Components.ID(),
221         cid_reset: Components.ID(),
222         cid_save: Components.ID()
223     }
226 function aaJSTestPagePage1Module(pageName) {
227     var base = aaJSTestPageModule(pageName);
228     
229     base.aaJSTestPageModule_parseAction = base.parseAction;
230     
231     base.newCID = null;
232     base.changeCID = null;
233     base.cancelCID = null;
234     base.resetCID = null;
235     base.saveCID = null;
236     
237     base.checkNew = null;
238     base.checkChange = null;
239     base.checkCancel = null;
240     base.checkReset = null;
241     base.checkSave = null;
242     
243     base.checkSubmit = null;
244     base.checkDiscard = null;
245     
246     base._NewCommand = 'cmd_page1_new';
247     base._ChangeCommand = 'cmd_page1_change';
248     base._CancelCommand = 'cmd_page1_cancel';
249     base._ResetCommand = 'cmd_page1_reset';
250     base._SaveCommand = 'cmd_page1_save';
251     
252     base._SubmitCommand = 'cmd_page1_submit';
253     base._DiscardCommand = 'cmd_page1_discard';
254     
255     base.parseAction = function(action) {
256         switch(action.name) {
257             case 'page1_cids':
258                 this.addCids(action.data);
259                 return true;
260                 break;
261         }
262         return this.aaJSTestPageModule_parseAction(action);
263     }
264     base.addCids = function(data) {
265         if (data.cid_new) this.newCID = data.cid_new;
266         if (data.cid_change) this.changeCID = data.cid_change;
267         if (data.cid_cancel) this.cancelCID = data.cid_cancel;
268         if (data.cid_reset) this.resetCID = data.cid_reset;
269         if (data.cid_save) this.saveCID = data.cid_save;
270     }    
271     base.addPage1CommandTest = function(cid, command, checkF) {
272         if (cid in this._map) {
273             this._repeat(this._map[cid]);
274         } else {
275             var data = {};
276             data.cid = cid;
277             data.contractID = this.generateContractID("new_object/" + command);
278             data.name = "aaPage_" + this._pageName + "_" + command;
279             data.object = {};
280             data.object.command = command;
281             data.object.checkF = checkF;
282             data.object.checkInTest = true;
283             //add
284             this.addCommandTest(data);
285         }
286     }
287     
288     base.addCommandNewTest = function() {
289         if (!this.newCID) throw "cid for new button is not defined";
290         this.addPage1CommandTest(this.newCID, this._NewCommand, this.checkNew);
291     }
292     base.addCommandChangeTest = function() {
293         if (!this.changeCID) throw "cid for change button is not defined";
294         this.addPage1CommandTest(this.changeCID, this._ChangeCommand, this.checkChange);
295     }
296     base.addCommandCancelTest = function() {
297         if (!this.cancelCID) throw "cid for cancel button is not defined";
298         this.addPage1CommandTest(this.cancelCID, this._CancelCommand, this.checkCancel);
299     }
300     base.addCommandResetTest = function() {
301         if (!this.resetCID) throw "cid for reset button is not defined";
302         this.addPage1CommandTest(this.resetCID, this._ResetCommand, this.checkReset);
303     }
304     base.addCommandSaveTest = function() {
305         if (!this.saveCID) throw "cid for save button is not defined";
306         this.addPage1CommandTest(this.saveCID, this._SaveCommand, this.checkSave);
307     }
308     return base;
312 input data
314     cid: Components.ID(),
315     contractID: '',
316     name: '',
317     object: //specific object
318     rowFunction: function(view, tree, i, object)
319     foundFunction: function(runner)
322 function aaJSSelectObjectTest(input) {
323     var base = new JSTest();
324     base._CID = input.cid;
325     base._contractID = input.contractID;
326     base._name = input.name;
327     
328     base._checkFunction = input.rowFunction;
329     base._object = input.object;
330     base._foundFunction = input.foundFunction;
331     
332     base._test = function(runner) {
333         var found = false;
334         if (this._checkFunction) {
335             var tree = getElement(runner, page1TreeID);
336             var view = tree.view;
337             for (var i = 0; i < tree.view.rowCount; ++ i) {
338                 if (this._checkFunction(view, tree, i, this._object)) {
339                     tree.view.selection.select(i);
340                     found = true;
341                     if (this._foundFunction) {
342                         this._foundFunction(runner);
343                     }
344                 }
345             }
346         } else {
347             this.addJSFailure(runner, "[aaJSSelectObjectTest] rowFunction is not defined");
348         }
349         if (!found) {
350             this.addJSFailure(runner, "[aaJSSelectObjectTest] cann't find appropriate row");
351         }
352     }
353     
354     base._check = function(runner) {
355     }
356     return base;
360 example for select
362     name: 'select',
363     data: {
364         cid: Components.ID(),
365         object: {
366             //some child class specific object
367         }
368     }
371 function aaJSTestSelectablePagePage1Module(pageName)
373     var base = aaJSTestPagePage1Module(pageName);
374     
375     base._IsPageForSelect = false;
376     
377     base.checkPageWithSubmit = null;
378     base.selectCheckRow = null; //function(view, tree, i, object)
379     
380     base.aaJSTestPagePage1Module_parseAction = base.parseAction;
381     base.aaJSTestPagePage1Module_addOpenPage = base.addOpenPage;
382     
383     base.parseAction = function(action) {
384         switch(action.name) {
385             case 'select':
386                 this.addSelectTest(action.data);
387                 return true;
388                 break;
389         }
390         return this.aaJSTestPagePage1Module_parseAction(action);
391     }
392     base.addSelectTest = function(data) {
393         this._IsPageForSelect = true;
394         data.contractID = this.generateContractID("select_object" + this._parse_counter);
395         data.name = "aaPageSelectObject" + this._parse_counter;
396         data.rowFunction = this.selectCheckRow;
397         //[TEST]
398         data.foundFunction = function(runner) {
399             runner.doCommand('cmd_page1_submit');
400             runner.watchWindow = getFrame(runner).contentWindow;
401         }
402         //[END TEST]
403         this._add(aaJSSelectObjectTest(data));
404     }
405     base.addOpenPage = function(data) {
406         if (this._IsPageForSelect) {
407             data.contractID = this.generateContractID("open" + this._parse_counter + "/" + data.object.command);
408             data.name = "aaPage_" + this._pageName + "_Open" + this._parse_counter + "_" + data.object.command;
409             data.object.checkF = this.checkPageWithSubmit;
410             this.addCommandPageOpenTest(data);
411         } else {
412             this.aaJSTestPagePage1Module_addOpenPage(data);
413         }
414     }
415     return base;
419 example for fill
421     name: "test name",
422     contractID: "contract id",
423     cid: Components.ID(""),
424     object: {
425         tag: 'asdsad'
426     }
429 function aaJSTestEntity(input) {
430     var me = new JSTest();
431     me._name = input.name;
432     me._contractID = input.contractID;
433     me._CID = input.cid;
434     
435     me._tagID = "entity.tag";
436     me._tagValue = input.object.tag;
437     
438     me._test = function(runner) {
439         //get element
440         var box = getElement(runner, this._tagID);
441         //set entity tag
442         box.value = this._tagValue;
443         sendOnInput(box);
444         if (this._check) {
445             this._check(runner);
446         }
447     }
448     me._check = function(runner) {
449         var box = getElement(runner, this._tagID);
450         //check tag entity
451         if (this._tagValue != box.value) {
452             this.addJSFailure(runner, "[Entity page]: tag value is not equal tag textbox value");   
453         }
454     }
455     return me;
459 example for fill
461     cid: Components.ID(""),
462     object: {
463         tag: 'asdsad'
464     }
466 example for select
468     cid: Components.ID(""),
469     object: {
470         tag: 'asdsad'
471     }
474 //add cid manually
475 function aaJSTestPageEntityModule(testNumber) {
476     var base = aaJSTestSelectablePagePage1Module('entity' + testNumber);
477     base.addFillTest = function(data) {
478         //add call new
479         this.addCommandNewTest();
480         //add fill
481         data.contractID = this.generateContractID("create_entity" + this._parse_counter + "_" + data.object.tag);
482         data.name = "aaEntityCreate_" + data.object.tag;
483         this._add(aaJSTestEntity(data));
484         //add call save
485         this.addCommandSaveTest();
486     }
487     base.checkPage = function(runner) {
488         var tagBox = getElement(runner, 'entity.tag');
489         if (!tagBox)
490             this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkPage] element entity.tag is not found");
491         //this.checkCancel(runner);
492         if (tagBox.getAttribute("readonly") != 'true')
493             this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkPage] element entity.tag is not readonly");
494     }
495     base.checkNew = function(runner) {
496         var tagBox = getElement(runner, 'entity.tag');
497         if (!tagBox)
498             this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkNew] element entity.tag is not found");
499         if (tagBox.getAttribute("readonly") == 'true')
500             this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkNew] element entity.tag is readonly");
501     }
502     base.checkChange = function(runner) {
503         this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkChange] not implemented");
504     }
505     base.checkCancel = function(runner) {
506         var tagBox = getElement(runner, 'entity.tag');
507         if (tagBox.getAttribute("readonly") != 'true')
508             this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkCancel] element entity.tag is not readonly");
509     }
510     base.checkReset = function(runner) {
511         this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkReset] not implemented");
512     }
513     base.checkSave = function(runner) {
514         var tagBox = getElement(runner, 'entity.tag');
515         if (tagBox.getAttribute("readonly") != 'true')
516             this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkSave] element entity.tag is not readonly");
517     }
518     base.checkPageWithSubmit = function(runner) {
519         this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkPageWithSubmit] not implemented");
520     }
521     base.selectCheckRow = function(view, tree, i, object) {
522         return view.getCellText(i, tree.columns[0]) == object.tag;
523     }
524     return base;
528 example for fill
530     name: "test name",
531     contractID: "contract id",
532     cid: Components.ID(""),
533     object: {
534         isMoney: true or false
535         tag: 'asdsad'
536         code: //if isMoney set to true, that field will be used for set money code;
537     }
540 function aaJSTestNewResource(input) {
541     var me = new JSTest();
542     me._name = input.name;
543     me._contractID = input.contractID;
544     me._CID = input.cid;
545     
546     me.isMoneyID = 'resource.isMoney';
547     me.tagID = 'resource.tag';
548     me.codeID = 'resource.code';
549     
550     me.isMoney = false;
551     me.code = null;
552     me.tag = input.object.tag;
553     if (input.object.isMoney) {
554         me.isMoney = input.object.isMoney;
555         me.code = input.object.code;
556     }
557     
558     me._test = function(runner) {
559         var _tag = getElement(runner, this.tagID);
560         if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource] tag element not found");
561         else {
562             //if is money
563             if (this.isMoney == true) {
564                 var _isMoney = getElement(runner, this.isMoneyID);
565                 var _code = getElement(runner, this.codeID);
566                 if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element not found");
567                 else {
568                     _isMoney.checked = true;
569                     _isMoney.doCommand();
570                     if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource] code element not found");
571                     else if(_code.getAttribute('readonly') == 'true') {
572                         this.addJSFailure(runner, "[aaJSTestNewResource] code element is readonly");
573                     }
574                     else {
575                         _code.value = this.code;
576                         sendOnInput(_code);
577                     }
578                 }
579             }
580             _tag.value = this.tag;
581             sendOnInput(_tag);
582         }
583         if (this._check) {
584             this._check(runner);
585         }
586     }
587     me._check = function(runner) {
588         var _tag = getElement(runner, this.tagID);
589         if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource] tag element not found");
590         else {
591             if (_tag.value != this.tag) {
592                 this.addJSFailure(runner, "[aaJSTestNewResource] tag element is not equal: " + this.tag);
593             }
594             //if is money
595             if (this.isMoney == true) {
596                 var _isMoney = getElement(runner, this.isMoneyID);
597                 var _code = getElement(runner, this.codeID);
598                 if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element not found");
599                 else {
600                     if (_isMoney.checked != true) {
601                         this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element is not checked");
602                     }
603                     if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource] code element not found");
604                     else if(_code.getAttribute('readonly') == 'true') {
605                         this.addJSFailure(runner, "[aaJSTestNewResource] code element is readonly");
606                     }
607                     else if(_code.value != this.code){
608                         this.addJSFailure(runner, "[aaJSTestNewResource] code element is not equal: " + this.code);
609                     }
610                 }
611             }
612         }
613     }
614     return me;
618 example for fill
620     cid: Components.ID(""),
621     object: {
622         isMoney: true or false
623         tag: 'asdsad'
624         code: //if isMoney set to true, that field will be used for set money code;
625     }
627 example for select
629     cid: Components.ID(""),
630     object: {
631         isMoney: true or false
632         tag: 'asdsad'
633     }
636 //add cid manually
637 function aaJSTestPageResourceModule(testNumber) {
638     var base = aaJSTestSelectablePagePage1Module('resource' + testNumber);
639     base.addFillTest = function(data) {
640         //add call new
641         this.addCommandNewTest();
642         //add fill
643         data.contractID = this.generateContractID("create_resource" + this._parse_counter + "_" + data.object.tag);
644         data.name = "aaResourceCreate" + this._parse_counter + "_" + data.object.tag;
645         this._add(aaJSTestNewResource(data));
646         //add call save
647         this.addCommandSaveTest();
648     }
649     base.checkPage = function(runner) {
650         var _tag = getElement(runner, "resource.tag");
651         var _isMoney = getElement(runner, "resource.isMoney");
652         var _code = getElement(runner, "resource.code");
653         if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource] tag element not found");
654         if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element not found");
655         if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource] code element not found");
656         
657         if(_code.getAttribute('readonly') != 'true') {
658             this.addJSFailure(runner, "[aaJSTestNewResource] code element is not readonly");
659         }
660         if (_isMoney.checked == true) {
661             this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element is checked");
662         }
663     }
664     base.checkNew = function(runner) {
665         var _tag = getElement(runner, "resource.tag");
666         var _isMoney = getElement(runner, "resource.isMoney");
667         var _code = getElement(runner, "resource.code");
668         if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] tag element not found");
669         if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] isMoney element not found");
670         if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] code element not found");
671         if(_tag.getAttribute('readonly') == 'true') {
672             this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] tag element is readonly");
673         }
674         if(_code.getAttribute('readonly') == 'true') {
675             this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] code element is readonly");
676         }
677         if (_isMoney.checked == true) {
678             this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] isMoney element is checked");
679         }
680     }
681     base.checkChange = function(runner) {
682         this.addJSFailure(runner, "[aaJSTestPageResourceModule.checkChange] not implemented");
683     }
684     base.checkCancel = function(runner) {
685         var _tag = getElement(runner, "resource.tag");
686         var _isMoney = getElement(runner, "resource.isMoney");
687         var _code = getElement(runner, "resource.code");
688         if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] tag element not found");
689         if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] isMoney element not found");
690         if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] code element not found");
691         if(_tag.getAttribute('readonly') != 'true') {
692             this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] tag element is not readonly");
693         }
694         if(_code.getAttribute('readonly') != 'true') {
695             this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] code element is not readonly");
696         }
697         if (_isMoney.checked == true) {
698             this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] isMoney element is checked");
699         }
700     }
701     base.checkReset = function(runner) {
702         var _tag = getElement(runner, "resource.tag");
703         var _isMoney = getElement(runner, "resource.isMoney");
704         var _code = getElement(runner, "resource.code");
705         if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] tag element not found");
706         if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] isMoney element not found");
707         if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] code element not found");
708         if(_tag.getAttribute('readonly') == 'true') {
709             this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] tag element is readonly");
710         }
711         if (_isMoney.checked == true) {
712             if(_code.getAttribute('readonly') == 'true') {
713                 this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] code element is readonly");
714             }
715             if(_code.value != '') {
716                 this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] code element value is not null");
717             }
718         } else {
719             if(_code.getAttribute('readonly') != 'true') {
720                 this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] code element is not readonly");
721             }
722         }
723         if(_tag.value != '') {
724             this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] tag element value is not null");
725         }
726     }
727     base.checkSave = function(runner) {
728         var _tag = getElement(runner, "resource.tag");
729         var _isMoney = getElement(runner, "resource.isMoney");
730         var _code = getElement(runner, "resource.code");
731         if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource.checkSave] tag element not found");
732         if (!_isMoney) this.addJSFailure(runner, "[aaJSTestNewResource.checkSave] isMoney element not found");
733         if (!_code) this.addJSFailure(runner, "[aaJSTestNewResource.checkSave] code element not found");
734         if(_tag.getAttribute('readonly') != 'true') {
735             this.addJSFailure(runner, "[aaJSTestNewResource.checkSave] tag element is not readonly");
736         }
737         if(_code.getAttribute('readonly') != 'true') {
738             this.addJSFailure(runner, "[aaJSTestNewResource.checkSave] code element is not readonly");
739         }
740     }
741     base.checkPageWithSubmit = function(runner) {
742         this.addJSFailure(runner, "[aaJSTestPageResourceModule.checkPageWithSubmit] not implemented");
743     }
744     base.selectCheckRow = function(view, tree, i, object) {
745         var type = 'asset';
746         if (object.isMoney) {
747             type = 'money';
748         }
749         return view.getCellText(i, tree.columns[0]) == type &&
750                 view.getCellText(i, tree.columns[1]) == object.tag;
751     }
752     return base;
756 example for fill
758     name: "test name",
759     contractID: "contract id",
760     cid: Components.ID(""),
761     object: {
762         isLight: false,
763         tag: 'asdsad',
764         direction: 0(-->) or 1(<--), 
765         rate: 1.0, 
766         isOffBalance: true or false
767     }
769 second version
771     cid: Components.ID(""),
772     object: {
773         isLight: true,
774         tag: 'asdsad',
775         direction: 0(-->) or 1(<--), 
776         rate: 1.0, 
777         isOffBalance: true or false,
778         entity: {
779             tag: ''
780         },
781         giveRes: {
782             isMoney: true or false,
783             tag: ''
784         },
785         takeRes: {
786             isMoney: true or false,
787             tag: ''
788         }
789     }
792 function aaJSTestNewFlow(input) {
793     var me = new JSTest();
794     me._name = input.name;
795     me._contractID = input.contractID;
796     me._CID = input.cid;
797     
798     me._tagID = 'flow.tag';
799     me._rateID = 'flow.rate';
800     me._directionID = 'rate.direction';
801     me._isOffBalanceID = 'flow.isoffbalance';
802     
803     me._tagValue = input.object.tag;
804     me._rateValue = input.object.rate;
805     me._directionValue = input.object.direction;
806     me._isOffBalanceValue = input.object.isOffBalance;
807     me._isLight = false;
808     if (input.object.isLight) {
809         me._isLight = input.object.isLight;
810     }
811     if (me._isLight == true) {
812         me._entity = input.object.entity;
813         me._give = input.object.giveRes;
814         me._take = input.object.takeRes;
815     }
816     
817     me._test = function(runner) {
818         var tagInput = getElement(runner, this._tagID);
819         var rateInput = getElement(runner, this._rateID);
820         var flowIsOffBalance = getElement(runner, this._isOffBalanceID);
821         //fill input values
822         tagInput.value = this._tagValue;
823         sendOnInput(tagInput);
824         
825         getElement(runner, this._directionID).selectedIndex = this._directionValue;
826         
827         rateInput.value = this._rateValue;
828         sendOnInput(rateInput);
829         
830         //set is off balance
831         if (true == this._isOffBalanceValue) {
832             sendOnClick(flowIsOffBalance);
833         }
834         
835         //if is light
836         if (this._isLight) {
837             this.addEntity(runner);
838             this.addGiveResource(runner);
839             this.addTakeResource(runner);
840         }
841         if (this._check) {
842             this._check(runner);
843         }
844     }
845     me.addEntity = function(runner) {
846         var loader = Components.classes["@aasii.org/storage/load-entity;1"].createInstance(nsCI.aaISqlRequest);
847         var entities = getFrame(runner).docShell.QueryInterface(nsCI.nsIWebNavigation).sessionHistory.load(loader);
848         var enumerator = entities.enumerate();
849         while(enumerator.hasMoreElements()) {
850             var entity = enumerator.getNext().QueryInterface(nsCI.aaIEntity);
851             if (entity.tag == this._entity.tag) {
852                 var page = getFrame(runner).contentWindow.wrappedJSObject.view;
853                 page.buffer.QueryInterface(nsCI.aaIFlow).entity =
854                         entity.QueryInterface(nsCI.aaIEntity);
855                 break;
856             }
857         }
858     }
859     me.addGiveResource = function(runner) {
860         var loader = Components.classes["@aasii.org/storage/load-resource;1"].createInstance(nsCI.aaISqlRequest);
861         var resources = getFrame(runner).docShell.QueryInterface(nsCI.nsIWebNavigation).sessionHistory.load(loader);
862         var enumerator = resources.enumerate();
863         while(enumerator.hasMoreElements()) {
864             var resource = enumerator.getNext().QueryInterface(nsCI.aaIResource);
865             if (resource.tag == this._give.tag) {
866                 if ((this._give.isMoney && resource.type == nsCI.aaIResource.TYPE_MONEY) || 
867                     (!this._give.isMoney && resource.type == nsCI.aaIResource.TYPE_ASSET)) {
868                     var page = getFrame(runner).contentWindow.wrappedJSObject.view;
869                     page.buffer.QueryInterface(nsCI.aaIFlow).giveResource =
870                             resource.QueryInterface(nsCI.aaIResource);
871                     break;
872                 }
873             }
874         }
875     }
876     me.addTakeResource = function(runner) {
877         var loader = Components.classes["@aasii.org/storage/load-resource;1"].createInstance(nsCI.aaISqlRequest);
878         var resources = getFrame(runner).docShell.QueryInterface(nsCI.nsIWebNavigation).sessionHistory.load(loader);
879         var enumerator = resources.enumerate();
880         while(enumerator.hasMoreElements()) {
881             var resource = enumerator.getNext().QueryInterface(nsCI.aaIResource);
882             if (resource.tag == this._take.tag) {
883                 if ((this._take.isMoney && resource.type == nsCI.aaIResource.TYPE_MONEY) || 
884                     (!this._take.isMoney && resource.type == nsCI.aaIResource.TYPE_ASSET)) {
885                     var page = getFrame(runner).contentWindow.wrappedJSObject.view;
886                     page.buffer.QueryInterface(nsCI.aaIFlow).takeResource =
887                             resource.QueryInterface(nsCI.aaIResource);
888                     break;
889                 }
890             }
891         }
892     }
893     me._check = function(runner) {
894         var tagInput = getElement(runner, this._tagID);
895         if (!tagInput) {
896             this.addJSFailure(runner, "[aaJSTestNewFlow._check] cann't find element " + this._tagID);
897         }
898         if (tagInput.value != this._tagValue) {
899             this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._tagID + " is not equal to " + this._tagValue);
900         }
901         var rateInput = getElement(runner, this._rateID);
902         if (!rateInput) {
903             this.addJSFailure(runner, "[aaJSTestNewFlow._check] cann't find element " + this._rateID);
904         }
905         if (rateInput.value != this._rateValue) {
906             this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._rateID + " is not equal to " + this._rateValue);
907         }
908         var flowIsOffBalance = getElement(runner, this._isOffBalanceID);
909         if (!flowIsOffBalance) {
910             this.addJSFailure(runner, "[aaJSTestNewFlow._check] cann't find element " + this._isOffBalanceID);
911         }
912         if (flowIsOffBalance.checked != this._isOffBalanceValue) {
913             this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._isOffBalanceID + " is not equal to " + this._isOffBalanceValue);
914         }
915         //getElement(runner, this._directionID).selectedIndex = this._directionValue;
916         if (!getElement(runner, this._directionID)) {
917             this.addJSFailure(runner, "[aaJSTestNewFlow._check] cann't find element " + this._directionID);
918         }
919         if (getElement(runner, this._directionID).selectedIndex != this._directionValue) {
920             this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._directionID + " is not equal to " + this._directionValue);
921         }
922     }
923     return me;
927 example for fill
929 first version
931     cid: Components.ID(""),
932     object: {
933         isLight: false,
934         tag: 'asdsad',
935         direction: 0(-->) or 1(<--), 
936         rate: 1.0, 
937         isOffBalance: true or false,
938         entity: {
939             page: {
940                 cid: Components.ID(),
941                 open_cid: Components.ID(),
942                 close_cid: Components.ID()
943             }
944             flow: [
945                 {//specific flow for entity page
946                 }
947             ]
948         },
949         giveRes: {
950             page: {
951                 cid: Components.ID(),
952                 open_cid: Components.ID(),
953                 close_cid: Components.ID()
954             }
955             flow: [
956                 {//specific flow for resource page
957                 }
958             ]
959         },
960         takeRes: {
961             page: {
962                 cid: Components.ID(),
963                 open_cid: Components.ID(),
964                 close_cid: Components.ID()
965             }
966             flow: [
967                 {//specific flow for resource page
968                 }
969             ]
970         }
971     }
973 second version
975     cid: Components.ID(""),
976     object: {
977         isLight: true,
978         tag: 'asdsad',
979         direction: 0(-->) or 1(<--), 
980         rate: 1.0, 
981         isOffBalance: true or false,
982         entity: {
983             tag: ''
984         },
985         giveRes: {
986             isMoney: true or false,
987             tag: ''
988         },
989         takeRes: {
990             isMoney: true or false,
991             tag: ''
992         }
993     }
995 example for select
997     cid: Components.ID(""),
998     object: {
999         tag: 'asdsad'
1000         entity: 'haha' //entity tag
1001     }
1004 //add cid manually
1005 function aaJSTestPageFlowModule(testNumber) {
1006     var base = aaJSTestSelectablePagePage1Module('resource' + testNumber);
1007     base.addFillTest = function(data) {
1008         //add call new
1009         this.addCommandNewTest();
1010         //add fill
1011         data.contractID = this.generateContractID("create_flow" + this._parse_counter + "_" + data.object.tag);
1012         data.name = "aaFlowCreate" + this._parse_counter + "_" + data.object.tag;
1013         this._add(aaJSTestNewFlow(data));
1014         //add entity select
1015         if (!data.object.isLight) {
1016             this.addSelectEntity(data.object.entity);
1017             this.addSelectGiveResource(data.object.giveRes);
1018             this.addSelectTakeResource(data.object.takeRes, data);
1019         }
1020         if (data.object.rules) {
1021             this.addFillRules(data.object.rules);
1022         }
1023         //add call save
1024         this.addCommandSaveTest();
1025     }
1026     base.addSelectEntity = function(entity) {        
1027         var tmp = new Array();
1028         tmp[0] = {
1029             name: 'open',
1030             data: {
1031                 cid: entity.page.open_cid,
1032                 object: {
1033                     command: 'cmd_flow_entity'
1034                 }
1035             }
1036         };
1037         var lng = tmp.length;
1038         for(var i = 0; i < entity.flow.length; i++) {
1039             tmp[lng++] = entity.flow[i];
1040         }
1041         var _entityModule = aaJSTestPageEntityModule(this._tests.length);
1042         _entityModule.createTestsFlow(tmp);
1043         for(var i = 0; i < _entityModule._tests.length; i++) {
1044             this._add(_entityModule._tests[i]);
1045         }
1046         ////////////////////////////////////////////////////
1047     }
1048     base.addSelectGiveResource = function(giveRes) {
1049         var tmp = new Array();
1050         tmp[0] = {
1051             name: 'open',
1052             data: {
1053                 cid: giveRes.page.open_cid,
1054                 object: {
1055                     command: 'cmd_flow_give'
1056                 }
1057             }
1058         };
1059         var lng = tmp.length;
1060         for(var i = 0; i < giveRes.flow.length; i++) {
1061             tmp[lng++] = giveRes.flow[i];
1062         }
1063         var _resource = aaJSTestPageResourceModule(this._tests.length);
1064         _resource.createTestsFlow(tmp);
1065         for(var i = 0; i < _resource._tests.length; i++) {
1066             this._add(_resource._tests[i]);
1067         }
1068     }
1069     base.addSelectTakeResource = function(takeRes, data) {
1070         var tmp = new Array();
1071         tmp[0] = {
1072             name: 'open',
1073             data: {
1074                 cid: takeRes.page.open_cid,
1075                 object: {
1076                     command: 'cmd_flow_take'
1077                 }
1078             }
1079         };
1080         var lng = tmp.length;
1081         for(var i = 0; i < takeRes.flow.length; i++) {
1082             tmp[lng++] = takeRes.flow[i];
1083         }
1084         var _resource = aaJSTestPageResourceModule(this._tests.length);
1085         _resource.createTestsFlow(tmp);
1086         for(var i = 0; i < _resource._tests.length; i++) {
1087             this._add(_resource._tests[i]);
1088         }
1089     }
1090     base.addFillRules = function(rules) {
1091         var tmp = new Array();
1092         tmp[0] = {
1093             name: 'open',
1094             data: {
1095                 cid: rules.page.open_cid,
1096                 object: {
1097                     click: 'flow.rules'
1098                 }
1099             }
1100         };
1101         var lng = tmp.length;
1102         for(var i = 0; i < rules.flow.length; i++) {
1103             tmp[lng++] = rules.flow[i];
1104         }
1105         var _rule = aaJSTestPageRuleModule(this._tests.length);
1106         _rule.createTestsFlow(tmp);
1107         for(var i = 0; i < _rule._tests.length; i++) {
1108             this._add(_rule._tests[i]);
1109         }
1110     }
1111     base.checkPage = function(runner) {
1112         var tagInput = getElement(runner, "flow.tag");
1113         if (!tagInput) {
1114             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.tag");
1115         }
1116         if (tagInput.getAttribute("readonly") != 'true') {
1117             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.tag is not readonly");
1118         }
1119         var rateInput = getElement(runner, "flow.rate");
1120         if (!rateInput) {
1121             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.rate");
1122         }
1123         if (rateInput.getAttribute("readonly") != 'true') {
1124             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.rate is not readonly");
1125         }
1126         var flowIsOffBalance = getElement(runner, "flow.isoffbalance");
1127         if (!flowIsOffBalance) {
1128             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.isoffbalance");
1129         }
1130         if (flowIsOffBalance.getAttribute("readonly") != 'true') {
1131             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.isoffbalance is not readonly");
1132         }
1133         //getElement(runner, this._directionID).selectedIndex = this._directionValue;
1134         if (!getElement(runner, "rate.direction")) {
1135             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element rate.direction");
1136         }
1137         if (getElement(runner, "rate.direction").getAttribute("readonly") != 'true') {
1138             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element rate.direction is not readonly");
1139         }
1140         if (!getElement(runner, "entity.tag")) {
1141             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element entity.tag");
1142         }
1143         if (getElement(runner, "entity.tag").getAttribute("readonly") != 'true') {
1144             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element entity.tag is not readonly");
1145         }
1146         if (!getElement(runner, "give.tag")) {
1147             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element give.tag");
1148         }
1149         if (getElement(runner, "give.tag").getAttribute("readonly") != 'true') {
1150             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element give.tag is not readonly");
1151         }
1152         if (!getElement(runner, "take.tag")) {
1153             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element take.tag");
1154         }
1155         if (getElement(runner, "take.tag").getAttribute("readonly") != 'true') {
1156             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element take.tag is not readonly");
1157         }
1158     }
1159     base.checkNew = function(runner) {
1160         var tagInput = getElement(runner, "flow.tag");
1161         if (!tagInput) {
1162             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.tag");
1163         }
1164         if (tagInput.getAttribute("readonly") == 'true') {
1165             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.tag is readonly");
1166         }
1167         var rateInput = getElement(runner, "flow.rate");
1168         if (!rateInput) {
1169             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.rate");
1170         }
1171         if (rateInput.getAttribute("readonly") == 'true') {
1172             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.rate is readonly");
1173         }
1174         var flowIsOffBalance = getElement(runner, "flow.isoffbalance");
1175         if (!flowIsOffBalance) {
1176             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.isoffbalance");
1177         }
1178         if (flowIsOffBalance.getAttribute("readonly") == 'true') {
1179             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.isoffbalance is readonly");
1180         }
1181         //getElement(runner, this._directionID).selectedIndex = this._directionValue;
1182         if (!getElement(runner, "rate.direction")) {
1183             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element rate.direction");
1184         }
1185         if (getElement(runner, "rate.direction").getAttribute("readonly") == 'true') {
1186             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element rate.direction is readonly");
1187         }
1188         if (!getElement(runner, "entity.tag")) {
1189             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element entity.tag");
1190         }
1191         if (getElement(runner, "entity.tag").getAttribute("readonly") == 'true') {
1192             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element entity.tag is readonly");
1193         }
1194         if (!getElement(runner, "give.tag")) {
1195             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element give.tag");
1196         }
1197         if (getElement(runner, "give.tag").getAttribute("readonly") == 'true') {
1198             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element give.tag is readonly");
1199         }
1200         if (!getElement(runner, "take.tag")) {
1201             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element take.tag");
1202         }
1203         if (getElement(runner, "take.tag").getAttribute("readonly") == 'true') {
1204             this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element take.tag is readonly");
1205         }
1206     }
1207     base.checkChange = function(runner) {
1208         this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkChange] do not implemented");
1209     }
1210     base.checkCancel = function(runner) {
1211         this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkCancel] do not implemented");
1212     }
1213     base.checkReset = function(runner) {
1214         this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkReset] do not implemented");
1215     }
1216     base.checkSave = base.checkPage;
1217     base.checkPageWithSubmit = function(runner) {
1218         this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPageWithSubmit] do not implemented");
1219     }
1220     base.selectCheckRow = function(view, tree, i, object) {
1221         return false;
1222     }
1223     return base;
1227 example for fill
1229     name: "test name",
1230     contractID: "contract id",
1231     cid: Components.ID(""),
1232     object: {
1233         tag: 'shipment1.rule1',
1234         takeFrom: 'storage 1',
1235         giveTo: 'sale 1',
1236         rate: 27.0,
1237         change_fact_side: 0
1238     }
1241 function aaJSTestNewRule(input) {
1242     var me = new JSTest();
1243     me._name = input.name;
1244     me._contractID = input.contractID;
1245     me._CID = input.cid;
1246     
1247     me._tagID = 'rule.tag';
1248     me._takeFromID = 'rule.takefrom';
1249     me._giveToID = 'rule.giveto';
1250     me._rateID = 'rule.rate';
1251     me._change_fact_sideID = 'rule.change.fact.side';
1252     
1253     me._tagValue = input.object.tag;
1254     me._takeFromValue = input.object.takeFrom;
1255     me._giveToValue = input.object.giveTo;
1256     me._rateValue = input.object.rate;
1257     me._change_fact_sideValue = input.object.change_fact_side;
1258     
1259     me._test = function(runner) {
1260         var tag = getElement(runner, this._tagID);
1261         var _rate = getElement(runner, this._rateID);
1262         var _changeFact = getElement(runner, this._change_fact_sideID);
1263         var _giveTo = getElement(runner, this._giveToID);
1264         var _takeFrom = getElement(runner, this._takeFromID);
1265         
1266         tag.value = this._tagValue;
1267         sendOnInput(tag);
1268         
1269         _rate.value = this._rateValue;
1270         sendOnInput(_rate);
1271         
1272         _changeFact.selectedIndex = this._change_fact_sideValue;
1273         //find combobox item
1274         if (this._giveToValue) {
1275             var gToItem = _giveTo.getElementsByAttribute("label", this._giveToValue);
1276             if (gToItem && gToItem.length > 0) {
1277                 _giveTo.selectedItem = gToItem[0];
1278             }
1279         }
1280         if (this._takeFromValue) {
1281             var tFromItem = _takeFrom.getElementsByAttribute("label", this._takeFromValue);
1282             if (tFromItem && tFromItem.length > 0) {
1283                 _takeFrom.selectedItem = tFromItem[0];
1284             }
1285         }
1286         if (this._check) {
1287             this._check(runner);
1288         }
1289     }
1290     me._check = function(runner) {
1291         var tag = getElement(runner, this._tagID);
1292         if (tag.value != this._tagValue) {
1293             this.addJSFailure(runner, "[aaJSTestNewRule._check] tag value is not equal to set; Value: " + tag.value);
1294         }
1295         var _rate = getElement(runner, this._rateID);
1296         if (_rate.value != this._rateValue) {
1297             this.addJSFailure(runner, "[aaJSTestNewRule._check] rate value is not equal to set; Value: " + _rate.value);
1298         }
1299         var _changeFact = getElement(runner, this._change_fact_sideID);
1300         if (_changeFact.selectedIndex != this._change_fact_sideValue) {
1301             this.addJSFailure(runner, "[aaJSTestNewRule._check] change_fact_side value is not equal to set; Value: " + _changeFact.selectedIndex);
1302         }
1303         var _giveTo = getElement(runner, this._giveToID);
1304         if (_giveTo.selectedItem.label != this._giveToValue) {
1305             this.addJSFailure(runner, "[aaJSTestNewRule._check] _giveTo value is not equal to set; Value: " + _giveTo.selectedItem.label);
1306         }
1307         var _takeFrom = getElement(runner, this._takeFromID);
1308         if (_takeFrom.selectedItem.label != this._takeFromValue) {
1309             this.addJSFailure(runner, "[aaJSTestNewRule._check] _takeFrom value is not equal to set; Value: " + _takeFrom.selectedItem.label);
1310         }
1311     }
1312     return me;
1316 example for fill
1318     cid: Components.ID(""),
1319     object: {
1320         tag: 'shipment1.rule1',
1321         takeFrom: 'storage 1',
1322         giveTo: 'sale 1',
1323         rate: 27.0,
1324         change_fact_side: 0
1325     }
1327 do not selectable
1329 //add cid manually
1330 function aaJSTestPageRuleModule(testNumber) {
1331     var base = aaJSTestPagePage1Module('rule' + testNumber);
1332     base.addFillTest = function(data) {
1333         //add call new
1334         this.addCommandNewTest();
1335         //add fill
1336         data.contractID = this.generateContractID("create_rule" + this._parse_counter + "_" + data.object.tag);
1337         data.name = "aaRuleCreate" + this._parse_counter + "_" + data.object.tag;
1338         this._add(aaJSTestNewRule(data));
1339         //add call save
1340         this.addCommandSaveTest();
1341     }
1342     base.checkPage = function(runner) {
1343         var tag = getElement(runner, "rule.tag");
1344         if (tag.getAttribute('readonly') != 'true') {
1345             this.addJSFailure(runner, "[aaJSTestNewRule._check] tag is not readonly");
1346         }
1347         var _rate = getElement(runner, "rule.rate");
1348         if (_rate.getAttribute('readonly') != 'true') {
1349             this.addJSFailure(runner, "[aaJSTestNewRule._check] rate is not readonly");
1350         }
1351         var _changeFact = getElement(runner, "rule.change.fact.side");
1352         if (_changeFact.getAttribute('readonly') != 'true') {
1353             this.addJSFailure(runner, "[aaJSTestNewRule._check] change_fact_side is not readonly");
1354         }
1355         var _giveTo = getElement(runner, "rule.giveto");
1356         if (_giveTo.getAttribute('readonly') != 'true') {
1357             this.addJSFailure(runner, "[aaJSTestNewRule._check] _giveTo is not readonly");
1358         }
1359         var _takeFrom = getElement(runner, "rule.takefrom");
1360         if (_takeFrom.getAttribute('readonly') != 'true') {
1361             this.addJSFailure(runner, "[aaJSTestNewRule._check] _takeFrom is not readonly");
1362         }
1363     }
1364     base.checkNew = function(runner) {
1365         var tag = getElement(runner, "rule.tag");
1366         if (tag.getAttribute('readonly') == 'true') {
1367             this.addJSFailure(runner, "[aaJSTestNewRule._check] tag is readonly");
1368         }
1369         var _rate = getElement(runner, "rule.rate");
1370         if (_rate.getAttribute('readonly') == 'true') {
1371             this.addJSFailure(runner, "[aaJSTestNewRule._check] rate is readonly");
1372         }
1373         var _changeFact = getElement(runner, "rule.change.fact.side");
1374         if (_changeFact.getAttribute('readonly') == 'true') {
1375             this.addJSFailure(runner, "[aaJSTestNewRule._check] change_fact_side is readonly");
1376         }
1377         var _giveTo = getElement(runner, "rule.giveto");
1378         if (_giveTo.getAttribute('readonly') == 'true') {
1379             this.addJSFailure(runner, "[aaJSTestNewRule._check] _giveTo is readonly");
1380         }
1381         var _takeFrom = getElement(runner, "rule.takefrom");
1382         if (_takeFrom.getAttribute('readonly') == 'true') {
1383             this.addJSFailure(runner, "[aaJSTestNewRule._check] _takeFrom is readonly");
1384         }
1385     }
1386     base.checkChange = function(runner) {
1387         this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkChange] not implemented");
1388     }
1389     base.checkCancel = function(runner) {
1390         this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkCancel] not implemented");
1391     }
1392     base.checkReset = function(runner) {
1393         this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkReset] not implemented");
1394     }
1395     base.checkSave = base.checkPage;
1396     base.checkPageWithSubmit = function(runner) {
1397         this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkPageWithSubmit] not implemented");
1398     }
1399     return base;