2020-04-02 17:56:48 +02:00
|
|
|
|
/*
|
2024-03-05 18:37:42 +01:00
|
|
|
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
2020-04-02 17:56:48 +02:00
|
|
|
|
*
|
|
|
|
|
* 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 CefSharp;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using Moq;
|
|
|
|
|
using SafeExamBrowser.Browser.Handlers;
|
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.Browser.UnitTests.Handlers
|
|
|
|
|
{
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class ContextMenuHandlerTests
|
|
|
|
|
{
|
|
|
|
|
private ContextMenuHandler sut;
|
|
|
|
|
|
|
|
|
|
[TestInitialize]
|
|
|
|
|
public void Initialize()
|
|
|
|
|
{
|
|
|
|
|
sut = new ContextMenuHandler();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void MustClearContextMenu()
|
|
|
|
|
{
|
|
|
|
|
var menu = new Mock<IMenuModel>();
|
|
|
|
|
|
2020-04-03 15:22:47 +02:00
|
|
|
|
sut.OnBeforeContextMenu(default(IWebBrowser), default(IBrowser), default(IFrame), default(IContextMenuParams), menu.Object);
|
2020-04-02 17:56:48 +02:00
|
|
|
|
menu.Verify(m => m.Clear(), Times.Once);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void MustBlockContextMenu()
|
|
|
|
|
{
|
2020-04-03 15:22:47 +02:00
|
|
|
|
var command = sut.OnContextMenuCommand(default(IWebBrowser), default(IBrowser), default(IFrame), default(IContextMenuParams), default(CefMenuCommand), default(CefEventFlags));
|
|
|
|
|
var run = sut.RunContextMenu(default(IWebBrowser), default(IBrowser), default(IFrame), default(IContextMenuParams), default(IMenuModel), default(IRunContextMenuCallback));
|
2020-04-02 17:56:48 +02:00
|
|
|
|
|
|
|
|
|
Assert.IsFalse(command);
|
|
|
|
|
Assert.IsFalse(run);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|