test: added ui test utils module
[abstract.git] / app / test / aaTestRules.js
blob92de810c1ca93ad7e8a974297a1550d53c847011
1 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=javascript: */
2 /*
3  * Copyright (C) 2008 Sergey Yanovich <ynvich@gmail.com>
4  *
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.
9  *
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.
14  *
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.
19  */
21 const nsCI                   = Components.interfaces;
22 const moduleName             = "aaTestRules";
23 const moduleCID              = "{ea4a8e7c-fe3a-4388-9e46-493f3b504a67}";
24 const moduleContractID       = "@aasii.org/abstract/test/vc-rules;1";
26 Components.utils.import("resource:///modules/aaTestVC.jsm");
27 Components.utils.import("resource:///modules/aaUITestUtils.jsm");
30  * Module entry point
31  * The NSGetModule function is the magic entry point that XPCOM uses to find
32  * what XPCOM components this module provides
33  */
34 function NSGetModule(comMgr, fileSpec)
36   var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
37     .getService(Components.interfaces.mozIJSSubScriptLoader);
38   loader.loadSubScript("resource:///modules/nsTestFrame.jsm");
40   var aaVCTestModule = new JSTestModule();
41   aaVCTestModule.init = ModuleInit;
42   aaVCTestModule.init();
43   return aaVCTestModule;
46 function ModuleInit()
48   this._name = moduleName;
49   this._CID = Components.ID(moduleCID);
50   this._contractID = moduleContractID;
52   /*  0 */
53   this._add(flow_page_CID, flow_page_contractID,
54       flow_page_name, flow_page_test, flow_page_check);
55   /*  1 */
56   this._add(rule_page_CID, rule_page_contractID,
57       rule_page_name, rule_page_test, rule_page_check);
60 /* Flow Page Test */
61 const flow_page_contractID = "@aasii.org/abstract/test/rules/flow-page;1";
62 const flow_page_name = "aaRulesFlowPageTest";
63 const flow_page_CID = Components.ID("{60d395e4-fe4d-459c-b910-b45593011936}");
65 function flow_page_test(runner)
67   runner.doCommand("cmd_process_flow");
68   runner.watchWindow = getFrame(runner).contentWindow;
71 const rulesId = "flow.rules";
73 function flow_page_check(runner)
75   var tree = getElement(runner,"page1.tree");
76   // XXX 403202 'Unflexing' the tree speeds up reflow significantly
77   if (tree && tree.hasAttribute("flex"))
78     tree.removeAttribute("flex");
80   flow_check(runner);
81   if (getAnnoElement(runner, "header", "header.discard")
82       .getAttribute("collapsed") != "true")
83     runner.addJSFailure("flow.discard button should be invisible");
84   if (getAnnoElement(runner, "header", "header.submit")
85       .getAttribute("collapsed") != "true")
86     runner.addJSFailure("flow.submit button should be invisible");
87   if (getElement(runner, "cmd_page1_discard")
88       .getAttribute("disabled") != "true")
89     runner.addJSFailure("flow_discard command should be disabled");
90   if (getElement(runner, "cmd_page1_submit")
91       .getAttribute("disabled") != "true")
92     runner.addJSFailure("flow_submit command should be disabled");
93   
94   var rules = getElement(runner, rulesId);
95   if (!rules)
96     runner.addJSFailure("flow page: no rules link");
98   tree.view.selection.select(0);
99   if (rules.getAttribute("disabled") != "true")
100     runner.addJSFailure("flow page: rules link is not disabled");
102   runner.doCommand("cmd_page1_new");
103   if (! flow_check(runner))
104     runner.addJSFailure("[flow] page not synched");
106   if (rules.getAttribute("disabled") == "true")
107     runner.addJSFailure("flow page: rules link is not enabled");
110 /* Rule Page Test */
111 const rule_page_contractID = "@aasii.org/abstract/test/rules/rule-page;1";
112 const rule_page_name = "aaRulePageTest";
113 const rule_page_CID = Components.ID("{57b88273-87fb-4ae8-bac9-6599b63187be}");
115 function rule_page_test(runner)
117   sendOnClick(getElement(runner, rulesId));
118   runner.watchWindow = getFrame(runner).contentWindow;
121 function rule_page_check(runner)
123   if (!rule_check(runner))
124     runner.addJSFailure("rule page: wrong state");