diff --git a/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs b/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs index 7c90d774..d62e723a 100644 --- a/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs +++ b/SafeExamBrowser.Runtime.UnitTests/RuntimeControllerTests.cs @@ -43,14 +43,17 @@ namespace SafeExamBrowser.Runtime.UnitTests private Mock messageBox; private SessionConfiguration nextSession; private AppSettings nextSettings; - private Mock shutdown; - private Mock text; - private Mock uiFactory; - private RuntimeController sut; private Mock runtimeHost; + private Mock runtimeWindow; private Mock service; private SessionContext sessionContext; private Mock sessionSequence; + private Mock shutdown; + private Mock splashScreen; + private Mock text; + private Mock uiFactory; + + private RuntimeController sut; [TestInitialize] public void Initialize() @@ -66,10 +69,12 @@ namespace SafeExamBrowser.Runtime.UnitTests nextSession = new SessionConfiguration(); nextSettings = new AppSettings(); runtimeHost = new Mock(); + runtimeWindow = new Mock(); service = new Mock(); sessionContext = new SessionContext(); sessionSequence = new Mock(); shutdown = new Mock(); + splashScreen = new Mock(); text = new Mock(); uiFactory = new Mock(); @@ -91,9 +96,11 @@ namespace SafeExamBrowser.Runtime.UnitTests bootstrapSequence.Object, sessionSequence.Object, runtimeHost.Object, + runtimeWindow.Object, service.Object, sessionContext, shutdown.Object, + splashScreen.Object, text.Object, uiFactory.Object); } @@ -373,9 +380,6 @@ namespace SafeExamBrowser.Runtime.UnitTests Progress = true, Regress = true }; - var runtimeWindow = new Mock(); - - uiFactory.Setup(u => u.CreateRuntimeWindow(It.IsAny())).Returns(runtimeWindow.Object); sut.TryStart(); sessionSequence.Raise(o => o.ProgressChanged += null, args); @@ -391,9 +395,6 @@ namespace SafeExamBrowser.Runtime.UnitTests public void Operations_MustUpdateStatus() { var key = TextKey.OperationStatus_EmptyClipboard; - var runtimeWindow = new Mock(); - - uiFactory.Setup(u => u.CreateRuntimeWindow(It.IsAny())).Returns(runtimeWindow.Object); sut.TryStart(); sessionSequence.Raise(o => o.StatusChanged += null, key); diff --git a/SafeExamBrowser.Runtime/CompositionRoot.cs b/SafeExamBrowser.Runtime/CompositionRoot.cs index 7a1be963..e439b2c6 100644 --- a/SafeExamBrowser.Runtime/CompositionRoot.cs +++ b/SafeExamBrowser.Runtime/CompositionRoot.cs @@ -64,14 +64,16 @@ namespace SafeExamBrowser.Runtime InitializeText(); var messageBox = new MessageBox(text); + var uiFactory = new UserInterfaceFactory(text); var desktopFactory = new DesktopFactory(ModuleLogger(nameof(DesktopFactory))); var explorerShell = new ExplorerShell(ModuleLogger(nameof(ExplorerShell)), nativeMethods); var processFactory = new ProcessFactory(ModuleLogger(nameof(ProcessFactory))); var proxyFactory = new ProxyFactory(new ProxyObjectFactory(), ModuleLogger(nameof(ProxyFactory))); 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 sessionContext = new SessionContext(); - var uiFactory = new UserInterfaceFactory(text); + var splashScreen = uiFactory.CreateSplashScreen(appConfig); var userInfo = new UserInfo(ModuleLogger(nameof(UserInfo))); var vmDetector = new VirtualMachineDetector(ModuleLogger(nameof(VirtualMachineDetector)), systemInfo); @@ -100,9 +102,11 @@ namespace SafeExamBrowser.Runtime bootstrapSequence, sessionSequence, runtimeHost, + runtimeWindow, serviceProxy, sessionContext, shutdown, + splashScreen, text, uiFactory); } diff --git a/SafeExamBrowser.Runtime/RuntimeController.cs b/SafeExamBrowser.Runtime/RuntimeController.cs index a7644ed7..3db25487 100644 --- a/SafeExamBrowser.Runtime/RuntimeController.cs +++ b/SafeExamBrowser.Runtime/RuntimeController.cs @@ -43,7 +43,7 @@ namespace SafeExamBrowser.Runtime private Action shutdown; private IText text; private IUserInterfaceFactory uiFactory; - + private SessionConfiguration Session { get { return sessionContext.Current; } @@ -61,9 +61,11 @@ namespace SafeExamBrowser.Runtime IOperationSequence bootstrapSequence, IRepeatableOperationSequence sessionSequence, IRuntimeHost runtimeHost, + IRuntimeWindow runtimeWindow, IServiceProxy service, SessionContext sessionContext, Action shutdown, + ISplashScreen splashScreen, IText text, IUserInterfaceFactory uiFactory) { @@ -72,10 +74,12 @@ namespace SafeExamBrowser.Runtime this.logger = logger; this.messageBox = messageBox; this.runtimeHost = runtimeHost; + this.runtimeWindow = runtimeWindow; this.sessionSequence = sessionSequence; this.service = service; this.sessionContext = sessionContext; this.shutdown = shutdown; + this.splashScreen = splashScreen; this.text = text; this.uiFactory = uiFactory; } @@ -84,9 +88,6 @@ namespace SafeExamBrowser.Runtime { logger.Info("Initiating startup procedure..."); - runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig); - splashScreen = uiFactory.CreateSplashScreen(appConfig); - bootstrapSequence.ProgressChanged += BootstrapSequence_ProgressChanged; bootstrapSequence.StatusChanged += BootstrapSequence_StatusChanged; sessionSequence.ActionRequired += SessionSequence_ActionRequired; @@ -94,6 +95,7 @@ namespace SafeExamBrowser.Runtime sessionSequence.StatusChanged += SessionSequence_StatusChanged; splashScreen.Show(); + splashScreen.BringToForeground(); var initialized = bootstrapSequence.TryPerform() == OperationResult.Success; @@ -104,7 +106,7 @@ namespace SafeExamBrowser.Runtime logger.Info("Application successfully initialized."); logger.Log(string.Empty); logger.Subscribe(runtimeWindow); - splashScreen.Close(); + splashScreen.Hide(); StartSession(); } @@ -129,10 +131,10 @@ namespace SafeExamBrowser.Runtime } logger.Unsubscribe(runtimeWindow); - runtimeWindow?.Close(); + runtimeWindow.Close(); - splashScreen = uiFactory.CreateSplashScreen(appConfig); splashScreen.Show(); + splashScreen.BringToForeground(); logger.Log(string.Empty); logger.Info("Initiating shutdown procedure..."); @@ -301,7 +303,7 @@ namespace SafeExamBrowser.Runtime private void BootstrapSequence_StatusChanged(TextKey status) { - splashScreen?.UpdateStatus(status, true); + splashScreen.UpdateStatus(status, true); } private void ClientProcess_Terminated(int exitCode)