[Sketcher] [gtest] Add SketchObject test
Create a document and then add a `SketchObject` to it. Does not work without creating document. Also `FCConfig.h` is needed for `FC_OS_WIN32`.
This commit is contained in:
committed by
Chris Hennes
parent
a52bc93da0
commit
76834f6a13
@@ -42,5 +42,5 @@ target_link_libraries(Tests_run gtest_main ${Google_Tests_LIBS} FreeCADApp)
|
||||
|
||||
add_executable(Sketcher_tests_run)
|
||||
add_subdirectory(src/Mod/Sketcher)
|
||||
target_include_directories(Sketcher_tests_run PUBLIC ${EIGEN3_INCLUDE_DIR})
|
||||
target_include_directories(Sketcher_tests_run PUBLIC ${EIGEN3_INCLUDE_DIR} ${OCC_INCLUDE_DIR} ${Python3_INCLUDE_DIRS})
|
||||
target_link_libraries(Sketcher_tests_run gtest_main ${Google_Tests_LIBS} Sketcher)
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
target_sources(
|
||||
Sketcher_tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/SketchObject.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(planegcs)
|
||||
|
||||
50
tests/src/Mod/Sketcher/App/SketchObject.cpp
Normal file
50
tests/src/Mod/Sketcher/App/SketchObject.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <FCConfig.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Mod/Sketcher/App/SketchObject.h>
|
||||
|
||||
class SketchObjectTest: public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
static void SetUpTestSuite()
|
||||
{
|
||||
if (App::Application::GetARGC() == 0) {
|
||||
int argc = 1;
|
||||
char* argv[] = {"FreeCAD"};
|
||||
App::Application::Config()["ExeName"] = "FreeCAD";
|
||||
App::Application::init(argc, argv);
|
||||
}
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
_docName = App::GetApplication().getUniqueDocumentName("test");
|
||||
auto _doc = App::GetApplication().newDocument(_docName.c_str(), "testUser");
|
||||
// TODO: Do we add a body first, or is just adding sketch sufficient for this test?
|
||||
_sketchobj = static_cast<Sketcher::SketchObject*>(_doc->addObject("Sketcher::SketchObject"));
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
App::GetApplication().closeDocument(_docName.c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO: use shared_ptr or something else here?
|
||||
Sketcher::SketchObject* _sketchobj;
|
||||
std::string _docName;
|
||||
};
|
||||
|
||||
TEST_F(SketchObjectTest, createSketchObject) // NOLINT
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Act
|
||||
|
||||
// Assert
|
||||
}
|
||||
Reference in New Issue
Block a user