Project

Profile

Help

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

he / tags / 9.4.0.7 / hen / csource / samples / TestRunnerForm.cs @ b0b00ab2

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 == "XQuery Test Suite")
29
                {
30
                    regKey.SetValue("XQueryTestDir", selectTestSourceFolder.SelectedPath);
31
                }
32
                else if (testSuite.Text == "XML Schema Test Suite")
33
                {
34
                    regKey.SetValue("SchemaTestDir", selectTestSourceFolder.SelectedPath);
35
                }
36
                else if (testSuite.Text == "FO Test Suite")
37
                {
38
                    regKey.SetValue("FOTestDir", selectTestSourceFolder.SelectedPath);
39
                }
40
            }
41
        }
42

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

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

    
91
        private void testSuiteSelected(object sender, EventArgs e)
92
        {
93
            RegistryKey regKey = Registry.CurrentUser;
94
            regKey = regKey.CreateSubKey("Software\\Saxonica\\Saxon.Net\\TestRunner");
95
            if (testSuite.Text == "XSLT Test Suite")
96
            {
97
                testSourceDirectory.Text = (String)regKey.GetValue("XSLTTestDir", "");
98
                resultsDirectory.Text = (String)regKey.GetValue("XSLTResultsDir", "");
99
                label6.Visible = false;
100
                testSetNamePattern.Visible = false;
101
                debugCheckBox.Visible = false;
102
                byteCodeCheckBox.Visible = false;
103
            }
104
            else if (testSuite.Text == "XQuery Test Suite")
105
            {
106
                testSourceDirectory.Text = (String)regKey.GetValue("XQueryTestDir", "");
107
                resultsDirectory.Text = (String)regKey.GetValue("XQueryResultsDir", "");
108
                label6.Visible = false;
109
                testSetNamePattern.Visible = false;
110
                debugCheckBox.Visible = false;
111
                byteCodeCheckBox.Visible = false;
112
            }
113
            else if (testSuite.Text == "XML Schema Test Suite")
114
            {
115
                testSourceDirectory.Text = (String)regKey.GetValue("SchemaTestDir", "");
116
                resultsDirectory.Text = (String)regKey.GetValue("SchemaResultsDir", "");
117
                label6.Visible = false;
118
                testSetNamePattern.Visible = false;
119
                debugCheckBox.Visible = false;
120
                byteCodeCheckBox.Visible = false;
121
            }
122
            else if (testSuite.Text == "FO Test Suite")
123
            {
124
                testSourceDirectory.Text = (String)regKey.GetValue("FOTestDir", "");
125
                resultsDirectory.Text = (String)regKey.GetValue("FOResultsDir", "");
126
                label6.Visible = true;
127
                testSetNamePattern.Visible = true;
128
                debugCheckBox.Visible = true;
129
                byteCodeCheckBox.Visible = true;
130
                testNamePattern.Text = (String)regKey.GetValue("TestCaseName", "");
131
                testSetNamePattern.Text = (String)regKey.GetValue("TestSetName", "");
132
            }
133
        }
134

    
135
        public class FeedbackListener : IFeedbackListener
136
        {
137
            public Label doneLabel;
138
            public ProgressBar progressBar;
139
            public TextBox monitor;
140

    
141
            public void Feedback(int passed, int failed, int total)
142
            {
143
                doneLabel.Text = "Done " + (passed + failed) + " of " + total;
144
                doneLabel.Refresh();
145
                progressBar.Minimum = 0;
146
                progressBar.Maximum = total;
147
                progressBar.Value = passed + failed;
148
              //  progressBar.Refresh();
149
            
150
            }
151

    
152

    
153
            public void Message(String message, bool popup)
154
            {
155
                if (monitor.Text.Length > 5000) {
156
                    monitor.Text = "";
157
                }
158
                monitor.Text += message;
159
                monitor.Select(monitor.Text.Length, 0);
160
                monitor.ScrollToCaret();
161
                //monitor.Refresh();
162
            }
163
        }
164

    
165
        private void CloseButtonClicked(object sender, EventArgs e)
166
        {
167
            Close();
168
        }
169

    
170
        private void resultsDirectoryButtonClick(object sender, EventArgs e)
171
        {
172
            if (selectTestSourceFolder.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
173
                resultsDirectory.Text = selectTestSourceFolder.SelectedPath;
174
                RegistryKey regKey = Registry.CurrentUser;
175
                regKey = regKey.CreateSubKey("Software\\Saxonica\\Saxon.Net\\TestRunner");
176
                if (testSuite.Text == "XSLT Test Suite") {
177
                    regKey.SetValue("XSLTResultsDir", selectTestSourceFolder.SelectedPath);
178
                }
179
                else if (testSuite.Text == "XQuery Test Suite")
180
                {
181
                    regKey.SetValue("XQueryResultsDir", selectTestSourceFolder.SelectedPath);
182
                }
183
                else if (testSuite.Text == "FO Test Suite")
184
                {
185
                    regKey.SetValue("FOResultsDir", selectTestSourceFolder.SelectedPath);
186
                }
187
            }
188
        }
189
    }
190
}
(11-11/14)