diff --git a/SafeExamBrowser.Client.Contracts/INotificationController.cs b/SafeExamBrowser.Client.Contracts/INotificationController.cs
index 1bc9cebf..f9d230fe 100644
--- a/SafeExamBrowser.Client.Contracts/INotificationController.cs
+++ b/SafeExamBrowser.Client.Contracts/INotificationController.cs
@@ -9,16 +9,15 @@
namespace SafeExamBrowser.Client.Contracts
{
///
- /// Controls the lifetime and functionality of a notification which is part of the .
+ /// Controls the lifetime and functionality of a notification which can be activated via the UI.
///
public interface INotificationController
{
- // TODO
- /////
- ///// Registers the taskbar notification.
- /////
- //void RegisterNotification(INotificationControl notification);
-
+ ///
+ /// Executes the notification functionality.
+ ///
+ void Activate();
+
///
/// Instructs the controller to shut down and release all used resources.
///
diff --git a/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs b/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs
index d08f9191..749357c7 100644
--- a/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs
+++ b/SafeExamBrowser.Client.UnitTests/Notifications/AboutNotificationControllerTests.cs
@@ -31,13 +31,12 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
[TestMethod]
public void MustCloseWindowWhenTerminating()
{
- var button = new NotificationButtonMock();
var window = new Mock();
var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
uiFactory.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object);
- sut.RegisterNotification(button);
- button.Click();
+
+ sut.Activate();
sut.Terminate();
window.Verify(w => w.Close());
@@ -46,34 +45,22 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
[TestMethod]
public void MustOpenOnlyOneWindow()
{
- var button = new NotificationButtonMock();
var window = new Mock();
var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
uiFactory.Setup(u => u.CreateAboutWindow(It.IsAny())).Returns(window.Object);
- sut.RegisterNotification(button);
- button.Click();
- button.Click();
- button.Click();
- button.Click();
- button.Click();
+
+ sut.Activate();
+ sut.Activate();
+ sut.Activate();
+ sut.Activate();
+ sut.Activate();
uiFactory.Verify(u => u.CreateAboutWindow(It.IsAny()), Times.Once);
window.Verify(u => u.Show(), Times.Once);
window.Verify(u => u.BringToForeground(), Times.Exactly(4));
}
- [TestMethod]
- public void MustSubscribeToClickEvent()
- {
- var button = new NotificationButtonMock();
- var sut = new AboutNotificationController(appConfig.Object, uiFactory.Object);
-
- sut.RegisterNotification(button);
-
- Assert.IsTrue(button.HasSubscribed);
- }
-
[TestMethod]
public void MustNotFailToTerminateIfNotStarted()
{
diff --git a/SafeExamBrowser.Client.UnitTests/Notifications/LogNotificationControllerTests.cs b/SafeExamBrowser.Client.UnitTests/Notifications/LogNotificationControllerTests.cs
index fd1a5d85..f9d8ddd3 100644
--- a/SafeExamBrowser.Client.UnitTests/Notifications/LogNotificationControllerTests.cs
+++ b/SafeExamBrowser.Client.UnitTests/Notifications/LogNotificationControllerTests.cs
@@ -31,13 +31,12 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
[TestMethod]
public void MustCloseWindowWhenTerminating()
{
- var button = new NotificationButtonMock();
var window = new Mock();
var sut = new LogNotificationController(logger.Object, uiFactory.Object);
uiFactory.Setup(u => u.CreateLogWindow(It.IsAny())).Returns(window.Object);
- sut.RegisterNotification(button);
- button.Click();
+
+ sut.Activate();
sut.Terminate();
window.Verify(w => w.Close());
@@ -46,34 +45,22 @@ namespace SafeExamBrowser.Client.UnitTests.Notifications
[TestMethod]
public void MustOpenOnlyOneWindow()
{
- var button = new NotificationButtonMock();
var window = new Mock();
var sut = new LogNotificationController(logger.Object, uiFactory.Object);
uiFactory.Setup(u => u.CreateLogWindow(It.IsAny())).Returns(window.Object);
- sut.RegisterNotification(button);
- button.Click();
- button.Click();
- button.Click();
- button.Click();
- button.Click();
+
+ sut.Activate();
+ sut.Activate();
+ sut.Activate();
+ sut.Activate();
+ sut.Activate();
uiFactory.Verify(u => u.CreateLogWindow(It.IsAny()), Times.Once);
window.Verify(u => u.Show(), Times.Once);
window.Verify(u => u.BringToForeground(), Times.Exactly(4));
}
- [TestMethod]
- public void MustSubscribeToClickEvent()
- {
- var button = new NotificationButtonMock();
- var sut = new LogNotificationController(logger.Object, uiFactory.Object);
-
- sut.RegisterNotification(button);
-
- Assert.IsTrue(button.HasSubscribed);
- }
-
[TestMethod]
public void MustNotFailToTerminateIfNotStarted()
{
diff --git a/SafeExamBrowser.Client.UnitTests/Notifications/NotificationButtonMock.cs b/SafeExamBrowser.Client.UnitTests/Notifications/NotificationButtonMock.cs
deleted file mode 100644
index 38165423..00000000
--- a/SafeExamBrowser.Client.UnitTests/Notifications/NotificationButtonMock.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-using SafeExamBrowser.UserInterface.Contracts.Shell;
-using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
-
-namespace SafeExamBrowser.Client.UnitTests.Notifications
-{
- class NotificationButtonMock : INotificationControl
- {
- private NotificationControlClickedEventHandler clicked;
-
- public bool HasSubscribed;
- public bool HasUnsubscribed;
-
- public event NotificationControlClickedEventHandler Clicked
- {
- add
- {
- clicked += value;
- HasSubscribed = true;
- }
- remove
- {
- clicked -= value;
- HasUnsubscribed = true;
- }
- }
-
- public void Click()
- {
- clicked?.Invoke();
- }
- }
-}
diff --git a/SafeExamBrowser.Client.UnitTests/Operations/ShellOperationTests.cs b/SafeExamBrowser.Client.UnitTests/Operations/ShellOperationTests.cs
index f080d10f..e9119462 100644
--- a/SafeExamBrowser.Client.UnitTests/Operations/ShellOperationTests.cs
+++ b/SafeExamBrowser.Client.UnitTests/Operations/ShellOperationTests.cs
@@ -71,17 +71,19 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
uiFactory = new Mock();
wirelessAdapter = new Mock();
- uiFactory.Setup(u => u.CreateNotificationControl(It.IsAny(), It.IsAny())).Returns(new Mock().Object);
+ uiFactory
+ .Setup(u => u.CreateNotificationControl(It.IsAny(), It.IsAny(), It.IsAny()))
+ .Returns(new Mock().Object);
sut = new ShellOperation(
actionCenter.Object,
activators,
actionCenterSettings,
audio.Object,
- logger.Object,
aboutInfo.Object,
aboutController.Object,
keyboard.Object,
+ logger.Object,
logInfo.Object,
logController.Object,
powerSupply.Object,
@@ -175,7 +177,9 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
taskbarSettings.EnableTaskbar = true;
taskbarSettings.ShowApplicationLog = false;
- uiFactory.Setup(f => f.CreateNotificationControl(It.Is(i => i == logInfo.Object), It.IsAny())).Returns(logControl.Object);
+ uiFactory
+ .Setup(f => f.CreateNotificationControl(It.IsAny(), It.Is(i => i == logInfo.Object), It.IsAny()))
+ .Returns(logControl.Object);
sut.Perform();
diff --git a/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj b/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj
index 3080280b..aee25bf6 100644
--- a/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj
+++ b/SafeExamBrowser.Client.UnitTests/SafeExamBrowser.Client.UnitTests.csproj
@@ -95,7 +95,6 @@
-
diff --git a/SafeExamBrowser.Client/CompositionRoot.cs b/SafeExamBrowser.Client/CompositionRoot.cs
index 0f36a9e7..7445e23b 100644
--- a/SafeExamBrowser.Client/CompositionRoot.cs
+++ b/SafeExamBrowser.Client/CompositionRoot.cs
@@ -275,10 +275,10 @@ namespace SafeExamBrowser.Client
activators,
configuration.Settings.ActionCenter,
audio,
- logger,
aboutInfo,
aboutController,
keyboard,
+ logger,
logInfo,
logController,
powerSupply,
diff --git a/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs b/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs
index 4d742539..6bdabb02 100644
--- a/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs
+++ b/SafeExamBrowser.Client/Notifications/AboutNotificationController.cs
@@ -9,14 +9,12 @@
using SafeExamBrowser.Client.Contracts;
using SafeExamBrowser.Configuration.Contracts;
using SafeExamBrowser.UserInterface.Contracts;
-using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.UserInterface.Contracts.Windows;
namespace SafeExamBrowser.Client.Notifications
{
internal class AboutNotificationController : INotificationController
{
- private INotificationControl notification;
private AppConfig appConfig;
private IUserInterfaceFactory uiFactory;
private IWindow window;
@@ -27,25 +25,13 @@ namespace SafeExamBrowser.Client.Notifications
this.uiFactory = uiFactory;
}
- public void RegisterNotification(INotificationControl notification)
+ public void Activate()
{
- this.notification = notification;
-
- notification.Clicked += Notification_Clicked;
- }
-
- public void Terminate()
- {
- window?.Close();
- }
-
- private void Notification_Clicked()
- {
- if (window == null)
+ if (window == default(IWindow))
{
window = uiFactory.CreateAboutWindow(appConfig);
- window.Closing += () => window = null;
+ window.Closing += () => window = default(IWindow);
window.Show();
}
else
@@ -53,5 +39,10 @@ namespace SafeExamBrowser.Client.Notifications
window.BringToForeground();
}
}
+
+ public void Terminate()
+ {
+ window?.Close();
+ }
}
}
diff --git a/SafeExamBrowser.Client/Notifications/LogNotificationController.cs b/SafeExamBrowser.Client/Notifications/LogNotificationController.cs
index 7fd4c918..bedb5521 100644
--- a/SafeExamBrowser.Client/Notifications/LogNotificationController.cs
+++ b/SafeExamBrowser.Client/Notifications/LogNotificationController.cs
@@ -9,14 +9,12 @@
using SafeExamBrowser.Client.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.UserInterface.Contracts;
-using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.UserInterface.Contracts.Windows;
namespace SafeExamBrowser.Client.Notifications
{
internal class LogNotificationController : INotificationController
{
- private INotificationControl notification;
private ILogger logger;
private IUserInterfaceFactory uiFactory;
private IWindow window;
@@ -27,21 +25,9 @@ namespace SafeExamBrowser.Client.Notifications
this.uiFactory = uiFactory;
}
- public void RegisterNotification(INotificationControl notification)
+ public void Activate()
{
- this.notification = notification;
-
- notification.Clicked += Notification_Clicked;
- }
-
- public void Terminate()
- {
- window?.Close();
- }
-
- private void Notification_Clicked()
- {
- if (window == null)
+ if (window == default(IWindow))
{
window = uiFactory.CreateLogWindow(logger);
@@ -53,5 +39,10 @@ namespace SafeExamBrowser.Client.Notifications
window.BringToForeground();
}
}
+
+ public void Terminate()
+ {
+ window?.Close();
+ }
}
}
diff --git a/SafeExamBrowser.Client/Operations/ShellOperation.cs b/SafeExamBrowser.Client/Operations/ShellOperation.cs
index f4647eb6..556757fb 100644
--- a/SafeExamBrowser.Client/Operations/ShellOperation.cs
+++ b/SafeExamBrowser.Client/Operations/ShellOperation.cs
@@ -30,10 +30,10 @@ namespace SafeExamBrowser.Client.Operations
private IEnumerable activators;
private ActionCenterSettings actionCenterSettings;
private IAudio audio;
- private ILogger logger;
private INotificationInfo aboutInfo;
private INotificationController aboutController;
private IKeyboard keyboard;
+ private ILogger logger;
private INotificationInfo logInfo;
private INotificationController logController;
private IPowerSupply powerSupply;
@@ -53,10 +53,10 @@ namespace SafeExamBrowser.Client.Operations
IEnumerable activators,
ActionCenterSettings actionCenterSettings,
IAudio audio,
- ILogger logger,
INotificationInfo aboutInfo,
INotificationController aboutController,
IKeyboard keyboard,
+ ILogger logger,
INotificationInfo logInfo,
INotificationController logController,
IPowerSupply powerSupply,
@@ -181,10 +181,7 @@ namespace SafeExamBrowser.Client.Operations
{
if (actionCenterSettings.ShowApplicationInfo)
{
- var notification = uiFactory.CreateNotificationControl(aboutInfo, Location.ActionCenter);
-
- // TODO aboutController.RegisterNotification(notification);
- actionCenter.AddNotificationControl(notification);
+ actionCenter.AddNotificationControl(uiFactory.CreateNotificationControl(aboutController, aboutInfo, Location.ActionCenter));
}
}
@@ -192,10 +189,7 @@ namespace SafeExamBrowser.Client.Operations
{
if (taskbarSettings.ShowApplicationInfo)
{
- var notification = uiFactory.CreateNotificationControl(aboutInfo, Location.Taskbar);
-
- // TODO aboutController.RegisterNotification(notification);
- taskbar.AddNotificationControl(notification);
+ taskbar.AddNotificationControl(uiFactory.CreateNotificationControl(aboutController, aboutInfo, Location.Taskbar));
}
}
@@ -229,10 +223,7 @@ namespace SafeExamBrowser.Client.Operations
{
if (actionCenterSettings.ShowApplicationLog)
{
- var notification = uiFactory.CreateNotificationControl(logInfo, Location.ActionCenter);
-
- // TODO logController.RegisterNotification(notification);
- actionCenter.AddNotificationControl(notification);
+ actionCenter.AddNotificationControl(uiFactory.CreateNotificationControl(logController, logInfo, Location.ActionCenter));
}
}
@@ -240,10 +231,7 @@ namespace SafeExamBrowser.Client.Operations
{
if (taskbarSettings.ShowApplicationLog)
{
- var notification = uiFactory.CreateNotificationControl(logInfo, Location.Taskbar);
-
- // TODO logController.RegisterNotification(notification);
- taskbar.AddNotificationControl(notification);
+ taskbar.AddNotificationControl(uiFactory.CreateNotificationControl(logController, logInfo, Location.Taskbar));
}
}
diff --git a/SafeExamBrowser.UserInterface.Contracts/IUserInterfaceFactory.cs b/SafeExamBrowser.UserInterface.Contracts/IUserInterfaceFactory.cs
index dcd8507f..1a157022 100644
--- a/SafeExamBrowser.UserInterface.Contracts/IUserInterfaceFactory.cs
+++ b/SafeExamBrowser.UserInterface.Contracts/IUserInterfaceFactory.cs
@@ -58,9 +58,9 @@ namespace SafeExamBrowser.UserInterface.Contracts
IWindow CreateLogWindow(ILogger logger);
///
- /// Creates a notification control for the specified location, initialized with the given notification information.
+ /// Creates a notification control for the given notification, initialized for the specified location.
///
- INotificationControl CreateNotificationControl(INotificationInfo info, Location location);
+ INotificationControl CreateNotificationControl(INotificationController controller, INotificationInfo info, Location location);
///
/// Creates a password dialog with the given message and title.
diff --git a/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj b/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj
index 79719265..addf13a2 100644
--- a/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj
+++ b/SafeExamBrowser.UserInterface.Contracts/SafeExamBrowser.UserInterface.Contracts.csproj
@@ -67,9 +67,7 @@
-
-
diff --git a/SafeExamBrowser.UserInterface.Contracts/Shell/Events/NotificationControlClickedEventHandler.cs b/SafeExamBrowser.UserInterface.Contracts/Shell/Events/NotificationControlClickedEventHandler.cs
deleted file mode 100644
index bcbb3779..00000000
--- a/SafeExamBrowser.UserInterface.Contracts/Shell/Events/NotificationControlClickedEventHandler.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-namespace SafeExamBrowser.UserInterface.Contracts.Shell.Events
-{
- ///
- /// Indicates that the user clicked on a in the shell.
- ///
- public delegate void NotificationControlClickedEventHandler();
-}
diff --git a/SafeExamBrowser.UserInterface.Contracts/Shell/Events/WirelessNetworkSelectedEventHandler.cs b/SafeExamBrowser.UserInterface.Contracts/Shell/Events/WirelessNetworkSelectedEventHandler.cs
deleted file mode 100644
index 89698c9b..00000000
--- a/SafeExamBrowser.UserInterface.Contracts/Shell/Events/WirelessNetworkSelectedEventHandler.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-using System;
-
-namespace SafeExamBrowser.UserInterface.Contracts.Shell.Events
-{
- ///
- /// Indicates that a particular wireless network has been selected by the user.
- ///
- public delegate void WirelessNetworkSelectedEventHandler(Guid id);
-}
diff --git a/SafeExamBrowser.UserInterface.Contracts/Shell/INotificationControl.cs b/SafeExamBrowser.UserInterface.Contracts/Shell/INotificationControl.cs
index 1a2fceab..59ae66f4 100644
--- a/SafeExamBrowser.UserInterface.Contracts/Shell/INotificationControl.cs
+++ b/SafeExamBrowser.UserInterface.Contracts/Shell/INotificationControl.cs
@@ -6,8 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
-
namespace SafeExamBrowser.UserInterface.Contracts.Shell
{
///
@@ -15,9 +13,5 @@ namespace SafeExamBrowser.UserInterface.Contracts.Shell
///
public interface INotificationControl
{
- ///
- /// Event fired when the user clicked on the notification control.
- ///
- event NotificationControlClickedEventHandler Clicked;
}
}
diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml
index b9649114..5c6b8091 100644
--- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml
+++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenterNotificationButton.xaml
@@ -14,7 +14,7 @@
-