添加单元测试

dev-VirtualTexture
wuyize 2023-02-07 20:50:31 +08:00
parent 55f37fd284
commit b562ff5053
8 changed files with 272 additions and 2 deletions

View File

@ -9,24 +9,51 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FramelessHelperCore", "Fram
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FramelessHelperWidgets", "FramelessHelper\qmake\FramelessHelperWidgets\FramelessHelperWidgets.vcxproj", "{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FramelessHelperWidgets", "FramelessHelper\qmake\FramelessHelperWidgets\FramelessHelperWidgets.vcxproj", "{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{C81742B7-2428-4329-BEA8-01E4B985810A}"
ProjectSection(ProjectDependencies) = postProject
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709} = {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64 Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Debug|x64.ActiveCfg = Debug|x64 {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Debug|x64.ActiveCfg = Debug|x64
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Debug|x64.Build.0 = Debug|x64 {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Debug|x64.Build.0 = Debug|x64
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Debug|x86.ActiveCfg = Debug|x64
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Debug|x86.Build.0 = Debug|x64
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x64.ActiveCfg = Release|x64 {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x64.ActiveCfg = Release|x64
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x64.Build.0 = Release|x64 {3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x64.Build.0 = Release|x64
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x86.ActiveCfg = Release|x64
{3FE96A33-2BB7-4686-A710-3EB8E3BBD709}.Release|x86.Build.0 = Release|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x64.ActiveCfg = Debug|x64 {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x64.ActiveCfg = Debug|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x64.Build.0 = Debug|x64 {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x64.Build.0 = Debug|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x86.ActiveCfg = Debug|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Debug|x86.Build.0 = Debug|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x64.ActiveCfg = Release|x64 {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x64.ActiveCfg = Release|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x64.Build.0 = Release|x64 {954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x64.Build.0 = Release|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x86.ActiveCfg = Release|x64
{954D3D24-DF86-33A3-8867-D1735CCBDB10}.Release|x86.Build.0 = Release|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x64.ActiveCfg = Debug|x64 {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x64.ActiveCfg = Debug|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x64.Build.0 = Debug|x64 {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x64.Build.0 = Debug|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x86.ActiveCfg = Debug|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Debug|x86.Build.0 = Debug|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x64.ActiveCfg = Release|x64 {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x64.ActiveCfg = Release|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x64.Build.0 = Release|x64 {E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x64.Build.0 = Release|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x86.ActiveCfg = Release|x64
{E7A71E05-4AA5-31DB-A17D-542FC7BD83A3}.Release|x86.Build.0 = Release|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Debug|x64.ActiveCfg = Debug|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Debug|x64.Build.0 = Debug|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Debug|x86.ActiveCfg = Debug|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Debug|x86.Build.0 = Debug|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Release|x64.ActiveCfg = Release|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Release|x64.Build.0 = Release|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Release|x86.ActiveCfg = Release|x64
{C81742B7-2428-4329-BEA8-01E4B985810A}.Release|x86.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -32,7 +32,7 @@
</ImportGroup> </ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>5.15.2_msvc2019_64</QtInstall> <QtInstall>5.15.2_msvc2019_64</QtInstall>
<QtModules>core;xml;gui;svg;widgets;winextras</QtModules> <QtModules>core;xml;gui;svg;widgets;</QtModules>
<QtBuildConfig>debug</QtBuildConfig> <QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
@ -68,7 +68,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<LanguageStandard>stdcpp20</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>$(SolutionDir)ArchitectureColoredPainting\src\Editor\RightBar;$(SolutionDir)ArchitectureColoredPainting\src\Editor\;$(SolutionDir)QGoodWindow;$(SolutionDir)FramelessHelper\include;$(SolutionDir)FramelessHelper\qmake\inc\core;$(SolutionDir)FramelessHelper\include\FramelessHelper\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)ArchitectureColoredPainting\src\Editor\RightBar;$(SolutionDir)ArchitectureColoredPainting\src\Editor\;$(SolutionDir)FramelessHelper\include;$(SolutionDir)FramelessHelper\qmake\inc\core;$(SolutionDir)FramelessHelper\include\FramelessHelper\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>FRAMELESSHELPER_WIDGETS_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>FRAMELESSHELPER_WIDGETS_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@ -0,0 +1,11 @@
<#@ template language="c#" hostspecific="true" #>
<#@ output extension=".runsettings" #>
<#@ parameter type="System.String" name="QtDllPath" #>
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<PATH>%PATH%;<#= QtDllPath #></PATH>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<PATH>%PATH%;E:/Qt/5.15.2/msvc2019_64/bin</PATH>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>

34
UnitTest/UnitTest.cpp Normal file
View File

@ -0,0 +1,34 @@
#include "CppUnitTest.h"
#include "MainWindow.h"
#include <QGuiApplication>
#include <QtWidgets/QApplication>
#include <FramelessHelper/Core/private/framelessconfig_p.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest
{
TEST_CLASS(UnitTest)
{
public:
TEST_METHOD(TestMethod1)
{
FRAMELESSHELPER_USE_NAMESPACE
FramelessHelper::Core::initialize();
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
char arg[] = "";
char* argv[] = { arg };
int argc = 1;
QApplication a(argc, argv);
FramelessHelper::Core::setApplicationOSThemeAware();
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
MainWindow w;
w.show();
a.exec();
}
};
}

28
UnitTest/UnitTest.ui Normal file
View File

@ -0,0 +1,28 @@
<UI version="4.0" >
<class>UnitTestClass</class>
<widget class="QMainWindow" name="UnitTestClass" >
<property name="objectName" >
<string notr="true">UnitTestClass</string>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle" >
<string>UnitTest</string>
</property> <widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources>
<include location="UnitTest.qrc"/>
</resources>
<connections/>
</UI>

126
UnitTest/UnitTest.vcxproj Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C81742B7-2428-4329-BEA8-01E4B985810A}</ProjectGuid>
<Keyword>QtVS_v304</Keyword>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>5.15.2_msvc2019_64</QtInstall>
<QtModules>core;xml;gui;svg;widgets;</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
<QtInstall>5.15.2_msvc2019_64</QtInstall>
<QtModules>core;gui;widgets</QtModules>
<QtBuildConfig>release</QtBuildConfig>
</PropertyGroup>
<PropertyGroup>
<RunSettingsFilePath>$(MSBuildProjectDirectory)\Qt.$(Platform).runsettings</RunSettingsFilePath>
<TransformOnBuild>true</TransformOnBuild>
</PropertyGroup>
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
</Target>
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(QtMsBuild)\Qt.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(QtMsBuild)\Qt.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;$(SolutionDIr)ArchitectureColoredPainting;$(SolutionDIr)ArchitectureColoredPainting\src;$(SolutionDir)ArchitectureColoredPainting\src\Editor\RightBar;$(SolutionDir)ArchitectureColoredPainting\src\Editor\;$(SolutionDIr)ArchitectureColoredPainting\x64\Debug\uic;$(SolutionDir)FramelessHelper\include;$(SolutionDir)FramelessHelper\qmake\inc\core;$(SolutionDir)FramelessHelper\include\FramelessHelper\Core;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>FRAMELESSHELPER_WIDGETS_STATIC;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>$(SolutionDIr)ArchitectureColoredPainting\x64\Debug\*.obj;$(SolutionDIr)FramelessHelper\qmake\FramelessHelperCore\debug\FramelessHelperCore.lib;$(SolutionDIr)FramelessHelper\qmake\FramelessHelperWidgets\debug\FramelessHelperWidgets.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;$(SolutionDIr)ArchitectureColoredPainting\ArchitectureColoredPainting;$(SolutionDIr)ArchitectureColoredPainting\ArchitectureColoredPainting\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ClCompile>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ClCompile>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>None</DebugInformationFormat>
<Optimization>MaxSpeed</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<QtUic Include="UnitTest.ui" />
<ClCompile Include="UnitTest.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="Qt.runsettings.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<OutputFileName>$(MSBuildProjectDirectory)\Qt.$(Platform).runsettings</OutputFileName>
</None>
<T4ParameterValues Include="QtDllPath">
<Value>$(QtDllPath)</Value>
</T4ParameterValues>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
<Import Project="$(QtMsBuild)\qt.targets" />
</ImportGroup>
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TextTemplating\Microsoft.TextTemplating.targets" />
</Project>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions>
</Filter>
<Filter Include="Translation Files">
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<QtUic Include="UnitTest.ui">
<Filter>Form Files</Filter>
</QtUic>
<ClCompile Include="UnitTest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Qt.runsettings.tt" />
</ItemGroup>
</Project>