SEBWIN-360: Improved runtime performance by having only one splash screen.

This commit is contained in:
dbuechel 2020-02-14 15:04:33 +01:00
parent 19bf6df812
commit 42e107d7c7
3 changed files with 26 additions and 19 deletions

View file

@ -43,14 +43,17 @@ namespace SafeExamBrowser.Runtime.UnitTests
private Mock<IMessageBox> messageBox; private Mock<IMessageBox> messageBox;
private SessionConfiguration nextSession; private SessionConfiguration nextSession;
private AppSettings nextSettings; private AppSettings nextSettings;
private Mock<Action> shutdown;
private Mock<IText> text;
private Mock<IUserInterfaceFactory> uiFactory;
private RuntimeController sut;
private Mock<IRuntimeHost> runtimeHost; private Mock<IRuntimeHost> runtimeHost;
private Mock<IRuntimeWindow> runtimeWindow;
private Mock<IServiceProxy> service; private Mock<IServiceProxy> service;
private SessionContext sessionContext; private SessionContext sessionContext;
private Mock<IRepeatableOperationSequence> sessionSequence; private Mock<IRepeatableOperationSequence> sessionSequence;
private Mock<Action> shutdown;
private Mock<ISplashScreen> splashScreen;
private Mock<IText> text;
private Mock<IUserInterfaceFactory> uiFactory;
private RuntimeController sut;
[TestInitialize] [TestInitialize]
public void Initialize() public void Initialize()
@ -66,10 +69,12 @@ namespace SafeExamBrowser.Runtime.UnitTests
nextSession = new SessionConfiguration(); nextSession = new SessionConfiguration();
nextSettings = new AppSettings(); nextSettings = new AppSettings();
runtimeHost = new Mock<IRuntimeHost>(); runtimeHost = new Mock<IRuntimeHost>();
runtimeWindow = new Mock<IRuntimeWindow>();
service = new Mock<IServiceProxy>(); service = new Mock<IServiceProxy>();
sessionContext = new SessionContext(); sessionContext = new SessionContext();
sessionSequence = new Mock<IRepeatableOperationSequence>(); sessionSequence = new Mock<IRepeatableOperationSequence>();
shutdown = new Mock<Action>(); shutdown = new Mock<Action>();
splashScreen = new Mock<ISplashScreen>();
text = new Mock<IText>(); text = new Mock<IText>();
uiFactory = new Mock<IUserInterfaceFactory>(); uiFactory = new Mock<IUserInterfaceFactory>();
@ -91,9 +96,11 @@ namespace SafeExamBrowser.Runtime.UnitTests
bootstrapSequence.Object, bootstrapSequence.Object,
sessionSequence.Object, sessionSequence.Object,
runtimeHost.Object, runtimeHost.Object,
runtimeWindow.Object,
service.Object, service.Object,
sessionContext, sessionContext,
shutdown.Object, shutdown.Object,
splashScreen.Object,
text.Object, text.Object,
uiFactory.Object); uiFactory.Object);
} }
@ -373,9 +380,6 @@ namespace SafeExamBrowser.Runtime.UnitTests
Progress = true, Progress = true,
Regress = true Regress = true
}; };
var runtimeWindow = new Mock<IRuntimeWindow>();
uiFactory.Setup(u => u.CreateRuntimeWindow(It.IsAny<AppConfig>())).Returns(runtimeWindow.Object);
sut.TryStart(); sut.TryStart();
sessionSequence.Raise(o => o.ProgressChanged += null, args); sessionSequence.Raise(o => o.ProgressChanged += null, args);
@ -391,9 +395,6 @@ namespace SafeExamBrowser.Runtime.UnitTests
public void Operations_MustUpdateStatus() public void Operations_MustUpdateStatus()
{ {
var key = TextKey.OperationStatus_EmptyClipboard; var key = TextKey.OperationStatus_EmptyClipboard;
var runtimeWindow = new Mock<IRuntimeWindow>();
uiFactory.Setup(u => u.CreateRuntimeWindow(It.IsAny<AppConfig>())).Returns(runtimeWindow.Object);
sut.TryStart(); sut.TryStart();
sessionSequence.Raise(o => o.StatusChanged += null, key); sessionSequence.Raise(o => o.StatusChanged += null, key);

View file

@ -64,14 +64,16 @@ namespace SafeExamBrowser.Runtime
InitializeText(); InitializeText();
var messageBox = new MessageBox(text); var messageBox = new MessageBox(text);
var uiFactory = new UserInterfaceFactory(text);
var desktopFactory = new DesktopFactory(ModuleLogger(nameof(DesktopFactory))); var desktopFactory = new DesktopFactory(ModuleLogger(nameof(DesktopFactory)));
var explorerShell = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods); var explorerShell = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods);
var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory))); var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory)));
var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory))); var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory)));
var runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS); var runtimeHost = new RuntimeHost(appConfig.RuntimeAddress, new HostObjectFactory(), ModuleLogger(nameof(RuntimeHost)), FIVE_SECONDS);
var runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig);
var serviceProxy = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)), Interlocutor.Runtime); var serviceProxy = new ServiceProxy(appConfig.ServiceAddress, new ProxyObjectFactory(), ModuleLogger(nameof(ServiceProxy)), Interlocutor.Runtime);
var sessionContext = new SessionContext(); var sessionContext = new SessionContext();
var uiFactory = new UserInterfaceFactory(text); var splashScreen = uiFactory.CreateSplashScreen(appConfig);
var userInfo = new UserInfo(ModuleLogger(nameof(UserInfo))); var userInfo = new UserInfo(ModuleLogger(nameof(UserInfo)));
var vmDetector = new VirtualMachineDetector(ModuleLogger(nameof(VirtualMachineDetector)), systemInfo); var vmDetector = new VirtualMachineDetector(ModuleLogger(nameof(VirtualMachineDetector)), systemInfo);
@ -100,9 +102,11 @@ namespace SafeExamBrowser.Runtime
bootstrapSequence, bootstrapSequence,
sessionSequence, sessionSequence,
runtimeHost, runtimeHost,
runtimeWindow,
serviceProxy, serviceProxy,
sessionContext, sessionContext,
shutdown, shutdown,
splashScreen,
text, text,
uiFactory); uiFactory);
} }

