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