1
// SPDX-License-Identifier: LGPL-2.1-or-later
3
/***************************************************************************
4
* Copyright (c) 2024 Werner Mayer <wmayer[at]users.sourceforge.net> *
6
* This file is part of FreeCAD. *
8
* FreeCAD is free software: you can redistribute it and/or modify it *
9
* under the terms of the GNU Lesser General Public License as *
10
* published by the Free Software Foundation, either version 2.1 of the *
11
* License, or (at your option) any later version. *
13
* FreeCAD is distributed in the hope that it will be useful, but *
14
* WITHOUT ANY WARRANTY; without even the implied warranty of *
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16
* Lesser General Public License for more details. *
18
* You should have received a copy of the GNU Lesser General Public *
19
* License along with FreeCAD. If not, see *
20
* <https://www.gnu.org/licenses/>. *
22
**************************************************************************/
24
#include "gtest/gtest.h"
25
#include "gmock/gmock.h"
27
#include <App/Application.h>
28
#include <App/Document.h>
29
#include <App/VRMLObject.h>
30
#include <Base/FileInfo.h>
31
#include <src/App/InitApplication.h>
35
class VRMLObjectTest: public ::testing::Test
38
static void SetUpTestSuite()
40
tests::initApplication();
45
document = App::GetApplication().openDocument(fileName().c_str());
48
void TearDown() override
51
App::GetApplication().closeDocument(document->getName());
55
std::string fileName() const
57
std::string resDir(DATADIR);
58
resDir.append("/tests/TestVRMLTextures.FCStd");
62
App::Document* getDocument() const
68
App::Document* document {};
71
TEST_F(VRMLObjectTest, loadVRMLWithTextures)
73
App::Document* doc = getDocument();
76
auto vrml = dynamic_cast<App::VRMLObject*>(doc->getActiveObject());
79
auto res = vrml->Resources.getValues();
80
EXPECT_EQ(res.size(), 6);
81
EXPECT_EQ(res[0], std::string("FreeCAD/FreeCAD1.png"));
82
EXPECT_EQ(res[1], std::string("FreeCAD/FreeCAD2.png"));
83
EXPECT_EQ(res[2], std::string("FreeCAD/FreeCAD3.png"));
84
EXPECT_EQ(res[3], std::string("FreeCAD/FreeCAD4.png"));
85
EXPECT_EQ(res[4], std::string("FreeCAD/FreeCAD5.png"));
86
EXPECT_EQ(res[5], std::string("FreeCAD/FreeCAD6.png"));
88
auto url = vrml->Urls.getValues();
89
EXPECT_EQ(url.size(), 6);
90
for (const auto& it : url) {
91
Base::FileInfo fi(it);
92
EXPECT_TRUE(fi.isFile());
93
EXPECT_TRUE(fi.exists());