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/nsTestFrame.jsm");
23 /* Page specific class */
25 example for actions on page
29 data: null //some data for special page
33 data: null //some data for special page
37 function JSTestPageModuleUI() {
38 var base = JSTestModule();
39 base.addOpenPage = null;
40 base.addClosePage = null;
41 base.parseAction = function(action) {
44 this.addOpenPage(action.data);
48 this.addClosePage(action.data);
56 /* End page specific class */
66 checkF: null //function to check
67 checkInTest: true or false
71 function aaJSDoCommandTest(input) {
72 var base = new JSTest();
74 base._name = input.name;
75 base._contractID = input.contractID;
76 base._CID = input.cid;
78 base._command = input.object.command;
79 base._checkInTest = false;
80 if (input.object.checkInTest) {
81 base._checkInTest = input.object.checkInTest;
84 base._test = function(runner) {
86 this.addJSFailure(runner, "JSDoCommandTest::_test - command is not defined");
88 runner.doCommand(this._command);
89 if (this._checkInTest && this._check) {
94 base._check = input.object.checkF;
101 cid: Components.ID(),
105 command: '' || click: ''
106 checkF: null //function to check
110 function aaJSCommandOpenPageTest(input) {
112 if (input.object.command) {
113 base = aaJSDoCommandTest(input);
114 base.aaJSDoCommandTest_test = base._test;
115 base._test = function(runner) {
117 this.aaJSDoCommandTest_test(runner);
119 this.addJSFailure(runner, "[aaJSCommandOpenPageTest] cann't do command. Exception: " + e);
121 runner.watchWindow = getFrame(runner).contentWindow;
123 } else if(input.object.click) {
125 base._CID = input.cid;
126 base._contractID = input.contractID;
127 base._name = input.name;
129 base._clickID = input.object.click;
131 base._test = function(runner) {
132 sendOnClick(getElement(runner, this._clickID));
133 runner.watchWindow = getFrame(runner).contentWindow;
135 base._check = input.object.checkF;
144 cid: Components.ID(),
146 command: "cmd_view_entity"
151 cid: Components.ID(),
153 command: "cmd_page1_submit",
154 checkF: null //function for check result page
157 example for extended actions:
161 data: null //page specific data
165 function aaJSTestPageModule(pgName) {
166 var base = JSTestPageModuleUI();
168 base._contractIDBase = "@aasii.org/abstract/test/";
169 base._pageName = pgName;
172 base._contractID = base._contractIDBase + base._pageName + "/page;" + base._version;
173 base._name = "aaPage_" + base._pageName;
175 base.generateContractID = function(inner_str) {
176 return this._contractIDBase + this._pageName + "/" + inner_str + ";" + this._version;
179 base.JSTestPage_parseAction = base.parseAction;
180 base.parseAction = function(action) {
181 switch(action.name) {
183 this.addFillTest(action.data);
187 return this.JSTestPage_parseAction(action);
189 base.addCommandPageOpenTest = function(data) {
190 this._add(aaJSCommandOpenPageTest(data));
192 base.addCommandTest = function(data) {
193 this._add(aaJSDoCommandTest(data));
195 base.addFillTest = null;
196 base.checkPage = function(runner) {
197 this.addJSFailure(runner, "aaJSTestPage.checkPage - not implemented");
199 base.addOpenPage = function(data) {
200 data.contractID = this.generateContractID("open" + this._parse_counter + "/" + data.object.command);
201 data.name = "aaPage_" + this._pageName + "_Open" + this._parse_counter + "_" + data.object.command;
202 data.object.checkF = this.checkPage;
203 this.addCommandPageOpenTest(data);
205 base.addClosePage = function(data) {
206 data.contractID = this.generateContractID("close" + this._parse_counter + "/" + data.object.command);
207 data.name = "aaPage_" + this._pageName + "_Close" + this._parse_counter + "_" + data.object.command;
208 this.addCommandPageOpenTest(data);