|
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 var view = |
|
7 { |
|
8 onRun : function() |
|
9 { |
|
10 runQueue.mArray = new Array(); |
|
11 var sels = this.boxObject.view.selection,a=new Object(),b=new Object(),k; |
|
12 var rowResource, name, path; |
|
13 for (k=0;k<sels.getRangeCount();k++){ |
|
14 sels.getRangeAt(k,a,b); |
|
15 for (var l=a.value;l<=b.value;l++) { |
|
16 rowResource = this.builder.getResourceAtIndex(l); |
|
17 itemCache.getItem(rowResource); |
|
18 } |
|
19 } |
|
20 runQueue.run(); |
|
21 }, |
|
22 displayTest : function() |
|
23 { |
|
24 var current = this.boxObject.view.selection.currentIndex; |
|
25 var rowResource = this.builder.getResourceAtIndex(current); |
|
26 var item = itemCache.getItem(rowResource); |
|
27 }, |
|
28 browseForRDF : function() |
|
29 { |
|
30 var fp = doCreateRDFFP('Xalan Description File', |
|
31 nsIFilePicker.modeOpen); |
|
32 var res = fp.show(); |
|
33 |
|
34 if (res == nsIFilePicker.returnOK) { |
|
35 var furl = fp.fileURL; |
|
36 this.setDataSource(fp.fileURL.spec); |
|
37 } |
|
38 }, |
|
39 dump_Good : function() |
|
40 { |
|
41 var enumi = this.mResultDS.GetSources(krTypeSucc, kGood, true); |
|
42 var k = 0; |
|
43 while (enumi.hasMoreElements()) { |
|
44 k += 1; |
|
45 dump(enumi.getNext().QueryInterface(nsIRDFResource).Value+"\n"); |
|
46 } |
|
47 dump("found "+k+" good tests\n"); |
|
48 }, |
|
49 prune_ds : function() |
|
50 { |
|
51 if (this.mResultDS) { |
|
52 this.mResultDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep(); |
|
53 } |
|
54 regressionStats.init() |
|
55 itemCache.mArray = new Array(); |
|
56 }, |
|
57 setDataSource : function(aSpec) |
|
58 { |
|
59 var baseSpec; |
|
60 if (aSpec) { |
|
61 baseSpec = aSpec; |
|
62 } |
|
63 else { |
|
64 baseSpec = document.getElementById("xalan_rdf").value; |
|
65 } |
|
66 if (this.mXalanDS && this.mXalanDS.URI == baseSpec) { |
|
67 this.mXalanDS.QueryInterface(nsIRDFRemoteDataSource); |
|
68 this.mXalanDS.Refresh(true); |
|
69 } |
|
70 else { |
|
71 if (this.mXalanDS) { |
|
72 this.database.RemoveDataSource(view.mXalanDS); |
|
73 } |
|
74 this.mXalanDS = kRDFSvc.GetDataSourceBlocking(baseSpec); |
|
75 if (!this.mXalanDS) { |
|
76 alert("Unable do load DataSource: "+baseSpec); |
|
77 return; |
|
78 } |
|
79 this.database.AddDataSource(this.mXalanDS); |
|
80 } |
|
81 regressionStats.init(); |
|
82 if (!this.mResultDS) { |
|
83 this.mResultDS = doCreate(kRDFInMemContractID, |
|
84 nsIRDFDataSource); |
|
85 this.database.AddDataSource(view.mResultDS); |
|
86 if (!this.mResultDS) { |
|
87 alert("Unable to create result InMemDatasource"); |
|
88 return; |
|
89 } |
|
90 } |
|
91 |
|
92 this.builder.rebuild(); |
|
93 document.getElementById("xalan_rdf").value = baseSpec; |
|
94 runItem.prototype.kXalan.init(runItem.prototype.kXalan.URLTYPE_STANDARD, |
|
95 0, baseSpec, null, null); |
|
96 }, |
|
97 loadHtml : function(aUrl, aListener) |
|
98 { |
|
99 const nsIIRequestor = Components.interfaces.nsIInterfaceRequestor; |
|
100 const nsIWebProgress = Components.interfaces.nsIWebProgress; |
|
101 var req = this.mIframe.webNavigation.QueryInterface(nsIIRequestor); |
|
102 var prog = req.getInterface(nsIWebProgress); |
|
103 prog.addProgressListener(aListener, nsIWebProgress.NOTIFY_ALL); |
|
104 this.mIframe.webNavigation.loadURI(aUrl, 0,null,null,null); |
|
105 }, |
|
106 fillItemContext : function() |
|
107 { |
|
108 var index = view.boxObject.view.selection.currentIndex; |
|
109 var res = view.builder.getResourceAtIndex(index); |
|
110 var purp = view.mXalanDS.GetTarget(res, krTypePurp, true); |
|
111 return (purp != null); |
|
112 } |
|
113 } |
|
114 |
|
115 regressionStats = |
|
116 { |
|
117 observe: function(aSubject, aTopic, aData) |
|
118 { |
|
119 if (aTopic != 'success') { |
|
120 return; |
|
121 } |
|
122 var arc = (aData == "true") ? krTypeSuccCount : krTypeFailCount; |
|
123 this.assertNewCount(aSubject, arc, 1); |
|
124 }, |
|
125 init: function() |
|
126 { |
|
127 if (this.mRegressionDS) { |
|
128 this.mRegressionDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep(); |
|
129 } |
|
130 else { |
|
131 this.mRegressionDS = |
|
132 doCreate(kRDFInMemContractID, nsIRDFDataSource); |
|
133 view.database.AddDataSource(this.mRegressionDS); |
|
134 } |
|
135 }, |
|
136 getParent: function(aDS, aSource) |
|
137 { |
|
138 // parent chached? |
|
139 var parent = this.mRegressionDS.GetTarget(aSource, krTypeParent, true); |
|
140 if (!parent) { |
|
141 var labels = view.mXalanDS.ArcLabelsIn(aSource); |
|
142 while (labels.hasMoreElements()) { |
|
143 var arc = labels.getNext().QueryInterface(nsIRDFResource); |
|
144 if (arc.Value.match(this.mChildRE)) { |
|
145 parent = view.mXalanDS.GetSource(arc, aSource, true); |
|
146 // cache the parent |
|
147 this.mRegressionDS.Assert(aSource, krTypeParent, |
|
148 parent, true); |
|
149 } |
|
150 } |
|
151 } |
|
152 return parent; |
|
153 }, |
|
154 assertNewCount: function(aSource, aArc, aIncrement) |
|
155 { |
|
156 var root = kRDFSvc.GetResource('urn:root'); |
|
157 var count = 0; |
|
158 // parent chached? |
|
159 var parent = this.getParent(view.XalanDS, aSource); |
|
160 while (parent && !parent.EqualsNode(root)) { |
|
161 var countRes = view.mResultDS.GetTarget(parent, aArc, true); |
|
162 if (countRes) { |
|
163 count = countRes.QueryInterface(nsIRDFInt).Value; |
|
164 } |
|
165 var newCountRes = kRDFSvc.GetIntLiteral(count + aIncrement); |
|
166 if (!newCountRes) { |
|
167 return; |
|
168 } |
|
169 |
|
170 if (countRes) { |
|
171 view.mResultDS.Change(parent, aArc, countRes, newCountRes); |
|
172 } |
|
173 else { |
|
174 view.mResultDS.Assert(parent, aArc, newCountRes, true); |
|
175 } |
|
176 parent = this.getParent(view.XalanDS, parent); |
|
177 } |
|
178 }, |
|
179 mRegressionDS: 0, |
|
180 mChildRE: /http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#_/ |
|
181 } |
|
182 |
|
183 function rdfObserve(aSubject, aTopic, aData) |
|
184 { |
|
185 if (aTopic == "success") { |
|
186 var target = (aData == "true") ? kGood : kBad; |
|
187 view.mResultDS.Assert(aSubject, krTypeSucc, target, true); |
|
188 |
|
189 regressionStats.observe(aSubject, aTopic, aData); |
|
190 } |
|
191 } |
|
192 |
|
193 runItem.prototype.kObservers.push(rdfObserve); |