1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2021, assimp team
7 
8 
9 
10 All rights reserved.
11 
12 Redistribution and use of this software in source and binary forms,
13 with or without modification, are permitted provided that the following
14 conditions are met:
15 
16 * Redistributions of source code must retain the above
17 copyright notice, this list of conditions and the
18 following disclaimer.
19 
20 * Redistributions in binary form must reproduce the above
21 copyright notice, this list of conditions and the
22 following disclaimer in the documentation and/or other
23 materials provided with the distribution.
24 
25 * Neither the name of the assimp team, nor the names of its
26 contributors may be used to endorse or promote products
27 derived from this software without specific prior
28 written permission of the assimp team.
29 
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ---------------------------------------------------------------------------
42 */
43 #include "UnitTestPCH.h"
44 
45 #include <assimp/scene.h>
46 #include <assimp/Importer.hpp>
47 #include <assimp/Exporter.hpp>
48 #include <assimp/postprocess.h>
49 
50 #include "TestModelFactory.h"
51 
52 using namespace Assimp;
53 
54 class utIssues : public ::testing::Test {
55     // empty
56 };
57 
58 #ifndef ASSIMP_BUILD_NO_EXPORT
59 
TEST_F(utIssues,OpacityBugWhenExporting_727)60 TEST_F( utIssues, OpacityBugWhenExporting_727 ) {
61     float opacity;
62     aiScene *scene( TestModelFacttory::createDefaultTestModel( opacity ) );
63     Assimp::Importer importer;
64     Assimp::Exporter exporter;
65 
66     std::string path = "dae";
67     const aiExportFormatDesc *desc = exporter.GetExportFormatDescription( 0 );
68     EXPECT_NE( desc, nullptr );
69     path.append(".");
70     path.append( desc->fileExtension );
71     EXPECT_EQ( AI_SUCCESS, exporter.Export( scene, desc->id, path ) );
72     const aiScene *newScene( importer.ReadFile( path, aiProcess_ValidateDataStructure ) );
73     ASSERT_NE( nullptr, newScene );
74     float newOpacity;
75     if ( newScene->mNumMaterials > 0 ) {
76         std::cout << "Desc = " << desc->description << "\n";
77         EXPECT_EQ( AI_SUCCESS, newScene->mMaterials[ 0 ]->Get( AI_MATKEY_OPACITY, newOpacity ) );
78         EXPECT_FLOAT_EQ( opacity, newOpacity );
79     }
80     delete scene;
81 }
82 
83 #endif // ASSIMP_BUILD_NO_EXPORT
84