FreeCAD

Форк
0
/
VRMLObject.cpp 
97 строк · 3.3 Кб
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2

3
/***************************************************************************
4
 *   Copyright (c) 2024 Werner Mayer <wmayer[at]users.sourceforge.net>     *
5
 *                                                                         *
6
 *   This file is part of FreeCAD.                                         *
7
 *                                                                         *
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.                       *
12
 *                                                                         *
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.                       *
17
 *                                                                         *
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/>.                                      *
21
 *                                                                         *
22
 **************************************************************************/
23

24
#include "gtest/gtest.h"
25
#include "gmock/gmock.h"
26

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>
32

33
// NOLINTBEGIN
34

35
class VRMLObjectTest: public ::testing::Test
36
{
37
protected:
38
    static void SetUpTestSuite()
39
    {
40
        tests::initApplication();
41
    }
42

43
    void SetUp() override
44
    {
45
        document = App::GetApplication().openDocument(fileName().c_str());
46
    }
47

48
    void TearDown() override
49
    {
50
        if (document) {
51
            App::GetApplication().closeDocument(document->getName());
52
        }
53
    }
54

55
    std::string fileName() const
56
    {
57
        std::string resDir(DATADIR);
58
        resDir.append("/tests/TestVRMLTextures.FCStd");
59
        return resDir;
60
    }
61

62
    App::Document* getDocument() const
63
    {
64
        return document;
65
    }
66

67
private:
68
    App::Document* document {};
69
};
70

71
TEST_F(VRMLObjectTest, loadVRMLWithTextures)
72
{
73
    App::Document* doc = getDocument();
74
    ASSERT_TRUE(doc);
75

76
    auto vrml = dynamic_cast<App::VRMLObject*>(doc->getActiveObject());
77
    ASSERT_TRUE(vrml);
78

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"));
87

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());
94
    }
95
}
96

97
// NOLINTEND
98

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.