Project

Profile

Help

How to connect?
Download (10.7 KB) Statistics
| Branch: | Tag: | Revision:

he / tags / 9.6.0.7 / hen / csource / samples / TestRunnerForm.cs @ aa733b18

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Text;
7
using System.Windows.Forms;
8
using Microsoft.Win32;
9

    
10
namespace TestRunner
11
{
12
    public partial class TestRunnerForm : Form
13
    {
14
        public TestRunnerForm()
15
        {
16
            InitializeComponent();
17
        }
18

    
19
        private void selectSourceButtonClick(object sender, EventArgs e)
20
        {
21
            if (selectTestSourceFolder.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
22
                testSourceDirectory.Text = selectTestSourceFolder.SelectedPath;
23
                RegistryKey regKey = Registry.CurrentUser;
24
                regKey = regKey.CreateSubKey("Software\\Saxonica\\Saxon.Net\\TestRunner");
25
                if (testSuite.Text == "XSLT Test Suite") {
26
                    regKey.SetValue("XSLTTestDir", selectTestSourceFolder.SelectedPath);
27
                }
28
                else if (testSuite.Text == "XSLT 3.0 Test Suite")
29
                {
30
                    regKey.SetValue("XSLT30TestDir", selectTestSourceFolder.SelectedPath);
31
                }
32
                else if (testSuite.Text == "XQuery Test Suite")
33
                {
34
                    regKey.SetValue("XQueryTestDir", selectTestSourceFolder.SelectedPath);
35
                }
36
                else if (testSuite.Text == "XML Schema Test Suite")
37
                {
38
                    regKey.SetValue("SchemaTestDir", selectTestSourceFolder.SelectedPath);
39
                }
40
                else if (testSuite.Text == "FO Test Suite")
41
                {
42
                    regKey.SetValue("FOTestDir", selectTestSourceFolder.SelectedPath);
43
                }
44
            }
45
        }
46

    
47
        private void clickRunButton(object sender, EventArgs e)
48
        {
49
            FeedbackListener f = new FeedbackListener();
50
            f.doneLabel = doneLabel;
51
            f.progressBar = progressBar1;
52
            f.monitor = monitor;
53
            doneLabel.Text = "";
54
            progressBar1.Value = 0;
55
            runButton.Enabled = false;
56

    
57
            if (testSuite.Text == "XSLT Test Suite") {
58
                XsltTestSuiteDriver driver = new XsltTestSuiteDriver();
59
                driver.setFeedbackListener(f);
60
                driver.go(
61
                    new String[]{testSourceDirectory.Text, testNamePattern.Text});
62
            }
63
            else if (testSuite.Text == "XQuery Test Suite")
64
            {
65
                XQueryTestSuiteDriver driver = new XQueryTestSuiteDriver();
66
                driver.setFeedbackListener(f);
67
                driver.go(
68
                    new String[] { testSourceDirectory.Text, resultsDirectory.Text, testNamePattern.Text });
69
            }
70
            else if (testSuite.Text == "XML Schema Test Suite")
71
            {
72
                SchemaTestSuiteDriver driver = new SchemaTestSuiteDriver();
73
                driver.setFeedbackListener(f);
74
                driver.go(
75
                    new String[] { testSourceDirectory.Text, "-g:" + testNamePattern.Text });
76
            }
77
            else if (testSuite.Text == "FO Test Suite")
78
            {
79
                RegistryKey regKey = Registry.CurrentUser;
80
                regKey = regKey.CreateSubKey("Software\\Saxonica\\Saxon.Net\\TestRunner");
81
                regKey.SetValue("TestCaseName", testNamePattern.Text);
82
                regKey.SetValue("TestSetName", testSetNamePattern.Text);
83
                string debugStr = (debugCheckBox.Checked ? "-debug" : "");
84
                string bytecodeStr = (byteCodeCheckBox.Checked ? "on" : "off");
85
                bytecodeStr = (byteCodeCheckBox.Checked && debugCheckBox.Checked ? "debug" : bytecodeStr);
86
                FOTestSuiteDriver driver = new FOTestSuiteDriver();
87
                driver.setFeedbackListener(f);
88
                driver.go(
89
                    new String[] { testSourceDirectory.Text, resultsDirectory.Text, (testNamePattern.TextLength > 0 ? "-t:"+testNamePattern.Text: ""), (testSetNamePattern.TextLength > 0 ? "-s:"+testSetNamePattern.Text : ""), debugStr, "-bytecode:"+bytecodeStr, "-lang:"+langComboBox.Text });
90
            } else if (testSuite.Text == "XSLT 3.0 Test Suite")
91
            {
92
                RegistryKey regKey = Registry.CurrentUser;
93
                regKey = regKey.CreateSubKey("Software\\Saxonica\\Saxon.Net\\TestRunner");
94
                regKey.SetValue("TestCaseName", testNamePattern.Text);
95
                regKey.SetValue("TestSetName", testSetNamePattern.Text);
96
                string debugStr = (debugCheckBox.Checked ? "-debug" : "");
97
                string bytecodeStr = (byteCodeCheckBox.Checked ? "on" : "off");
98
                bytecodeStr = (byteCodeCheckBox.Checked && debugCheckBox.Checked ? "debug" : bytecodeStr);
99
                Xslt30TestSuiteDriver driver = new Xslt30TestSuiteDriver();
100
                driver.setFeedbackListener(f);
101
                driver.go(
102
                    new String[] { testSourceDirectory.Text, resultsDirectory.Text, (testNamePattern.TextLength > 0 ? "-t:"+testNamePattern.Text: ""), (testSetNamePattern.TextLength > 0 ? "-s:"+testSetNamePattern.Text : ""), debugStr, "-bytecode:"+bytecodeStr, "-lang:"+langComboBox.Text });
103
            }
104
            doneLabel.Text = "Done!";
105
            runButton.Enabled = true;
106
        }
107

    
108
        private void testSuiteSelected(object sender, EventArgs e)
109
        {
110
            RegistryKey regKey = Registry.CurrentUser;
111
            regKey = regKey.CreateSubKey("Software\\Saxonica\\Saxon.Net\\TestRunner");
112
            if (testSuite.Text == "XSLT Test Suite")
113
            {
114
                testSourceDirectory.Text = (String)regKey.GetValue("XSLTTestDir", "");
115
                resultsDirectory.Text = (String)regKey.GetValue("XSLTResultsDir", "");
116
                label6.Visible = false;
117
                testSetNamePattern.Visible = false;
118
                debugCheckBox.Visible = false;
119
                byteCodeCheckBox.Visible = false;
120
                this.langComboBox.Visible = false;
121
                this.langLabel.Visible = false;
122
            }
123
            else if (testSuite.Text == "XSLT 3.0 Test Suite")
124
            {
125
                testSourceDirectory.Text = "C:\\work\\development\\intellij\\workspace\\project\\XSLT30-mercurial\\XSLT30-mercurial\\xslt30-test";//(String)regKey.GetValue("XSLT30TestDir", "");
126
                resultsDirectory.Text = "C:\\work\\development\\intellij\\workspace\\project\\XSLT30-mercurial\\XSLT30-mercurial\\results\\saxon";// (String)regKey.GetValue("XSLT30ResultsDir", "");
127
                label6.Visible = true;
128
                testSetNamePattern.Visible = true;
129
                debugCheckBox.Visible = true;
130
                byteCodeCheckBox.Visible = true;
131
                this.langComboBox.Visible = true;
132
                this.langLabel.Visible = true;
133
            }
134
            else if (testSuite.Text == "XQuery Test Suite")
135
            {
136
                testSourceDirectory.Text = (String)regKey.GetValue("XQueryTestDir", "");
137
                resultsDirectory.Text = (String)regKey.GetValue("XQueryResultsDir", "");
138
                label6.Visible = false;
139
                testSetNamePattern.Visible = false;
140
                debugCheckBox.Visible = false;
141
                byteCodeCheckBox.Visible = false;
142
                this.langComboBox.Visible = false;
143
                this.langLabel.Visible = false;
144
            }
145
            else if (testSuite.Text == "XML Schema Test Suite")
146
            {
147
                testSourceDirectory.Text = (String)regKey.GetValue("SchemaTestDir", "");
148
                resultsDirectory.Text = (String)regKey.GetValue("SchemaResultsDir", "");
149
                label6.Visible = false;
150
                testSetNamePattern.Visible = false;
151
                debugCheckBox.Visible = false;
152
                byteCodeCheckBox.Visible = false;
153
                this.langComboBox.Visible = false;
154
                this.langLabel.Visible = false;
155
            }
156
            else if (testSuite.Text == "FO Test Suite")
157
            {
158
                testSourceDirectory.Text = (String)regKey.GetValue("FOTestDir", "");
159
                resultsDirectory.Text = (String)regKey.GetValue("FOResultsDir", "");
160
                label6.Visible = true;
161
                testSetNamePattern.Visible = true;
162
                debugCheckBox.Visible = true;
163
                byteCodeCheckBox.Visible = true;
164
                this.langComboBox.Visible = true;
165
                this.langLabel.Visible = true;
166
                testNamePattern.Text = (String)regKey.GetValue("TestCaseName", "");
167
                testSetNamePattern.Text = (String)regKey.GetValue("TestSetName", "");
168
            }
169
        }
170

    
171
        public class FeedbackListener : IFeedbackListener
172
        {
173
            public Label doneLabel;
174
            public ProgressBar progressBar;
175
            public TextBox monitor;
176

    
177
            public void Feedback(int passed, int failed, int total)
178
            {
179
                doneLabel.Text = "Done " + (passed + failed) + " of " + total;
180
                doneLabel.Refresh();
181
                progressBar.Minimum = 0;
182
                progressBar.Maximum = total;
183
                progressBar.Value = passed + failed;
184
              //  progressBar.Refresh();
185
            
186
            }
187

    
188

    
189
            public void Message(String message, bool popup)
190
            {
191
                if (monitor.Text.Length > 5000) {
192
                    monitor.Text = "";
193
                }
194
                monitor.Text += message;
195
                monitor.Select(monitor.Text.Length, 0);
196
                monitor.ScrollToCaret();
197
                //monitor.Refresh();
198
            }
199
        }
200

    
201
        private void CloseButtonClicked(object sender, EventArgs e)
202
        {
203
            Close();
204
        }
205

    
206
        private void resultsDirectoryButtonClick(object sender, EventArgs e)
207
        {
208
            if (selectTestSourceFolder.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
209
                resultsDirectory.Text = selectTestSourceFolder.SelectedPath;
210
                RegistryKey regKey = Registry.CurrentUser;
211
                regKey = regKey.CreateSubKey("Software\\Saxonica\\Saxon.Net\\TestRunner");
212
                if (testSuite.Text == "XSLT Test Suite") {
213
                    regKey.SetValue("XSLTResultsDir", selectTestSourceFolder.SelectedPath);
214
                }
215
                else if (testSuite.Text == "XSLT 3.0 Test Suite")
216
                {
217
                    regKey.SetValue("XSLT30ResultsDir", selectTestSourceFolder.SelectedPath);
218
                }
219
                else if (testSuite.Text == "XQuery Test Suite")
220
                {
221
                    regKey.SetValue("XQueryResultsDir", selectTestSourceFolder.SelectedPath);
222
                }
223
                else if (testSuite.Text == "FO Test Suite")
224
                {
225
                    regKey.SetValue("FOResultsDir", selectTestSourceFolder.SelectedPath);
226
                }
227
            }
228
        }
229

    
230
    }
231
}
(18-18/24)