1 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=javascript: */
3 * Copyright (C) 2007 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 const nsCI = Components.interfaces
22 const moduleName = "aaTestAccountViews";
23 const moduleCID = "{afd38c04-819b-4823-ad6a-22c6d05b3774}";
24 const moduleContractID = "@aasii.org/abstract/test/vc-accounts;1";
26 Components.utils.import("resource:///modules/aaTestVC.jsm");
30 * The NSGetModule function is the magic entry point that XPCOM uses to find
31 * what XPCOM components this module provides
33 function NSGetModule(comMgr, fileSpec)
35 var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
36 .getService(Components.interfaces.mozIJSSubScriptLoader);
37 loader.loadSubScript("resource:///modules/nsTestFrame.jsm");
39 var aaVCTestModule = new JSTestModule();
40 aaVCTestModule.init = ModuleInit;
41 aaVCTestModule.init();
42 return aaVCTestModule;
47 this._name = moduleName;
48 this._CID = Components.ID(moduleCID);
49 this._contractID = moduleContractID;
52 this._add(account_page_CID, account_page_contractID, account_page_name,
53 account_page_test, account_page_check);
55 this._add(transcript_page_CID, transcript_page_contractID,
56 transcript_page_name, transcript_page_test, transcript_page_check);
58 this._add(transcript_flow_CID, transcript_flow_contractID, transcript_flow_name,
59 transcript_flow_test, flow_select_check);
61 this._add(tf_discard_CID, tf_discard_contractID, tf_discard_name,
62 flow_discard_test, transcript_flow_discard_check);
63 this._tests[3].instance.item = 0;
67 this._add(tf_submit_CID, tf_submit_contractID, tf_submit_name,
68 flow_submit_test, transcript_flow_submit_check);
69 this._tests[5].instance.item = 9;
71 this._add(transcript_load_CID, transcript_load_contractID,
72 transcript_load_name, transcript_load_test);
74 this._add(transcript_after_flow_CID, transcript_after_flow_contractID,
75 transcript_after_flow_name, transcript_after_flow_test);
77 this._add(transcript_income_flow_CID, transcript_income_flow_contractID,
78 transcript_income_flow_name, transcript_income_flow_test);
80 this._add(transfer_page_CID, transfer_page_contractID,
81 transfer_page_name, transfer_page_test, transfer_page_check);
83 this._add(transfer_from_CID, transfer_from_contractID, transfer_from_name,
84 transfer_from_test, flow_select_check);
86 this._add(transfer_from_discard_CID, transfer_from_discard_contractID,
87 transfer_from_discard_name, flow_discard_test,
88 transfer_from_discard_check);
89 this._tests[11].instance.item = 0;
93 this._add(transfer_from_submit_CID, transfer_from_submit_contractID,
94 transfer_from_submit_name, flow_submit_test, transfer_from_submit_check);
95 this._tests[13].instance.item = 5;
97 this._add(transfer_to_CID, transfer_to_contractID, transfer_to_name,
98 transfer_to_test, flow_select_check);
100 this._add(transfer_to_discard_CID, transfer_to_discard_contractID,
101 transfer_to_discard_name, flow_discard_test,
102 transfer_to_discard_check);
103 this._tests[15].instance.item = 0;
107 this._add(transfer_to_submit_CID, transfer_to_submit_contractID,
108 transfer_to_submit_name, flow_submit_test, transfer_to_submit_check);
109 this._tests[17].instance.item = 9;
110 this._tests[17].instance.extra = flow_last_line_check;
112 this._add(transfer_save_CID, transfer_save_contractID,
113 transfer_save_name, transfer_save_test);
116 /* Module-specific Defines and Utilities */
117 const contentId = "content";
119 /* Account Page Test */
120 const account_page_contractID = "@aasii.org/abstract/test/account-balance;1";
121 const account_page_name = "aaAccountPageTest";
122 const account_page_CID = Components.ID("{3391fcd8-e122-4e31-9162-f114fe2d843d}");
124 function account_page_test(runner)
126 runner.doCommand("cmd_report_balances");
127 runner.watchWindow = getFrame(runner).contentWindow;
130 function account_page_check(runner)
132 var tree = getElement(runner, "balances.tree");
133 var view = tree.view;
134 var date = getElement(runner, "filter.date");
135 date.value = "2007-09-07";
138 runner.addJSFailure("[balances page] failed");
140 if (view.getCellText(0,tree.columns[3]) != "")
141 runner.addJSFailure("transcript.tree.line1.col4 failed");
142 if (view.getCellText(1,tree.columns[3]) != "")
143 runner.addJSFailure("transcript.tree.line2.col4 failed");
144 if (view.getCellText(2,tree.columns[3]) != "1.00")
145 runner.addJSFailure("transcript.tree.line3.col4 failed");
146 if (view.getCellText(3,tree.columns[3]) != "2400.00")
147 runner.addJSFailure("transcript.tree.line4.col4 failed");
148 if (view.getCellText(4,tree.columns[3]) != "1.00")
149 runner.addJSFailure("transcript.tree.line5.col4 failed");
150 if (view.getCellText(5,tree.columns[3]) != "87920.00")
151 runner.addJSFailure("transcript.tree.line6.col4 failed");
153 if (view.getCellText(0,tree.columns[4]) != "10.00")
154 runner.addJSFailure("transcript.tree.line1.col4 failed");
155 if (view.getCellText(1,tree.columns[4]) != "14.20")
156 runner.addJSFailure("transcript.tree.line2.col4 failed");
157 if (view.getCellText(2,tree.columns[4]) != "")
158 runner.addJSFailure("transcript.tree.line3.col4 failed");
159 if (view.getCellText(3,tree.columns[4]) != "")
160 runner.addJSFailure("transcript.tree.line4.col4 failed");
161 if (view.getCellText(4,tree.columns[4]) != "")
162 runner.addJSFailure("transcript.tree.line5.col4 failed");
163 if (view.getCellText(5,tree.columns[4]) != "")
164 runner.addJSFailure("transcript.tree.line6.col4 failed");
166 getElement(runner, "units.mode").selectedIndex = 1;
168 if (tree.view.getCellText(0,tree.columns[0]) != "equity share 2")
169 runner.addJSFailure("balance.tree.line1.col1 failed");
170 if (tree.view.getCellText(0,tree.columns[1]) != "J. Dow")
171 runner.addJSFailure("balance.tree.line1.col2 failed");
172 if (tree.view.getCellText(0,tree.columns[2]) != "AASI share")
173 runner.addJSFailure("balance.tree.line1.col3 failed");
174 if (tree.view.getCellText(0,tree.columns[3]) != "")
175 runner.addJSFailure("balance.tree.line3.col4 failed");
176 if (tree.view.getCellText(0,tree.columns[4]) != "100000.00")
177 runner.addJSFailure("balance.tree.line1.col5 failed");
178 if (tree.view.getCellText(5,tree.columns[3]) != "87920.00")
179 runner.addJSFailure("balance.tree.line3.col4 failed");
181 if (getElement(runner, "footer.sumDebit").value != "242000.00")
182 runner.addJSFailure("balance.totalAssets is wrong: "
183 + getElement(runner, "footer.sumDebit").value);
184 if (getElement(runner, "footer.sumCredit").value != "242000.00")
185 runner.addJSFailure("balance.totalLiabilities is wrong: "
186 + getElement(runner, "footer.sumCredit").value);
189 /* Transcript Page Test */
190 const transcript_page_contractID = "@aasii.org/abstract/test/account-transcript;1";
191 const transcript_page_name = "aaTranscriptPageTest";
192 const transcript_page_CID = Components.ID("{d7a1753e-7d74-4f8a-940d-317d37c369ee}");
194 function transcript_page_test(runner)
196 runner.doCommand("cmd_report_transcript");
197 runner.watchWindow = getFrame(runner).contentWindow;
200 function transcript_check(runner)
202 if (! getElement(runner, "transcript.tree"))
203 runner.addJSFailure("[transcript page] tree failed");
204 if (! getElement(runner, "filter.flow"))
205 runner.addJSFailure("[transcript page] flow link failed");
208 function transcript_page_check(runner)
210 transcript_check(runner);
211 var tree = getElement(runner, "transcript.tree");
212 // XXX 403202 'Unflexing' the tree speeds up reflow significantly
213 if (tree && tree.hasAttribute("flex"))
214 tree.removeAttribute("flex");
216 getElement(runner, "filter.dateFrom").value = "2007-09-05";
217 sendOnChange(getElement(runner, "filter.dateFrom"));
218 getElement(runner, "filter.dateTo").value = "2007-09-10";
219 sendOnChange(getElement(runner, "filter.dateTo"));
220 if (getElement(runner, "filter.cancel").hasAttribute("collapsed"))
221 runner.addJSFailure("[transcript page] 'change' command");
224 /* ask for flow from transcript page */
225 const transcript_flow_contractID = "@aasii.org/test/transcript-flow;1";
226 const transcript_flow_name = "aaVCTranscriptFlowTest";
227 const transcript_flow_CID = Components.ID("{b4fe65f6-c55e-491c-a039-27c0beff12cc}");
229 function transcript_flow_test(runner)
231 sendOnClick(getElement(runner, "filter.flow"));
232 runner.watchWindow = getFrame(runner).contentWindow;
235 const tf_discard_contractID = "@aasii.org/test/transcript-flow-discard;1";
236 const tf_discard_name = "aaVCTranscriptFlowDiscardTest";
237 const tf_discard_CID = Components.ID("{a122d947-3fb2-4796-87fe-22c67706bd9a}");
239 function transcript_flow_discard_check(runner)
241 transcript_check(runner);
242 if (getElement(runner, "filter.flow").value != "click to choose")
243 runner.addJSFailure("[transcript->flow] discard failed");
246 const tf_submit_contractID = "@aasii.org/test/transcript-flow-submit;1";
247 const tf_submit_name = "aaVCTranscriptFlowSubmitTest";
248 const tf_submit_CID = Components.ID("{3197a8bb-1fd1-453e-98d8-6bc7996552a5}");
250 function transcript_flow_submit_check(runner)
252 transcript_check(runner);
253 if (getElement(runner, "filter.flow").value != "forex deal 4")
254 runner.addJSFailure("[transcript->flow] submit failed");
257 /* submit/discard from flow page */
258 function flow_select_check(runner)
261 var tree = getElement(runner, "page1.tree");
262 // XXX 403202 'Unflexing' the tree speeds up reflow significantly
263 if (tree && tree.hasAttribute("flex"))
264 tree.removeAttribute("flex");
266 if (getAnnoElement(runner, "header", "header.discard")
267 .getAttribute("collapsed") == "true")
268 runner.addJSFailure("flow.discard button should be visible");
269 if (getAnnoElement(runner, "header", "header.submit")
270 .getAttribute("collapsed") == "true")
271 runner.addJSFailure("flow.submit button should be visible");
272 if (getElement(runner, "cmd_page1_discard")
273 .getAttribute("disabled") == "true")
274 runner.addJSFailure("flow_discard command should be enabled");
275 if (getElement(runner, "cmd_page1_submit")
276 .getAttribute("disabled") == "true")
277 runner.addJSFailure("flow_submit command should be enabled");
280 function flow_discard_test(runner)
282 getElement(runner,"page1.tree").view.selection.select(this.item);
283 runner.doCommand("cmd_page1_discard");
284 runner.watchWindow = getFrame(runner).contentWindow;
287 function flow_submit_test(runner)
290 this.item = getElement(runner, "page1.tree").view.rowCount + this.item;
291 getElement(runner,"page1.tree").view.selection.select(this.item);
292 runner.doCommand("cmd_page1_submit");
293 runner.watchWindow = getFrame(runner).contentWindow;
298 function flow_last_line_check(runner)
300 var tree = getElement(runner, "page1.tree");
301 var view = tree.view;
302 if (view.getCellText(view.rowCount - 1, tree.columns[0])
303 != "profit and loss")
304 runner.addJSFailure("[flow page] wrong tag on the last line");
307 /* Transcript Load Test */
308 const transcript_load_contractID = "@aasii.org/abstract/test/transcript-load;1";
309 const transcript_load_name = "aaTranscriptLoadTest";
310 const transcript_load_CID = Components.ID("{335e1a8e-f8a0-4a9d-850b-0404cd2db9e5}");
312 function transcript_load_test(runner)
314 var loadLnk = getElement(runner, "transcript.load");
315 var startDate = getElement(runner, "filter.dateFrom");
316 var endDate = getElement(runner, "filter.dateTo");
317 var tree = getElement(runner, "transcript.tree");
318 var view = tree.view.QueryInterface(nsCI.nsITreeView);
320 sendOnClick(loadLnk);
322 if (getElement(runner, "filter.group").getAttribute("collapsed") != "true")
323 runner.addJSFailure("[transcript load] filter not hidden");
325 if (getElement(runner, "header.flow").value != "forex deal 4")
326 runner.addJSFailure("[transcript load] wrong flow: "
327 + getElement(runner, "header.flow").value);
328 if (getElement(runner, "header.dateFrom").value != "2007-09-05")
329 runner.addJSFailure("[transcript load] [1] wrong 'from' date");
330 if (getElement(runner, "header.sumDebitFrom").value != "0.00")
331 runner.addJSFailure("[transcript load] [1] wrong 'from' debit");
332 if (getElement(runner, "header.sumCreditFrom").value != "0.00")
333 runner.addJSFailure("[transcript load] [1] wrong 'from' credit");
334 if (getElement(runner, "header.dateTo").value != "2007-09-10")
335 runner.addJSFailure("[transcript load] [1] wrong 'to' date");
336 if (getElement(runner, "header.sumDebitTo").value != "0.00")
337 runner.addJSFailure("[transcript load] [1] wrong 'to' debit");
338 if (getElement(runner, "header.sumCreditTo").value != "0.00")
339 runner.addJSFailure("[transcript load] [1] wrong 'to' credit");
341 if (view.getCellText(0,tree.columns[0]) != "2007-09-05")
342 runner.addJSFailure("transcript.tree.line1.col1 failed");
343 if (view.getCellText(1,tree.columns[0]) != "2007-09-05")
344 runner.addJSFailure("transcript.tree.line2.col1 failed");
345 if (view.getCellText(2,tree.columns[0]) != "2007-09-05")
346 runner.addJSFailure("transcript.tree.line3.col1 failed");
347 if (view.getCellText(3,tree.columns[0]) != "2007-09-05")
348 runner.addJSFailure("transcript.tree.line4.col1 failed");
349 if (view.getCellText(4,tree.columns[0]) != "2007-09-10")
350 runner.addJSFailure("transcript.tree.line5.col1 failed");
351 if (view.getCellText(5,tree.columns[0]) != "2007-09-10")
352 runner.addJSFailure("transcript.tree.line6.col1 failed");
354 if (view.getCellText(0,tree.columns[1]) != "bank account 2")
355 runner.addJSFailure("transcript.tree.line1.col2 failed");
356 if (view.getCellText(1,tree.columns[1]) != "bank account 1")
357 runner.addJSFailure("transcript.tree.line2.col2 failed");
358 if (view.getCellText(2,tree.columns[1]) != "bank account 2")
359 runner.addJSFailure("transcript.tree.line3.col2 failed");
360 if (view.getCellText(3,tree.columns[1]) != "bank account 1")
361 runner.addJSFailure("transcript.tree.line4.col2 failed");
362 if (view.getCellText(4,tree.columns[1]) != "bank account 1")
363 runner.addJSFailure("transcript.tree.line5.col2 failed");
364 if (view.getCellText(5,tree.columns[1]) != "profit and loss")
365 runner.addJSFailure("transcript.tree.line6.col2 failed");
367 if (view.getCellText(0,tree.columns[2]) != "2000.00")
368 runner.addJSFailure("transcript.tree.line1.col3 failed");
369 if (view.getCellText(1,tree.columns[2]) != "")
370 runner.addJSFailure("transcript.tree.line2.col3 failed");
371 if (view.getCellText(2,tree.columns[2]) != "600.00")
372 runner.addJSFailure("transcript.tree.line3.col3 failed");
373 if (view.getCellText(3,tree.columns[2]) != "")
374 runner.addJSFailure("transcript.tree.line4.col3 failed");
375 if (view.getCellText(4,tree.columns[2]) != "")
376 runner.addJSFailure("transcript.tree.line5.col3 failed");
377 if (view.getCellText(5,tree.columns[2]) != "400.00")
378 runner.addJSFailure("transcript.tree.line6.col3 failed");
380 if (view.getCellText(0,tree.columns[3]) != "")
381 runner.addJSFailure("transcript.tree.line1.col4 failed");
382 if (view.getCellText(1,tree.columns[3]) != "87375.00")
383 runner.addJSFailure("transcript.tree.line2.col4 failed");
384 if (view.getCellText(2,tree.columns[3]) != "")
385 runner.addJSFailure("transcript.tree.line3.col4 failed");
386 if (view.getCellText(3,tree.columns[3]) != "3495.00")
387 runner.addJSFailure("transcript.tree.line4.col4 failed");
388 if (view.getCellText(4,tree.columns[3]) != "13980.00")
389 runner.addJSFailure("transcript.tree.line5.col4 failed");
390 if (view.getCellText(5,tree.columns[3]) != "")
391 runner.addJSFailure("transcript.tree.line6.col4 failed");
393 getElement(runner, "units.mode").selectedIndex = 1;
395 if (view.getCellText(0,tree.columns[2]) != "69900.00")
396 runner.addJSFailure("transcript.tree.line1.col3 failed");
397 if (view.getCellText(1,tree.columns[2]) != "")
398 runner.addJSFailure("transcript.tree.line2.col3 failed");
399 if (view.getCellText(2,tree.columns[2]) != "20970.00")
400 runner.addJSFailure("transcript.tree.line3.col3 failed");
401 if (view.getCellText(3,tree.columns[2]) != "")
402 runner.addJSFailure("transcript.tree.line4.col3 failed");
403 if (view.getCellText(4,tree.columns[2]) != "")
404 runner.addJSFailure("transcript.tree.line5.col3 failed");
405 if (view.getCellText(5,tree.columns[2]) != "13980.00")
406 runner.addJSFailure("transcript.tree.line6.col3 failed");
408 if (view.getCellText(0,tree.columns[3]) != "")
409 runner.addJSFailure("transcript.tree.line1.col4 failed");
410 if (view.getCellText(1,tree.columns[3]) != "87375.00")
411 runner.addJSFailure("transcript.tree.line2.col4 failed");
412 if (view.getCellText(2,tree.columns[3]) != "")
413 runner.addJSFailure("transcript.tree.line3.col4 failed");
414 if (view.getCellText(3,tree.columns[3]) != "3495.00")
415 runner.addJSFailure("transcript.tree.line4.col4 failed");
416 if (view.getCellText(4,tree.columns[3]) != "13980.00")
417 runner.addJSFailure("transcript.tree.line5.col4 failed");
418 if (view.getCellText(5,tree.columns[3]) != "")
419 runner.addJSFailure("transcript.tree.line6.col4 failed");
422 /* Tests for Flow-in-Transcript-Selection bug #122 */
423 const transcript_after_flow_contractID = "@aasii.org/abstract/test/trasncript-after-flow;1";
424 const transcript_after_flow_name = "aaTranscriptAfterFlowP1";
425 const transcript_after_flow_CID = Components.ID("{b9c0df9d-6036-43c7-b0b4-d4e2f3092601}");
427 function transcript_after_flow_test(runner)
429 var flows = getFrame(runner).docShell.QueryInterface(nsCI.nsIWebNavigation)
430 .sessionHistory.createQuery("@aasii.org/storage/load-flow;1")
431 .QueryInterface(nsCI.aaILoadQuery);
433 getFrame(runner).contentWindow.wrappedJSObject.gReport.flow = flows
434 .queryElementAt(3, nsCI.aaIFlow);
436 var tree = getElement(runner, "transcript.tree");
437 var view = tree.view.QueryInterface(nsCI.nsITreeView);
439 if (view.getCellText(2,tree.columns[1]) != "bank account 2")
440 runner.addJSFailure("transcript.tree.line3.col2 failed");
443 /* Tests for income-flow display */
444 const transcript_income_flow_contractID = "@aasii.org/abstract/test/trasncript-income-flow;1";
445 const transcript_income_flow_name = "aaTranscriptIncomeFlowP1";
446 const transcript_income_flow_CID = Components.ID("{07f18646-a3be-4ab5-9edd-7b2b899f00b8}");
448 function transcript_income_flow_test(runner)
450 var loadLnk = getElement(runner, "transcript.load");
451 var startDate = getElement(runner, "filter.dateFrom");
452 var endDate = getElement(runner, "filter.dateTo");
453 var tree = getElement(runner, "transcript.tree");
454 var view = tree.view.QueryInterface(nsCI.nsITreeView);
456 getFrame(runner).contentWindow.wrappedJSObject.gReport.flow =
457 Components.classes["@aasii.org/base/income-flow;1"]
458 .createInstance(nsCI.aaIFlow);
460 startDate.value = "2007-08-28";
461 endDate.value = "2007-09-10";
463 sendOnClick(loadLnk);
465 if (getElement(runner, "header.dateFrom").value != "2007-08-28")
466 runner.addJSFailure("[transcript load] [2] wrong 'from' date");
467 if (getElement(runner, "header.sumDebitFrom").value != "0.00")
468 runner.addJSFailure("[transcript load] [2] wrong 'from' debit");
469 if (getElement(runner, "header.sumCreditFrom").value != "0.00")
470 runner.addJSFailure("[transcript load] [2] wrong 'from' credit");
471 if (getElement(runner, "header.dateTo").value != "2007-09-10")
472 runner.addJSFailure("[transcript load] [2] wrong 'to' date");
473 if (getElement(runner, "header.sumDebitTo").value != "0.00")
474 runner.addJSFailure("[transcript load] [2] wrong 'to' debit");
475 if (getElement(runner, "header.sumCreditTo").value != "300.00")
476 runner.addJSFailure("[transcript load] [2] wrong 'to' credit");
477 if (view.rowCount != 8)
478 runner.addJSFailure("[transcript load] [2] line count");
480 if (view.getCellText(0,tree.columns[0]) != "2007-08-31")
481 runner.addJSFailure("transcript.tree.line1.col1 failed");
482 if (view.getCellText(1,tree.columns[0]) != "2007-08-31")
483 runner.addJSFailure("transcript.tree.line2.col1 failed");
484 if (view.getCellText(2,tree.columns[0]) != "2007-09-05")
485 runner.addJSFailure("transcript.tree.line3.col1 failed");
486 if (view.getCellText(3,tree.columns[0]) != "2007-09-05")
487 runner.addJSFailure("transcript.tree.line3.col1 failed");
488 if (view.getCellText(4,tree.columns[0]) != "2007-09-06")
489 runner.addJSFailure("transcript.tree.line3.col1 failed");
490 if (view.getCellText(5,tree.columns[0]) != "2007-09-07")
491 runner.addJSFailure("transcript.tree.line3.col1 failed");
492 if (view.getCellText(6,tree.columns[0]) != "2007-09-10")
493 runner.addJSFailure("transcript.tree.line3.col1 failed");
494 if (view.getCellText(7,tree.columns[0]) != "2007-09-10")
495 runner.addJSFailure("transcript.tree.line3.col1 failed");
497 if (view.getCellText(0,tree.columns[1]) != "forex deal 2")
498 runner.addJSFailure("transcript.tree.line1.col2 failed");
499 if (view.getCellText(1,tree.columns[1]) != "rented office 1")
500 runner.addJSFailure("transcript.tree.line2.col2 failed");
501 if (view.getCellText(2,tree.columns[1]) != "forex deal 4")
502 runner.addJSFailure("transcript.tree.line3.col2 failed");
503 if (view.getCellText(3,tree.columns[1]) != "forex deal 4")
504 runner.addJSFailure("transcript.tree.line3.col2 failed");
505 if (view.getCellText(4,tree.columns[1]) != "bank account 1")
506 runner.addJSFailure("transcript.tree.line3.col2 failed");
507 if (view.getCellText(5,tree.columns[1]) != "bank account 1")
508 runner.addJSFailure("transcript.tree.line3.col2 failed");
509 if (view.getCellText(6,tree.columns[1]) != "bank account 2")
510 runner.addJSFailure("transcript.tree.line3.col2 failed");
511 if (view.getCellText(7,tree.columns[1]) != "forex deal 4")
512 runner.addJSFailure("transcript.tree.line3.col2 failed");
514 if (view.getCellText(0,tree.columns[2]) != "")
515 runner.addJSFailure("transcript.tree.line1.col3 failed");
516 if (view.getCellText(1,tree.columns[2]) != "2000.00")
517 runner.addJSFailure("transcript.tree.line2.col3 failed");
518 if (view.getCellText(2,tree.columns[2]) != "")
519 runner.addJSFailure("transcript.tree.line3.col3 failed");
520 if (view.getCellText(3,tree.columns[2]) != "")
521 runner.addJSFailure("transcript.tree.line3.col3 failed");
522 if (view.getCellText(4,tree.columns[2]) != "50.00")
523 runner.addJSFailure("transcript.tree.line3.col3 failed");
524 if (view.getCellText(5,tree.columns[2]) != "")
525 runner.addJSFailure("transcript.tree.line3.col3 failed");
526 if (view.getCellText(6,tree.columns[2]) != "13680.00")
527 runner.addJSFailure("transcript.tree.line3.col3 failed");
528 if (view.getCellText(7,tree.columns[2]) != "")
529 runner.addJSFailure("transcript.tree.line3.col3 failed");
531 if (view.getCellText(0,tree.columns[3]) != "50.00")
532 runner.addJSFailure("transcript.tree.line1.col4 failed");
533 if (view.getCellText(1,tree.columns[3]) != "")
534 runner.addJSFailure("transcript.tree.line2.col4 failed");
535 if (view.getCellText(2,tree.columns[3]) != "1500.00")
536 runner.addJSFailure("transcript.tree.line3.col4 failed");
537 if (view.getCellText(3,tree.columns[3]) != "450.00")
538 runner.addJSFailure("transcript.tree.line3.col4 failed");
539 if (view.getCellText(4,tree.columns[3]) != "")
540 runner.addJSFailure("transcript.tree.line3.col4 failed");
541 if (view.getCellText(5,tree.columns[3]) != "50.00")
542 runner.addJSFailure("transcript.tree.line3.col4 failed");
543 if (view.getCellText(6,tree.columns[3]) != "")
544 runner.addJSFailure("transcript.tree.line3.col4 failed");
545 if (view.getCellText(7,tree.columns[3]) != "13980.00")
546 runner.addJSFailure("transcript.tree.line3.col4 failed");
549 /* Transfer Page Test */
550 const transfer_page_contractID = "@aasii.org/abstract/test/account-transfer;1";
551 const transfer_page_name = "aaTransferPageTest";
552 const transfer_page_CID = Components.ID("{950daefb-95ba-4960-a11a-b88af6cf6cad}");
554 function transfer_page_test(runner)
556 runner.doCommand("cmd_process_transfer");
557 runner.watchWindow = getFrame(runner).contentWindow;
560 function transfer_sync_check(runner)
562 var wnd = getFrame(runner).contentWindow.wrappedJSObject;
565 runner.addJSFailure("[transfer sync] getting window");
570 runner.addJSFailure("[transfer sync] getting fact object");
574 if (getElement(runner, "transfer.fromFlow").value != (wnd.gFact.takeFrom ?
575 wnd.gFact.takeFrom.tag : "click to choose")) {
576 runner.addJSFailure(" 'fromFlow.tag' is wrong:" + getElement(runner,
577 "transfer.fromFlow").value);
581 if (getElement(runner, "transfer.toFlow").value != (wnd.gFact.giveTo ?
582 wnd.gFact.giveTo.tag : "click to choose")) {
583 runner.addJSFailure(" 'toFlow.tag' is wrong: " + getElement(runner,
584 "transfer.toFlow").value);
588 if (getElement(runner, "transfer.amount").value != wnd.gFact.amount) {
589 runner.addJSFailure(" 'amount' is wrong: " + getElement(runner,
590 "transfer.amount").value);
594 var time = new Date(wnd.gEvent.time / 1000);
595 if (getElement(runner, "transfer.date").value != time
596 .toLocaleFormat('%Y-%m-%d')) {
597 runner.addJSFailure(" 'date' is wrong: " + getElement(runner,
598 "transfer.date").value + " - " + time.toLocaleFormat('%Y-%m-%d'));
602 if (getElement(runner, "transfer.value").value != wnd.gTransaction.value) {
603 runner.addJSFailure(" 'value' is wrong: " + getElement(runner,
604 "transfer.value").value);
611 function transfer_check(runner)
614 if (getFrame(runner).docShell.QueryInterface(nsCI.nsIWebNavigation)
615 .currentURI.spec != "chrome://abstract/content/transfer.xul") {
616 runner.addJSFailure(" [transfer] wrong xul document");
619 if (! transfer_sync_check(runner)) {
620 runner.addJSFailure(" [transfer] page out of sync");
627 function transfer_page_check(runner)
629 if (! transfer_check(runner))
630 runner.addJSFailure("[transfer page] wrong initialization");
632 if (getElement(runner, "transfer.amount").value != "0")
633 runner.addJSFailure(" 'amount' is wrong: " + getElement(runner,
634 "transfer.amount").value);
636 var junk = Components.classes["@aasii.org/base/flow;1"].createInstance(nsCI.aaIFlow);
638 var wnd = getFrame(runner).contentWindow.wrappedJSObject;
639 wnd.gFact.takeFrom = junk;
640 wnd.gFact.giveTo = junk;
643 /* ask for 'from' flow from transfer page */
644 const transfer_from_contractID = "@aasii.org/test/transfer-from;1";
645 const transfer_from_name = "aaVCTransferFromTest";
646 const transfer_from_CID = Components.ID("{7ad5abf7-53b9-468d-b50c-4d9614a9dc14}");
648 function transfer_from_test(runner)
650 sendOnClick(getElement(runner, "transfer.fromFlow"));
651 runner.watchWindow = getFrame(runner).contentWindow;
654 const transfer_from_discard_contractID = "@aasii.org/test/transfer-from-discard;1";
655 const transfer_from_discard_name = "aaVCTransferFromDiscardTest";
656 const transfer_from_discard_CID = Components.ID("{ca063e94-1b9c-4e53-bf25-9fa8af605def}");
658 function transfer_from_discard_check(runner)
660 if (! transfer_check(runner))
661 runner.addJSFailure("[transfer->fromFlow] wrong init");
663 if (getElement(runner, "transfer.fromFlow").value != "junk")
664 runner.addJSFailure("[transfer->fromFlow] discard failed");
667 const transfer_from_submit_contractID = "@aasii.org/test/transfer-from-submit;1";
668 const transfer_from_submit_name = "aaVCTransferFromSubmitTest";
669 const transfer_from_submit_CID = Components.ID("{aaf7ec49-e9aa-45a8-b630-56b6659fa6ad}");
671 function transfer_from_submit_check(runner)
673 if (! transfer_check(runner))
674 runner.addJSFailure("[transfer->fromFlow] wrong page init");
676 if (getElement(runner, "transfer.fromFlow").value != "bank account 2")
677 runner.addJSFailure("[transfer->fromFlow] submit failed:"
678 + getElement(runner, "transfer.fromFlow").value);
681 /* ask for 'to' flow from transfer page */
682 const transfer_to_contractID = "@aasii.org/test/transfer-to;1";
683 const transfer_to_name = "aaVCTransferToTest";
684 const transfer_to_CID = Components.ID("{3c13bbbd-927b-4b67-be0a-2f80691bed1e}");
686 function transfer_to_test(runner)
688 sendOnClick(getElement(runner, "transfer.toFlow"));
689 runner.watchWindow = getFrame(runner).contentWindow;
692 const transfer_to_discard_contractID = "@aasii.org/test/transfer-to-discard;1";
693 const transfer_to_discard_name = "aaVCTransferToDiscardTest";
694 const transfer_to_discard_CID = Components.ID("{a04d7093-663b-4c24-9c96-028c67b89df3}");
696 function transfer_to_discard_check(runner)
698 if (! transfer_check(runner))
699 runner.addJSFailure("[transfer->toFlow] wrong init");
701 if (getElement(runner, "transfer.toFlow").value != "junk")
702 runner.addJSFailure("[transfer->toFlow] discard failed");
705 const transfer_to_submit_contractID = "@aasii.org/test/transfer-to-submit;1";
706 const transfer_to_submit_name = "aaVCTransferToSubmitTest";
707 const transfer_to_submit_CID = Components.ID("{e827d4c8-89c6-4f19-8df3-0bc2c70f658b}");
709 function transfer_to_submit_check(runner)
711 if (! transfer_check(runner))
712 runner.addJSFailure("[transfer->toFlow] wrong page init");
714 if (getElement(runner, "transfer.toFlow").value != "forex deal 4")
715 runner.addJSFailure("[transfer->toFlow] submit failed:"
716 + getElement(runner, "transfer.toFlow").value);
719 /* ask for 'to' flow from transfer page */
720 const transfer_save_contractID = "@aasii.org/test/transfer-save;1";
721 const transfer_save_name = "aaVCTransferSaveTest";
722 const transfer_save_CID = Components.ID("{bcb12042-4b82-4e71-949b-228b444e344c}");
724 function transfer_save_test(runner)
726 getElement(runner, "transfer.amount").value = "200";
727 sendOnInput(getElement(runner, "transfer.amount"));
728 if (! transfer_sync_check(runner))
729 runner.addJSFailure(" [transfer save] page out of sync");
730 getElement(runner, "transfer.date").value = "2007-09-10";
731 sendOnChange(getElement(runner, "transfer.date"));
732 if (! transfer_sync_check(runner))
733 runner.addJSFailure(" [transfer save] page out of sync");
734 sendOnClick(getElement(runner, "transfer.commit"));
735 if (! transfer_sync_check(runner))
736 runner.addJSFailure(" [transfer save] page out of sync");
737 if (getElement(runner, "transfer.value").value != "6990.00")
738 runner.addJSFailure(" [transfer save] wrong value:" + getElement(runner,
739 "transfer.value").value);