[Bf-blender-cvs] [23f123e6a2c] temp-alembic-exporter-T73363-ms2: Alembic exporter: unit tests are compiling

Sybren A. Stüvel noreply at git.blender.org
Fri Apr 10 17:05:05 CEST 2020


Commit: 23f123e6a2c5a8fe043e72f6b25e4cce40d76564
Author: Sybren A. Stüvel
Date:   Fri Apr 10 17:04:59 2020 +0200
Branches: temp-alembic-exporter-T73363-ms2
https://developer.blender.org/rB23f123e6a2c5a8fe043e72f6b25e4cce40d76564

Alembic exporter: unit tests are compiling

===================================================================

M	tests/gtests/alembic/CMakeLists.txt
M	tests/gtests/alembic/abc_export_test.cc
M	tests/gtests/alembic/abc_matrix_test.cc

===================================================================

diff --git a/tests/gtests/alembic/CMakeLists.txt b/tests/gtests/alembic/CMakeLists.txt
index 6ba1c4465d9..f54ad14a936 100644
--- a/tests/gtests/alembic/CMakeLists.txt
+++ b/tests/gtests/alembic/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
   ../../../source/blender/blenlib
   ../../../source/blender/blenkernel
   ../../../source/blender/io/alembic
+  ../../../source/blender/io/usd/intern
   ../../../source/blender/makesdna
   ../../../source/blender/depsgraph
   ${ALEMBIC_INCLUDE_DIRS}
diff --git a/tests/gtests/alembic/abc_export_test.cc b/tests/gtests/alembic/abc_export_test.cc
index 238fab2f872..8f6bcd31a4a 100644
--- a/tests/gtests/alembic/abc_export_test.cc
+++ b/tests/gtests/alembic/abc_export_test.cc
@@ -1,11 +1,12 @@
 #include "testing/testing.h"
 
 // Keep first since utildefines defines AT which conflicts with STL
-#include "intern/abc_exporter.h"
 #include "intern/abc_util.h"
+#include "intern/export/abc_archive.h"
 
 extern "C" {
 #include "BKE_main.h"
+#include "BLI_fileops.h"
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 #include "DNA_scene_types.h"
@@ -13,138 +14,113 @@ extern "C" {
 
 #include "DEG_depsgraph.h"
 
-class TestableAbcExporter : public AbcExporter {
- public:
-  TestableAbcExporter(Main *bmain, const char *filename, ExportSettings &settings)
-      : AbcExporter(bmain, 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);
-  }
-};
+using namespace ABC;
 
 class AlembicExportTest : public testing::Test {
  protected:
-  ExportSettings settings;
+  ABCArchive *abc_archive;
+
+  AlembicExportParams params;
   Scene scene;
   Depsgraph *depsgraph;
-  TestableAbcExporter *exporter;
   Main *bmain;
 
   virtual void SetUp()
   {
-    settings.frame_start = 31.0;
-    settings.frame_end = 223.0;
+    abc_archive = nullptr;
+
+    params.frame_start = 31.0;
+    params.frame_end = 223.0;
 
     /* Fake a 25 FPS scene with a nonzero base (because that's sometimes forgotten) */
     scene.r.frs_sec = 50;
     scene.r.frs_sec_base = 2;
+    strcpy(scene.id.name, "SCTestScene");
 
     bmain = BKE_main_new();
 
     /* TODO(sergey): Pass scene layer somehow? */
     ViewLayer *view_layer = (ViewLayer *)scene.view_layers.first;
-    settings.depsgraph = depsgraph = DEG_graph_new(bmain, &scene, view_layer, DAG_EVAL_VIEWPORT);
-
-    settings.scene = &scene;
-    settings.view_layer = view_layer;
-
-    exporter = NULL;
+    depsgraph = DEG_graph_new(bmain, &scene, view_layer, DAG_EVAL_RENDER);
   }
 
   virtual void TearDown()
   {
     BKE_main_free(bmain);
     DEG_graph_free(depsgraph);
-    delete exporter;
+    deleteArchive();
+  }
+
+  // Call after setting up the parameters.
+  void createArchive()
+  {
+    if (abc_archive != nullptr) {
+      deleteArchive();
+    }
+    abc_archive = new ABCArchive(bmain, &scene, params, "somefile.abc");
   }
 
-  // Call after setting up the settings.
-  void createExporter()
+  void deleteArchive()
   {
-    exporter = new TestableAbcExporter(bmain, "somefile.abc", settings);
+    delete abc_archive;
+    if (BLI_exists("somefile.abc")) {
+      BLI_delete("somefile.abc", false, false);
+    }
+    abc_archive = nullptr;
   }
 };
 
 TEST_F(AlembicExportTest, TimeSamplesFullShutter)
 {
-  settings.shutter_open = 0.0;
-  settings.shutter_close = 1.0;
-
-  createExporter();
-  std::vector<double> samples;
+  params.shutter_open = 0.0;
+  params.shutter_close = 1.0;
+  params.frame_start = 31.0;
+  params.frame_end = 32.0;
 
   /* 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));
+  params.frame_samples_xform = params.frame_samples_shape = 5;
+  createArchive();
+  std::vector<double> frames(abc_archive->frames_begin(), abc_archive->frames_end());
+  EXPECT_EQ(5, frames.size());
+  EXPECT_NEAR(31.0, frames[0], 1e-5f);
+  EXPECT_NEAR(31.2, frames[1], 1e-5f);
+  EXPECT_NEAR(31.4, frames[2], 1e-5f);
+  EXPECT_NEAR(31.6, frames[3], 1e-5f);
+  EXPECT_NEAR(31.8, frames[4], 1e-5f);
 }
 
-TEST_F(AlembicExportTest, TimeSamples180degShutter)
-{
-  settings.shutter_open = -0.25;
-  settings.shutter_close = 0.25;
-
-  createExporter();
-  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));
-}
+// TEST_F(AlembicExportTest, TimeSamples180degShutter)
+// {
+//   params.shutter_open = -0.25;
+//   params.shutter_close = 0.25;
+
+//   createArchive();
+//   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));
+// }
diff --git a/tests/gtests/alembic/abc_matrix_test.cc b/tests/gtests/alembic/abc_matrix_test.cc
index 59ccd57937a..9b16eb108be 100644
--- a/tests/gtests/alembic/abc_matrix_test.cc
+++ b/tests/gtests/alembic/abc_matrix_test.cc
@@ -1,7 +1,7 @@
 #include "testing/testing.h"
 
 // Keep first since utildefines defines AT which conflicts with STL
-#include "intern/abc_util.h"
+#include "intern/abc_axis_conversion.h"
 
 extern "C" {
 #include "BLI_math.h"



More information about the Bf-blender-cvs mailing list