1 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=javascript: */
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
30 data: null //some data for special page
34 data: null //some data for special page
38 function JSTestPageModuleUI() {
39 var base = JSTestModule();
40 base.addOpenPage = null;
41 base.addClosePage = null;
42 base.parseAction = function(action) {
45 this.addOpenPage(action.data);
49 this.addClosePage(action.data);
57 /* End page specific class */
67 checkF: null //function to check
68 checkInTest: true or false
72 function aaJSDoCommandTest(input) {
73 var base = new JSTest();
75 base._name = input.name;
76 base._contractID = input.contractID;
77 base._CID = input.cid;
79 base._command = input.object.command;
80 base._checkInTest = false;
81 if (input.object.checkInTest) {
82 base._checkInTest = input.object.checkInTest;
85 base._test = function(runner) {
87 this.addJSFailure(runner, "JSDoCommandTest::_test - command is not defined");
89 runner.doCommand(this._command);
90 if (this._checkInTest && this._check) {
95 base._check = input.object.checkF;
102 cid: Components.ID(),
106 command: '' || click: ''
107 checkF: null //function to check
111 function aaJSCommandOpenPageTest(input) {
113 if (input.object.command) {
114 base = aaJSDoCommandTest(input);
115 base.aaJSDoCommandTest_test = base._test;
116 base._test = function(runner) {
118 this.aaJSDoCommandTest_test(runner);
120 this.addJSFailure(runner, "[aaJSCommandOpenPageTest] cann't do command. Exception: " + e);
122 runner.watchWindow = getFrame(runner).contentWindow;
124 } else if(input.object.click) {
126 base._CID = input.cid;
127 base._contractID = input.contractID;
128 base._name = input.name;
130 base._clickID = input.object.click;
132 base._test = function(runner) {
133 sendOnClick(getElement(runner, this._clickID));
134 runner.watchWindow = getFrame(runner).contentWindow;
136 base._check = input.object.checkF;
145 cid: Components.ID(),
147 command: "cmd_view_entity"
152 cid: Components.ID(),
154 command: "cmd_page1_submit",
155 checkF: null //function for check result page
158 example for extended actions:
162 data: null //page specific data
166 function aaJSTestPageModule(pgName) {
167 var base = JSTestPageModuleUI();
169 base._contractIDBase = "@aasii.org/abstract/test/";
170 base._pageName = pgName;
173 base._contractID = base._contractIDBase + base._pageName + "/page;" + base._version;
174 base._name = "aaPage_" + base._pageName;
176 base.generateContractID = function(inner_str) {
177 return this._contractIDBase + this._pageName + "/" + inner_str + ";" + this._version;
180 base.JSTestPage_parseAction = base.parseAction;
181 base.parseAction = function(action) {
182 switch(action.name) {
184 this.addFillTest(action.data);
188 return this.JSTestPage_parseAction(action);
190 base.addCommandPageOpenTest = function(data) {
191 this._add(aaJSCommandOpenPageTest(data));
193 base.addCommandTest = function(data) {
194 this._add(aaJSDoCommandTest(data));
196 base.addFillTest = null;
197 base.checkPage = function(runner) {
198 this.addJSFailure(runner, "aaJSTestPage.checkPage - not implemented");
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);
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);
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()
227 function aaJSTestPagePage1Module(pageName) {
228 var base = aaJSTestPageModule(pageName);
230 base.aaJSTestPageModule_parseAction = base.parseAction;
233 base.changeCID = null;
234 base.cancelCID = null;
235 base.resetCID = null;
238 base.checkNew = null;
239 base.checkChange = null;
240 base.checkCancel = null;
241 base.checkReset = null;
242 base.checkSave = null;
244 base.checkSubmit = null;
245 base.checkDiscard = null;
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';
253 base._SubmitCommand = 'cmd_page1_submit';
254 base._DiscardCommand = 'cmd_page1_discard';
256 base.parseAction = function(action) {
257 switch(action.name) {
259 this.addCids(action.data);
263 return this.aaJSTestPageModule_parseAction(action);
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;
272 base.addPage1CommandTest = function(cid, command, checkF) {
273 if (cid in this._map) {
274 this._repeat(this._map[cid]);
278 data.contractID = this.generateContractID("new_object/" + command);
279 data.name = "aaPage_" + this._pageName + "_" + command;
281 data.object.command = command;
282 data.object.checkF = checkF;
283 data.object.checkInTest = true;
285 this.addCommandTest(data);
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);
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);
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);
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);
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);
315 cid: Components.ID(),
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;
329 base._checkFunction = input.rowFunction;
330 base._object = input.object;
331 base._foundFunction = input.foundFunction;
333 base._test = function(runner) {
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);
342 if (this._foundFunction) {
343 this._foundFunction(runner);
348 this.addJSFailure(runner, "[aaJSSelectObjectTest] rowFunction is not defined");
351 this.addJSFailure(runner, "[aaJSSelectObjectTest] cann't find appropriate row");
355 base._check = function(runner) {
365 cid: Components.ID(),
367 //some child class specific object
372 function aaJSTestSelectablePagePage1Module(pageName)
374 var base = aaJSTestPagePage1Module(pageName);
376 base._IsPageForSelect = false;
378 base.checkPageWithSubmit = null;
379 base.selectCheckRow = null; //function(view, tree, i, object)
381 base.aaJSTestPagePage1Module_parseAction = base.parseAction;
382 base.aaJSTestPagePage1Module_addOpenPage = base.addOpenPage;
384 base.parseAction = function(action) {
385 switch(action.name) {
387 this.addSelectTest(action.data);
391 return this.aaJSTestPagePage1Module_parseAction(action);
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;
399 data.foundFunction = function(runner) {
400 runner.doCommand('cmd_page1_submit');
401 runner.watchWindow = getFrame(runner).contentWindow;
404 this._add(aaJSSelectObjectTest(data));
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);
413 this.aaJSTestPagePage1Module_addOpenPage(data);
423 contractID: "contract id",
424 cid: Components.ID(""),
430 function aaJSTestEntity(input) {
431 var me = new JSTest();
432 me._name = input.name;
433 me._contractID = input.contractID;
436 me._tagID = "entity.tag";
437 me._tagValue = input.object.tag;
439 me._test = function(runner) {
441 var box = getElement(runner, this._tagID);
443 box.value = this._tagValue;
449 me._check = function(runner) {
450 var box = getElement(runner, this._tagID);
452 if (this._tagValue != box.value) {
453 this.addJSFailure(runner, "[Entity page]: tag value is not equal tag textbox value");
462 cid: Components.ID(""),
469 cid: Components.ID(""),
476 function aaJSTestPageEntityModule(testNumber) {
477 var base = aaJSTestSelectablePagePage1Module('entity' + testNumber);
478 base.addFillTest = function(data) {
480 this.addCommandNewTest();
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));
486 this.addCommandSaveTest();
488 base.checkPage = function(runner) {
489 var tagBox = getElement(runner, 'entity.tag');
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");
496 base.checkNew = function(runner) {
497 var tagBox = getElement(runner, 'entity.tag');
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");
503 base.checkChange = function(runner) {
504 this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkChange] not implemented");
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");
511 base.checkReset = function(runner) {
512 this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkReset] not implemented");
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");
519 base.checkPageWithSubmit = function(runner) {
520 this.addJSFailure(runner, "[aaJSTestPageEntityModule.checkPageWithSubmit] not implemented");
522 base.selectCheckRow = function(view, tree, i, object) {
523 return view.getCellText(i, tree.columns[0]) == object.tag;
532 contractID: "contract id",
533 cid: Components.ID(""),
535 isMoney: true or false
537 code: //if isMoney set to true, that field will be used for set money code;
541 function aaJSTestNewResource(input) {
542 var me = new JSTest();
543 me._name = input.name;
544 me._contractID = input.contractID;
547 me.isMoneyID = 'resource.isMoney';
548 me.tagID = 'resource.tag';
549 me.codeID = 'resource.code';
553 me.tag = input.object.tag;
554 if (input.object.isMoney) {
555 me.isMoney = input.object.isMoney;
556 me.code = input.object.code;
559 me._test = function(runner) {
560 var _tag = getElement(runner, this.tagID);
561 if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource] tag element not found");
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");
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");
576 _code.value = this.code;
581 _tag.value = this.tag;
588 me._check = function(runner) {
589 var _tag = getElement(runner, this.tagID);
590 if (!_tag) this.addJSFailure(runner, "[aaJSTestNewResource] tag element not found");
592 if (_tag.value != this.tag) {
593 this.addJSFailure(runner, "[aaJSTestNewResource] tag element is not equal: " + this.tag);
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");
601 if (_isMoney.checked != true) {
602 this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element is not checked");
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");
608 else if(_code.value != this.code){
609 this.addJSFailure(runner, "[aaJSTestNewResource] code element is not equal: " + this.code);
621 cid: Components.ID(""),
623 isMoney: true or false
625 code: //if isMoney set to true, that field will be used for set money code;
630 cid: Components.ID(""),
632 isMoney: true or false
638 function aaJSTestPageResourceModule(testNumber) {
639 var base = aaJSTestSelectablePagePage1Module('resource' + testNumber);
640 base.addFillTest = function(data) {
642 this.addCommandNewTest();
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));
648 this.addCommandSaveTest();
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");
658 if(_code.getAttribute('readonly') != 'true') {
659 this.addJSFailure(runner, "[aaJSTestNewResource] code element is not readonly");
661 if (_isMoney.checked == true) {
662 this.addJSFailure(runner, "[aaJSTestNewResource] isMoney element is checked");
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");
675 if(_code.getAttribute('readonly') == 'true') {
676 this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] code element is readonly");
678 if (_isMoney.checked == true) {
679 this.addJSFailure(runner, "[aaJSTestNewResource.checkNew] isMoney element is checked");
682 base.checkChange = function(runner) {
683 this.addJSFailure(runner, "[aaJSTestPageResourceModule.checkChange] not implemented");
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");
695 if(_code.getAttribute('readonly') != 'true') {
696 this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] code element is not readonly");
698 if (_isMoney.checked == true) {
699 this.addJSFailure(runner, "[aaJSTestNewResource.checkCancel] isMoney element is checked");
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");
712 if (_isMoney.checked == true) {
713 if(_code.getAttribute('readonly') == 'true') {
714 this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] code element is readonly");
716 if(_code.value != '') {
717 this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] code element value is not null");
720 if(_code.getAttribute('readonly') != 'true') {
721 this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] code element is not readonly");
724 if(_tag.value != '') {
725 this.addJSFailure(runner, "[aaJSTestNewResource.checkReset] tag element value is not null");
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");
738 if(_code.getAttribute('readonly') != 'true') {
739 this.addJSFailure(runner, "[aaJSTestNewResource.checkSave] code element is not readonly");
742 base.checkPageWithSubmit = function(runner) {
743 this.addJSFailure(runner, "[aaJSTestPageResourceModule.checkPageWithSubmit] not implemented");
745 base.selectCheckRow = function(view, tree, i, object) {
747 if (object.isMoney) {
750 return view.getCellText(i, tree.columns[0]) == type &&
751 view.getCellText(i, tree.columns[1]) == object.tag;
760 contractID: "contract id",
761 cid: Components.ID(""),
765 direction: 0(-->) or 1(<--),
767 isOffBalance: true or false
772 cid: Components.ID(""),
776 direction: 0(-->) or 1(<--),
778 isOffBalance: true or false,
783 isMoney: true or false,
787 isMoney: true or false,
793 function aaJSTestNewFlow(input) {
794 var me = new JSTest();
795 me._name = input.name;
796 me._contractID = input.contractID;
799 me._tagID = 'flow.tag';
800 me._rateID = 'flow.rate';
801 me._directionID = 'rate.direction';
802 me._isOffBalanceID = 'flow.isoffbalance';
804 me._tagValue = input.object.tag;
805 me._rateValue = input.object.rate;
806 me._directionValue = input.object.direction;
807 me._isOffBalanceValue = input.object.isOffBalance;
809 if (input.object.isLight) {
810 me._isLight = input.object.isLight;
812 if (me._isLight == true) {
813 me._entity = input.object.entity;
814 me._give = input.object.giveRes;
815 me._take = input.object.takeRes;
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);
823 tagInput.value = this._tagValue;
824 sendOnInput(tagInput);
826 getElement(runner, this._directionID).selectedIndex = this._directionValue;
828 rateInput.value = this._rateValue;
829 sendOnInput(rateInput);
832 if (true == this._isOffBalanceValue) {
833 sendOnClick(flowIsOffBalance);
838 this.addEntity(runner);
839 this.addGiveResource(runner);
840 this.addTakeResource(runner);
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);
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);
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);
894 me._check = function(runner) {
895 var tagInput = getElement(runner, this._tagID);
897 this.addJSFailure(runner, "[aaJSTestNewFlow._check] cann't find element " + this._tagID);
899 if (tagInput.value != this._tagValue) {
900 this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._tagID + " is not equal to " + this._tagValue);
902 var rateInput = getElement(runner, this._rateID);
904 this.addJSFailure(runner, "[aaJSTestNewFlow._check] cann't find element " + this._rateID);
906 if (rateInput.value != this._rateValue) {
907 this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._rateID + " is not equal to " + this._rateValue);
909 var flowIsOffBalance = getElement(runner, this._isOffBalanceID);
910 if (!flowIsOffBalance) {
911 this.addJSFailure(runner, "[aaJSTestNewFlow._check] cann't find element " + this._isOffBalanceID);
913 if (flowIsOffBalance.checked != this._isOffBalanceValue) {
914 this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._isOffBalanceID + " is not equal to " + this._isOffBalanceValue);
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);
920 if (getElement(runner, this._directionID).selectedIndex != this._directionValue) {
921 this.addJSFailure(runner, "[aaJSTestNewFlow._check] element " + this._directionID + " is not equal to " + this._directionValue);
932 cid: Components.ID(""),
936 direction: 0(-->) or 1(<--),
938 isOffBalance: true or false,
941 cid: Components.ID(),
942 open_cid: Components.ID(),
943 close_cid: Components.ID()
946 {//specific flow for entity page
952 cid: Components.ID(),
953 open_cid: Components.ID(),
954 close_cid: Components.ID()
957 {//specific flow for resource page
963 cid: Components.ID(),
964 open_cid: Components.ID(),
965 close_cid: Components.ID()
968 {//specific flow for resource page
976 cid: Components.ID(""),
980 direction: 0(-->) or 1(<--),
982 isOffBalance: true or false,
987 isMoney: true or false,
991 isMoney: true or false,
998 cid: Components.ID(""),
1001 entity: 'haha' //entity tag
1006 function aaJSTestPageFlowModule(testNumber) {
1007 var base = aaJSTestSelectablePagePage1Module('resource' + testNumber);
1008 base.addFillTest = function(data) {
1010 this.addCommandNewTest();
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));
1016 if (!data.object.isLight) {
1017 this.addSelectEntity(data.object.entity);
1018 this.addSelectGiveResource(data.object.giveRes);
1019 this.addSelectTakeResource(data.object.takeRes, data);
1021 if (data.object.rules) {
1022 this.addFillRules(data.object.rules);
1025 this.addCommandSaveTest();
1027 base.addSelectEntity = function(entity) {
1028 var tmp = new Array();
1032 cid: entity.page.open_cid,
1034 command: 'cmd_flow_entity'
1038 var lng = tmp.length;
1039 for(var i = 0; i < entity.flow.length; i++) {
1040 tmp[lng++] = entity.flow[i];
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]);
1047 ////////////////////////////////////////////////////
1049 base.addSelectGiveResource = function(giveRes) {
1050 var tmp = new Array();
1054 cid: giveRes.page.open_cid,
1056 command: 'cmd_flow_give'
1060 var lng = tmp.length;
1061 for(var i = 0; i < giveRes.flow.length; i++) {
1062 tmp[lng++] = giveRes.flow[i];
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]);
1070 base.addSelectTakeResource = function(takeRes, data) {
1071 var tmp = new Array();
1075 cid: takeRes.page.open_cid,
1077 command: 'cmd_flow_take'
1081 var lng = tmp.length;
1082 for(var i = 0; i < takeRes.flow.length; i++) {
1083 tmp[lng++] = takeRes.flow[i];
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]);
1091 base.addFillRules = function(rules) {
1092 var tmp = new Array();
1096 cid: rules.page.open_cid,
1102 var lng = tmp.length;
1103 for(var i = 0; i < rules.flow.length; i++) {
1104 tmp[lng++] = rules.flow[i];
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]);
1112 base.checkPage = function(runner) {
1113 var tagInput = getElement(runner, "flow.tag");
1115 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.tag");
1117 if (tagInput.getAttribute("readonly") != 'true') {
1118 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.tag is not readonly");
1120 var rateInput = getElement(runner, "flow.rate");
1122 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.rate");
1124 if (rateInput.getAttribute("readonly") != 'true') {
1125 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.rate is not readonly");
1127 var flowIsOffBalance = getElement(runner, "flow.isoffbalance");
1128 if (!flowIsOffBalance) {
1129 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.isoffbalance");
1131 if (flowIsOffBalance.getAttribute("readonly") != 'true') {
1132 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.isoffbalance is not readonly");
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");
1138 if (getElement(runner, "rate.direction").getAttribute("readonly") != 'true') {
1139 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element rate.direction is not readonly");
1141 if (!getElement(runner, "entity.tag")) {
1142 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element entity.tag");
1144 if (getElement(runner, "entity.tag").getAttribute("readonly") != 'true') {
1145 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element entity.tag is not readonly");
1147 if (!getElement(runner, "give.tag")) {
1148 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element give.tag");
1150 if (getElement(runner, "give.tag").getAttribute("readonly") != 'true') {
1151 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element give.tag is not readonly");
1153 if (!getElement(runner, "take.tag")) {
1154 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element take.tag");
1156 if (getElement(runner, "take.tag").getAttribute("readonly") != 'true') {
1157 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element take.tag is not readonly");
1160 base.checkNew = function(runner) {
1161 var tagInput = getElement(runner, "flow.tag");
1163 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.tag");
1165 if (tagInput.getAttribute("readonly") == 'true') {
1166 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.tag is readonly");
1168 var rateInput = getElement(runner, "flow.rate");
1170 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.rate");
1172 if (rateInput.getAttribute("readonly") == 'true') {
1173 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.rate is readonly");
1175 var flowIsOffBalance = getElement(runner, "flow.isoffbalance");
1176 if (!flowIsOffBalance) {
1177 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element flow.isoffbalance");
1179 if (flowIsOffBalance.getAttribute("readonly") == 'true') {
1180 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element flow.isoffbalance is readonly");
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");
1186 if (getElement(runner, "rate.direction").getAttribute("readonly") == 'true') {
1187 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element rate.direction is readonly");
1189 if (!getElement(runner, "entity.tag")) {
1190 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element entity.tag");
1192 if (getElement(runner, "entity.tag").getAttribute("readonly") == 'true') {
1193 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element entity.tag is readonly");
1195 if (!getElement(runner, "give.tag")) {
1196 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element give.tag");
1198 if (getElement(runner, "give.tag").getAttribute("readonly") == 'true') {
1199 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element give.tag is readonly");
1201 if (!getElement(runner, "take.tag")) {
1202 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] cann't find element take.tag");
1204 if (getElement(runner, "take.tag").getAttribute("readonly") == 'true') {
1205 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPage] element take.tag is readonly");
1208 base.checkChange = function(runner) {
1209 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkChange] do not implemented");
1211 base.checkCancel = function(runner) {
1212 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkCancel] do not implemented");
1214 base.checkReset = function(runner) {
1215 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkReset] do not implemented");
1217 base.checkSave = base.checkPage;
1218 base.checkPageWithSubmit = function(runner) {
1219 this.addJSFailure(runner, "[aaJSTestPageFlowModule.checkPageWithSubmit] do not implemented");
1221 base.selectCheckRow = function(view, tree, i, object) {
1231 contractID: "contract id",
1232 cid: Components.ID(""),
1234 tag: 'shipment1.rule1',
1235 takeFrom: 'storage 1',
1242 function aaJSTestNewRule(input) {
1243 var me = new JSTest();
1244 me._name = input.name;
1245 me._contractID = input.contractID;
1246 me._CID = input.cid;
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';
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;
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);
1267 tag.value = this._tagValue;
1270 _rate.value = this._rateValue;
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];
1281 if (this._takeFromValue) {
1282 var tFromItem = _takeFrom.getElementsByAttribute("label", this._takeFromValue);
1283 if (tFromItem && tFromItem.length > 0) {
1284 _takeFrom.selectedItem = tFromItem[0];
1288 this._check(runner);
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);
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);
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);
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);
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);
1319 cid: Components.ID(""),
1321 tag: 'shipment1.rule1',
1322 takeFrom: 'storage 1',
1331 function aaJSTestPageRuleModule(testNumber) {
1332 var base = aaJSTestPagePage1Module('rule' + testNumber);
1333 base.addFillTest = function(data) {
1335 this.addCommandNewTest();
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));
1341 this.addCommandSaveTest();
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");
1348 var _rate = getElement(runner, "rule.rate");
1349 if (_rate.getAttribute('readonly') != 'true') {
1350 this.addJSFailure(runner, "[aaJSTestNewRule._check] rate is not readonly");
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");
1356 var _giveTo = getElement(runner, "rule.giveto");
1357 if (_giveTo.getAttribute('readonly') != 'true') {
1358 this.addJSFailure(runner, "[aaJSTestNewRule._check] _giveTo is not readonly");
1360 var _takeFrom = getElement(runner, "rule.takefrom");
1361 if (_takeFrom.getAttribute('readonly') != 'true') {
1362 this.addJSFailure(runner, "[aaJSTestNewRule._check] _takeFrom is not readonly");
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");
1370 var _rate = getElement(runner, "rule.rate");
1371 if (_rate.getAttribute('readonly') == 'true') {
1372 this.addJSFailure(runner, "[aaJSTestNewRule._check] rate is readonly");
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");
1378 var _giveTo = getElement(runner, "rule.giveto");
1379 if (_giveTo.getAttribute('readonly') == 'true') {
1380 this.addJSFailure(runner, "[aaJSTestNewRule._check] _giveTo is readonly");
1382 var _takeFrom = getElement(runner, "rule.takefrom");
1383 if (_takeFrom.getAttribute('readonly') == 'true') {
1384 this.addJSFailure(runner, "[aaJSTestNewRule._check] _takeFrom is readonly");
1387 base.checkChange = function(runner) {
1388 this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkChange] not implemented");
1390 base.checkCancel = function(runner) {
1391 this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkCancel] not implemented");
1393 base.checkReset = function(runner) {
1394 this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkReset] not implemented");
1396 base.checkSave = base.checkPage;
1397 base.checkPageWithSubmit = function(runner) {
1398 this.addJSFailure(runner, "[aaJSTestPageRuleModule.checkPageWithSubmit] not implemented");
1403 var EXPORTED_SYMBOLS = [
1404 "JSTestPageModuleUI",
1405 "aaJSDoCommandTest",
1406 "aaJSCommandOpenPageTest",
1407 "aaJSTestPageModule",
1408 "aaJSTestPagePage1Module",
1409 "aaJSSelectObjectTest",
1410 "aaJSTestSelectablePagePage1Module",
1412 "aaJSTestPageEntityModule",
1413 "aaJSTestNewResource",
1414 "aaJSTestPageResourceModule",
1416 "aaJSTestPageFlowModule",
1418 "aaJSTestPageRuleModule"