Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-05-31 16:51:17 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-05-31 16:52:11 +0300
commitf32a18994ad7f37eb568771f01bab9db53d38d54 (patch)
treedc014ea9a34c0d1fc414f1afa937daf1f55a5f97 /tests
parent82276d6cf7d3e18a0e5654d472bdff2b716b0d54 (diff)
parenta481908232ef20449e6ad6951769677e0b108ca8 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'tests')
-rw-r--r--tests/gtests/alembic/CMakeLists.txt5
-rw-r--r--tests/gtests/alembic/abc_export_test.cc120
2 files changed, 123 insertions, 2 deletions
diff --git a/tests/gtests/alembic/CMakeLists.txt b/tests/gtests/alembic/CMakeLists.txt
index c1480910d42..fadf549e212 100644
--- a/tests/gtests/alembic/CMakeLists.txt
+++ b/tests/gtests/alembic/CMakeLists.txt
@@ -26,6 +26,7 @@ set(INC
..
../../../source/blender/blenlib
../../../source/blender/alembic
+ ../../../source/blender/makesdna
${ALEMBIC_INCLUDE_DIRS}
${BOOST_INCLUDE_DIR}
${HDF5_INCLUDE_DIRS}
@@ -44,8 +45,8 @@ else()
endif()
# For motivation on doubling BLENDER_SORTED_LIBS, see ../bmesh/CMakeLists.txt
-BLENDER_SRC_GTEST(abc_matrix "abc_matrix_test.cc;${_buildinfo_src}" "${BLENDER_SORTED_LIBS};${BLENDER_SORTED_LIBS}")
+BLENDER_SRC_GTEST(alembic "abc_matrix_test.cc;abc_export_test.cc;${_buildinfo_src}" "${BLENDER_SORTED_LIBS};${BLENDER_SORTED_LIBS}")
unset(_buildinfo_src)
-setup_liblinks(abc_matrix_test)
+setup_liblinks(alembic_test)
diff --git a/tests/gtests/alembic/abc_export_test.cc b/tests/gtests/alembic/abc_export_test.cc
new file mode 100644
index 00000000000..63c1d179e51
--- /dev/null
+++ b/tests/gtests/alembic/abc_export_test.cc
@@ -0,0 +1,120 @@
+#include "testing/testing.h"
+
+// Keep first since utildefines defines AT which conflicts with fucking STL
+#include "intern/abc_util.h"
+#include "intern/abc_exporter.h"
+
+extern "C" {
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+#include "DNA_scene_types.h"
+}
+
+class TestableAbcExporter : public AbcExporter {
+public:
+ TestableAbcExporter(Scene *scene, const char *filename, ExportSettings &settings)
+ : AbcExporter(scene, filename, settings)
+ {}
+
+ void getShutterSamples(unsigned int nr_of_samples,
+ bool time_relative,
+ std::vector<double> &samples)
+ {
+ AbcExporter::getShutterSamples(nr_of_samples, time_relative, samples);
+ }
+
+ void getFrameSet(unsigned int nr_of_samples,
+ std::set<double> &frames) {
+ AbcExporter::getFrameSet(nr_of_samples, frames);
+ }
+
+};
+
+
+TEST(abc_export, TimeSamplesFullShutter) {
+ ExportSettings settings;
+ settings.frame_start = 31.0;
+ settings.frame_end = 223.0;
+ settings.shutter_open = 0.0;
+ settings.shutter_close = 1.0;
+
+ /* Fake a 25 FPS scene with a nonzero base (because that's sometimes forgotten) */
+ Scene scene;
+ scene.r.frs_sec = 50;
+ scene.r.frs_sec_base = 2;
+
+ TestableAbcExporter exporter(&scene, "somefile.abc", settings);
+ std::vector<double> samples;
+
+ /* test 5 samples per frame */
+ exporter.getShutterSamples(5, true, samples);
+ EXPECT_EQ(5, samples.size());
+ EXPECT_NEAR(1.240, samples[0], 1e-5f);
+ EXPECT_NEAR(1.248, samples[1], 1e-5f);
+ EXPECT_NEAR(1.256, samples[2], 1e-5f);
+ EXPECT_NEAR(1.264, samples[3], 1e-5f);
+ EXPECT_NEAR(1.272, samples[4], 1e-5f);
+
+ /* test same, but using frame number offset instead of time */
+ exporter.getShutterSamples(5, false, samples);
+ EXPECT_EQ(5, samples.size());
+ EXPECT_NEAR(0.0, samples[0], 1e-5f);
+ EXPECT_NEAR(0.2, samples[1], 1e-5f);
+ EXPECT_NEAR(0.4, samples[2], 1e-5f);
+ EXPECT_NEAR(0.6, samples[3], 1e-5f);
+ EXPECT_NEAR(0.8, samples[4], 1e-5f);
+
+ /* use the same setup to test getFrameSet() */
+ std::set<double> frames;
+ exporter.getFrameSet(5, frames);
+ EXPECT_EQ(965, frames.size());
+ EXPECT_EQ(1, frames.count(31.0));
+ EXPECT_EQ(1, frames.count(31.2));
+ EXPECT_EQ(1, frames.count(31.4));
+ EXPECT_EQ(1, frames.count(31.6));
+ EXPECT_EQ(1, frames.count(31.8));
+}
+
+
+TEST(abc_export, TimeSamples180degShutter) {
+ ExportSettings settings;
+ settings.frame_start = 31.0;
+ settings.frame_end = 223.0;
+ settings.shutter_open = -0.25;
+ settings.shutter_close = 0.25;
+
+ /* Fake a 25 FPS scene with a nonzero base (because that's sometimes forgotten) */
+ Scene scene;
+ scene.r.frs_sec = 50;
+ scene.r.frs_sec_base = 2;
+
+ TestableAbcExporter exporter(&scene, "somefile.abc", settings);
+ std::vector<double> samples;
+
+ /* test 5 samples per frame */
+ exporter.getShutterSamples(5, true, samples);
+ EXPECT_EQ(5, samples.size());
+ EXPECT_NEAR(1.230, samples[0], 1e-5f);
+ EXPECT_NEAR(1.234, samples[1], 1e-5f);
+ EXPECT_NEAR(1.238, samples[2], 1e-5f);
+ EXPECT_NEAR(1.242, samples[3], 1e-5f);
+ EXPECT_NEAR(1.246, samples[4], 1e-5f);
+
+ /* test same, but using frame number offset instead of time */
+ exporter.getShutterSamples(5, false, samples);
+ EXPECT_EQ(5, samples.size());
+ EXPECT_NEAR(-0.25, samples[0], 1e-5f);
+ EXPECT_NEAR(-0.15, samples[1], 1e-5f);
+ EXPECT_NEAR(-0.05, samples[2], 1e-5f);
+ EXPECT_NEAR( 0.05, samples[3], 1e-5f);
+ EXPECT_NEAR( 0.15, samples[4], 1e-5f);
+
+ /* Use the same setup to test getFrameSet().
+ * Here only a few numbers are tested, due to rounding issues. */
+ std::set<double> frames;
+ exporter.getFrameSet(5, frames);
+ EXPECT_EQ(965, frames.size());
+ EXPECT_EQ(1, frames.count(30.75));
+ EXPECT_EQ(1, frames.count(30.95));
+ EXPECT_EQ(1, frames.count(31.15));
+}