View file

@ -43,7 +43,7 @@ namespace SafeExamBrowser.Runtime
private Action shutdown; private Action shutdown;
private IText text; private IText text;
private IUserInterfaceFactory uiFactory; private IUserInterfaceFactory uiFactory;
private SessionConfiguration Session private SessionConfiguration Session
{ {
get { return sessionContext.Current; } get { return sessionContext.Current; }
@ -61,9 +61,11 @@ namespace SafeExamBrowser.Runtime
IOperationSequence bootstrapSequence, IOperationSequence bootstrapSequence,
IRepeatableOperationSequence sessionSequence, IRepeatableOperationSequence sessionSequence,
IRuntimeHost runtimeHost, IRuntimeHost runtimeHost,
IRuntimeWindow runtimeWindow,
IServiceProxy service, IServiceProxy service,
SessionContext sessionContext, SessionContext sessionContext,
Action shutdown, Action shutdown,
ISplashScreen splashScreen,
IText text, IText text,
IUserInterfaceFactory uiFactory) IUserInterfaceFactory uiFactory)
{ {
@ -72,10 +74,12 @@ namespace SafeExamBrowser.Runtime
this.logger = logger; this.logger = logger;
this.messageBox = messageBox; this.messageBox = messageBox;
this.runtimeHost = runtimeHost; this.runtimeHost = runtimeHost;
this.runtimeWindow = runtimeWindow;
this.sessionSequence = sessionSequence; this.sessionSequence = sessionSequence;
this.service = service; this.service = service;
this.sessionContext = sessionContext; this.sessionContext = sessionContext;
this.shutdown = shutdown; this.shutdown = shutdown;
this.splashScreen = splashScreen;
this.text = text; this.text = text;
this.uiFactory = uiFactory; this.uiFactory = uiFactory;
} }
@ -84,9 +88,6 @@ namespace SafeExamBrowser.Runtime
{ {
logger.Info("Initiating startup procedure..."); logger.Info("Initiating startup procedure...");
runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig);
splashScreen = uiFactory.CreateSplashScreen(appConfig);
bootstrapSequence.ProgressChanged += BootstrapSequence_ProgressChanged; bootstrapSequence.ProgressChanged += BootstrapSequence_ProgressChanged;
bootstrapSequence.StatusChanged += BootstrapSequence_StatusChanged; bootstrapSequence.StatusChanged += BootstrapSequence_StatusChanged;
sessionSequence.ActionRequired += SessionSequence_ActionRequired; sessionSequence.ActionRequired += SessionSequence_ActionRequired;
@ -94,6 +95,7 @@ namespace SafeExamBrowser.Runtime
sessionSequence.StatusChanged += SessionSequence_StatusChanged; sessionSequence.StatusChanged += SessionSequence_StatusChanged;
splashScreen.Show(); splashScreen.Show();
splashScreen.BringToForeground();
var initialized = bootstrapSequence.TryPerform() == OperationResult.Success; var initialized = bootstrapSequence.TryPerform() == OperationResult.Success;
@ -104,7 +106,7 @@ namespace SafeExamBrowser.Runtime
logger.Info("Application successfully initialized."); logger.Info("Application successfully initialized.");
logger.Log(string.Empty); logger.Log(string.Empty);
logger.Subscribe(runtimeWindow); logger.Subscribe(runtimeWindow);
splashScreen.Close(); splashScreen.Hide();
StartSession(); StartSession();
} }
@ -129,10 +131,10 @@ namespace SafeExamBrowser.Runtime
} }
logger.Unsubscribe(runtimeWindow); logger.Unsubscribe(runtimeWindow);
runtimeWindow?.Close(); runtimeWindow.Close();
splashScreen = uiFactory.CreateSplashScreen(appConfig);
splashScreen.Show(); splashScreen.Show();
splashScreen.BringToForeground();
logger.Log(string.Empty); logger.Log(string.Empty);
logger.Info("Initiating shutdown procedure..."); logger.Info("Initiating shutdown procedure...");
@ -301,7 +303,7 @@ namespace SafeExamBrowser.Runtime
private void BootstrapSequence_StatusChanged(TextKey status) private void BootstrapSequence_StatusChanged(TextKey status)
{ {
splashScreen?.UpdateStatus(status, true); splashScreen.UpdateStatus(status, true);
} }
private void ClientProcess_Terminated(int exitCode) private void ClientProcess_Terminated(int exitCode)