Better non-visible regression testing & the close button working.

This commit is contained in:
Tim Young 2018-09-26 09:08:05 -05:00
parent b87d1acd93
commit aaf7afdd65
4 changed files with 43 additions and 3 deletions

View File

@ -609,6 +609,7 @@ namespace EduNetworkBuilder
{
AddRoute();
}
//In puzzle mode, this is the cancel button
if(MyMode == LBContents.puzzles)
{
if (oursettings.AutoStartPuzzles != cbLoadPuzzlesAtStart.Checked)
@ -618,6 +619,11 @@ namespace EduNetworkBuilder
}
Close();
}
//In regression, this is the close button
if (MyMode == LBContents.regressiontest)
{
Close();
}
}
private void AddRoute()
{

View File

@ -491,7 +491,7 @@ namespace EduNetworkBuilder
{
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
if (myWin == null) return;
myWin.RegisterInisibleNet(ToRegister);
myWin.RegisterInvisibleNet(ToRegister);
}
public static void UnregisterInvisibleNetwork()

View File

@ -84,6 +84,8 @@ namespace EduNetworkBuilder
public bool ReplayInProgress = false;
public DateTime NextReplayAction = DateTime.UtcNow;
public int NextReplayIndex = -1;
public bool StartedNewReplayAction = false;
public bool ProcessingNonVisually = false;
/// <summary>
/// WhatFrom: If we are launched from a homework, we remember it here.
@ -1682,6 +1684,7 @@ namespace EduNetworkBuilder
{
//we did something. keep replaying
NB.MarkToUpdate();
StartedNewReplayAction = true;
}
else
{
@ -2471,6 +2474,27 @@ namespace EduNetworkBuilder
}
}
/// <summary>
/// This is used when we are doing a replay behind the scenes.
/// We may have many things that we do. We still want to time-out if
/// a packet needs to drop. So we loop through, but have a timeout on each
/// individual action.
/// </summary>
public void NonVisualProcessPacketsMultipleTimes()
{
int counter = 0;
while (counter < 1000 && myPackets.Count > 0)
{
Tick(true); //Skip visuals
if(StartedNewReplayAction)
{
counter = 0; //reset counter to zero
StartedNewReplayAction = false; //reset it
}
counter++;
}
}
int BreakNetComponent(NetworkComponent What, HowToBreak How, string Data)
{
int didit = 0;

View File

@ -2706,7 +2706,7 @@ namespace EduNetworkBuilder
return myNetwork;
}
public void RegisterInisibleNet(Network toRegister)
public void RegisterInvisibleNet(Network toRegister)
{
InvisibleNetwork = toRegister;
}
@ -2859,7 +2859,17 @@ namespace EduNetworkBuilder
//Disable menuitems & right-click if in replay mode
myNetwork.ReplayInProgress = true;
myNetwork.NextReplayIndex = 0;
myNetwork.NextReplayAction = DateTime.UtcNow.AddMilliseconds(delay_between);
myNetwork.NextReplayAction = DateTime.UtcNow.AddMilliseconds(delay_between);
//Now we need to process it.
NB.RegisterInvisibleNetwork(myNetwork);
//while we have actions to do.
while (myNetwork.ReplayInProgress)
{
myNetwork.Tick(true);
myNetwork.NonVisualProcessPacketsMultipleTimes();
}
NB.UnregisterInvisibleNetwork();
}
private void replayToolStripMenuItem_Click(object sender, EventArgs e)