Browse Subversion Repository
Contents of /NeoFT/TestLauncher/ProgressForm.cs
Parent Directory
| Revision Log
Revision 103 -
( show annotations)
( download)
Sun Oct 13 12:34:30 2013 UTC
(10 years, 5 months ago)
by c477
File size: 1963 byte(s)
Add Test utility class and Control wrapper(platform compatible layer).
| 1 |
using System; |
| 2 |
using System.Collections.Generic; |
| 3 |
using System.ComponentModel; |
| 4 |
using System.Data; |
| 5 |
using System.Drawing; |
| 6 |
using System.Linq; |
| 7 |
using System.Text; |
| 8 |
using System.Windows.Forms; |
| 9 |
using System.Reflection; |
| 10 |
using System.IO; |
| 11 |
using nft.framework; |
| 12 |
using nft.util; |
| 13 |
using System.Diagnostics; |
| 14 |
|
| 15 |
namespace nft.test |
| 16 |
{ |
| 17 |
public partial class ProgressForm : Form |
| 18 |
{ |
| 19 |
public ProgressForm() { |
| 20 |
InitializeComponent(); |
| 21 |
} |
| 22 |
|
| 23 |
private Assembly[] asm_array; |
| 24 |
public Assembly[] Assemblies { |
| 25 |
get { return asm_array; } |
| 26 |
set { |
| 27 |
if (value == null) { |
| 28 |
asm_array = new Assembly[0]; |
| 29 |
} else { |
| 30 |
asm_array = value; |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
protected ProgressMonitor monitor; |
| 36 |
protected override void OnShown(EventArgs e) { |
| 37 |
base.OnShown(e); |
| 38 |
Process(); |
| 39 |
Close(); |
| 40 |
} |
| 41 |
|
| 42 |
protected TestLauncher Launcher { |
| 43 |
get {return Owner as TestLauncher; } |
| 44 |
} |
| 45 |
|
| 46 |
protected void Process() { |
| 47 |
monitor = new ProgressMonitor(1, OnProgress); |
| 48 |
foreach (Assembly asm in Assemblies) { |
| 49 |
progressBar.Value = 0; |
| 50 |
Text = String.Format("Loading {0}", Path.GetFileName(asm.CodeBase)); |
| 51 |
monitor.Attach(1,TestUtil.ProgressMonitor); |
| 52 |
foreach (TestInfo info in TestUtil.EnumTestEntries(asm)) { |
| 53 |
Debug.WriteLine("find test entry:"+info.TestAttribute.Caption); |
| 54 |
Launcher.AddTestEntry(info); |
| 55 |
} |
| 56 |
monitor.Detach(TestUtil.ProgressMonitor); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
public void OnProgress(int level, int percentage, string msg) { |
| 61 |
progressBar.Value = percentage; |
| 62 |
labelInfo.Text = msg; |
| 63 |
Update(); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
} |
| 68 |
} |
|