SEBWIN-380: Added browser engine reference to browser unit tests in order to be able to unit test important components.
This commit is contained in:
parent
735e0b6dca
commit
5eff32a7bc
4 changed files with 60 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 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 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>();
|
||||||
|
|
||||||
|
sut.OnBeforeContextMenu(Mock.Of<IWebBrowser>(), Mock.Of<IBrowser>(), Mock.Of<IFrame>(), Mock.Of<IContextMenuParams>(), menu.Object);
|
||||||
|
menu.Verify(m => m.Clear(), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void MustBlockContextMenu()
|
||||||
|
{
|
||||||
|
var command = sut.OnContextMenuCommand(Mock.Of<IWebBrowser>(), Mock.Of<IBrowser>(), Mock.Of<IFrame>(), Mock.Of<IContextMenuParams>(), default(CefMenuCommand), default(CefEventFlags));
|
||||||
|
var run = sut.RunContextMenu(Mock.Of<IWebBrowser>(), Mock.Of<IBrowser>(), Mock.Of<IFrame>(), Mock.Of<IContextMenuParams>(), Mock.Of<IMenuModel>(), Mock.Of<IRunContextMenuCallback>());
|
||||||
|
|
||||||
|
Assert.IsFalse(command);
|
||||||
|
Assert.IsFalse(run);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props" Condition="Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props')" />
|
||||||
|
<Import Project="..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props" Condition="Exists('..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props')" />
|
||||||
|
<Import Project="..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props" Condition="Exists('..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props')" />
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props')" />
|
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props')" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
@ -86,6 +89,7 @@
|
||||||
<Compile Include="Filters\RuleFactoryTests.cs" />
|
<Compile Include="Filters\RuleFactoryTests.cs" />
|
||||||
<Compile Include="Filters\Rules\RegexRuleTests.cs" />
|
<Compile Include="Filters\Rules\RegexRuleTests.cs" />
|
||||||
<Compile Include="Filters\Rules\SimplifiedRuleTests.cs" />
|
<Compile Include="Filters\Rules\SimplifiedRuleTests.cs" />
|
||||||
|
<Compile Include="Handlers\ContextMenuHandlerTests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -118,6 +122,11 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props'))" />
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props'))" />
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets'))" />
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.79.1.36\build\cef.redist.x64.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.79.1.36\build\cef.redist.x86.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.props'))" />
|
||||||
|
<Error Condition="!Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" />
|
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" />
|
||||||
|
<Import Project="..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets" Condition="Exists('..\packages\CefSharp.Common.79.1.360\build\CefSharp.Common.targets')" />
|
||||||
</Project>
|
</Project>
|
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Castle.Core" version="4.4.0" targetFramework="net472" />
|
<package id="Castle.Core" version="4.4.0" targetFramework="net472" />
|
||||||
|
<package id="cef.redist.x64" version="79.1.36" targetFramework="net472" />
|
||||||
|
<package id="cef.redist.x86" version="79.1.36" targetFramework="net472" />
|
||||||
|
<package id="CefSharp.Common" version="79.1.360" targetFramework="net472" />
|
||||||
<package id="Moq" version="4.13.1" targetFramework="net472" />
|
<package id="Moq" version="4.13.1" targetFramework="net472" />
|
||||||
<package id="MSTest.TestAdapter" version="2.1.0" targetFramework="net472" />
|
<package id="MSTest.TestAdapter" version="2.1.0" targetFramework="net472" />
|
||||||
<package id="MSTest.TestFramework" version="2.1.0" targetFramework="net472" />
|
<package id="MSTest.TestFramework" version="2.1.0" targetFramework="net472" />
|
||||||
|
|
|
@ -113,6 +113,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.Browser.AdditionalWindow.RelativeHeight = 100;
|
settings.Browser.AdditionalWindow.RelativeHeight = 100;
|
||||||
settings.Browser.AdditionalWindow.RelativeWidth = 50;
|
settings.Browser.AdditionalWindow.RelativeWidth = 50;
|
||||||
settings.Browser.AdditionalWindow.ShowReloadWarning = false;
|
settings.Browser.AdditionalWindow.ShowReloadWarning = false;
|
||||||
|
settings.Browser.AdditionalWindow.ShowToolbar = false;
|
||||||
settings.Browser.AllowConfigurationDownloads = true;
|
settings.Browser.AllowConfigurationDownloads = true;
|
||||||
settings.Browser.AllowCustomDownloadLocation = false;
|
settings.Browser.AllowCustomDownloadLocation = false;
|
||||||
settings.Browser.AllowDownloads = true;
|
settings.Browser.AllowDownloads = true;
|
||||||
|
@ -133,6 +134,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||||
settings.Browser.MainWindow.RelativeHeight = 100;
|
settings.Browser.MainWindow.RelativeHeight = 100;
|
||||||
settings.Browser.MainWindow.RelativeWidth = 100;
|
settings.Browser.MainWindow.RelativeWidth = 100;
|
||||||
settings.Browser.MainWindow.ShowReloadWarning = true;
|
settings.Browser.MainWindow.ShowReloadWarning = true;
|
||||||
|
settings.Browser.MainWindow.ShowToolbar = false;
|
||||||
settings.Browser.PopupPolicy = PopupPolicy.Allow;
|
settings.Browser.PopupPolicy = PopupPolicy.Allow;
|
||||||
settings.Browser.Proxy.Policy = ProxyPolicy.System;
|
settings.Browser.Proxy.Policy = ProxyPolicy.System;
|
||||||
settings.Browser.StartUrl = "https://www.safeexambrowser.org/start";
|
settings.Browser.StartUrl = "https://www.safeexambrowser.org/start";
|
||||||
|
|
Loading…
Reference in a new issue