diff --git a/include/OpenColorIO/OpenColorIO.h b/include/OpenColorIO/OpenColorIO.h index b7183ce77..66c62ec44 100644 --- a/include/OpenColorIO/OpenColorIO.h +++ b/include/OpenColorIO/OpenColorIO.h @@ -852,6 +852,9 @@ class OCIOEXPORT Config * \ref Config::validate will throw if the config does not contain * the matching display color space. */ + + bool viewIsShared(const char * dispName, const char * viewName) const; + /// Will throw if view or colorSpaceName are null or empty. void addSharedView(const char * view, const char * viewTransformName, const char * colorSpaceName, const char * looks, @@ -859,6 +862,8 @@ class OCIOEXPORT Config /// Remove a shared view. Will throw if the view does not exist. void removeSharedView(const char * view); + void clearSharedViews(); + const char * getDefaultDisplay() const; int getNumDisplays() const; /// Will return "" if the index is invalid. @@ -883,6 +888,11 @@ class OCIOEXPORT Config int getNumViews(const char * display, const char * colorspaceName) const; const char * getView(const char * display, const char * colorspaceName, int index) const; + static bool viewsAreEqual(const ConstConfigRcPtr & first, + const ConstConfigRcPtr & second, + const char * dispName, + const char * viewName); + /** * Returns the view_transform attribute of the (display, view) pair. View can * be a shared view of the display. If display is null or empty, config shared views are used. @@ -900,6 +910,8 @@ class OCIOEXPORT Config /// Returns the description attribute of a (display, view) pair. const char * getDisplayViewDescription(const char * display, const char * view) const noexcept; + bool displayHasView(const char * dispName, const char * viewName) const; + /** * For the (display, view) pair, specify which color space and look to use. * If a look is not desired, then just pass a null or empty string. @@ -963,6 +975,9 @@ class OCIOEXPORT Config * */ + bool hasVirtualView(const char * viewName) const; + bool virtualViewIsShared(const char * viewName) const; + void addVirtualDisplayView(const char * view, const char * viewTransformName, const char * colorSpaceName, @@ -977,6 +992,10 @@ class OCIOEXPORT Config /// Get the view name at a specific index. const char * getVirtualDisplayView(ViewType type, int index) const noexcept; + static bool virtualViewsAreEqual(const ConstConfigRcPtr & first, + const ConstConfigRcPtr & second, + const char * viewName); + const char * getVirtualDisplayViewTransformName(const char * view) const noexcept; const char * getVirtualDisplayViewColorSpaceName(const char * view) const noexcept; const char * getVirtualDisplayViewLooks(const char * view) const noexcept; diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index 3bde3abb9..9204159d8 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -3305,6 +3305,23 @@ void Config::setViewingRules(ConstViewingRulesRcPtr viewingRules) getImpl()->resetCacheIDs(); } +bool Config::viewIsShared(const char * dispName, const char * viewName) const +{ + // Check if a view within a given display is a display-defined view or is referencing + // one of the config's shared views. + + for (int v = 0; v < getNumViews(VIEW_SHARED, dispName); v++) + { + const char * sharedViewName = getView(VIEW_SHARED, dispName, v); + if (sharedViewName && *sharedViewName && Platform::Strcasecmp(sharedViewName, viewName) == 0) + { + return true; + } + } + + return false; +} + void Config::addSharedView(const char * view, const char * viewTransform, const char * colorSpace, const char * looks, const char * rule, const char * description) @@ -3358,6 +3375,19 @@ void Config::removeSharedView(const char * view) } } +void Config::clearSharedViews() +{ + int numViews = getNumViews(VIEW_SHARED, nullptr); + for (int v = numViews - 1; v >= 0; v--) + { + const char * sharedViewName = getView(VIEW_SHARED, nullptr, v); + if (sharedViewName && *sharedViewName) + { + removeSharedView(sharedViewName); + } + } +} + const char * Config::getDefaultDisplay() const { return getDisplay(0); @@ -3487,6 +3517,43 @@ const char * Config::getView(const char * display, const char * colorspace, int return ""; } + +bool Config::viewsAreEqual(const ConstConfigRcPtr & first, + const ConstConfigRcPtr & second, + const char * dispName, // may be empty or nullptr for shared views + const char * viewName) +{ + // It's ok to call this even for displays/views that don't exist, it will simply return false. + + // Note that this will return true even if the view is display-defined in one config and a reference + // to a shared view in the other config (both within the same display), as long as the contents match. + + // These calls return null if either the display or view doesn't exist (regardless if it's active). + const char * cs1 = first->getDisplayViewColorSpaceName(dispName, viewName); + const char * cs2 = second->getDisplayViewColorSpaceName(dispName, viewName); + + // If the color space is not null, the display and view exist. + if (cs1 && *cs1 && cs2 && *cs2) + { + // Both configs have a display and view by this name, now check the contents. + if (Platform::Strcasecmp(cs1, cs2) == 0) + { + // Note the remaining strings may be empty in a valid view. + // Intentionally not checking the description since it is not a functional difference. + if ( (Platform::Strcasecmp(first->getDisplayViewLooks(dispName, viewName), + second->getDisplayViewLooks(dispName, viewName)) == 0) && + (Platform::Strcasecmp(first->getDisplayViewTransformName(dispName, viewName), + second->getDisplayViewTransformName(dispName, viewName)) == 0) && + (Platform::Strcasecmp(first->getDisplayViewRule(dispName, viewName), + second->getDisplayViewRule(dispName, viewName)) == 0) ) + { + return true; + } + } + } + return false; +} + const char * Config::getDisplayViewTransformName(const char * display, const char * view) const { const View * viewPtr = getImpl()->getView(display, view); @@ -3525,6 +3592,21 @@ const char * Config::getDisplayViewDescription(const char * display, const char return viewPtr ? viewPtr->m_description.c_str() : ""; } +bool Config::displayHasView(const char * dispName, const char * viewName) const +{ + // This returns null if either the display or view doesn't exist. + // It works regardless of whether the display or view are active, + // and it works regardless of whether the view is display-defined + // or if the display has this as a shared view. + // + // It will only check config level shared views if dispName is null. + // It will not check config level shared views if dispName is not null. + const char * cs = getDisplayViewColorSpaceName(dispName, viewName); + + // All views must have a color space, so if it's not empty, the view exists. + return (cs && *cs); +} + void Config::addDisplaySharedView(const char * display, const char * sharedView) { if (!display || !*display) @@ -3695,6 +3777,28 @@ void Config::clearDisplays() getImpl()->resetCacheIDs(); } +bool Config::hasVirtualView(const char * viewName) const +{ + const char * cs = getVirtualDisplayViewColorSpaceName(viewName); + + // All views must have a color space, so if it's not empty, the view exists. + return (cs && *cs); +} + +bool Config::virtualViewIsShared(const char * viewName) const +{ + for (int v = 0; v < getVirtualDisplayNumViews(VIEW_SHARED); v++) + { + const char * sharedViewName = getVirtualDisplayView(VIEW_SHARED, v); + if (sharedViewName && *sharedViewName && Platform::Strcasecmp(sharedViewName, viewName) == 0) + { + return true; + } + } + + return false; +} + void Config::addVirtualDisplayView(const char * view, const char * viewTransform, const char * colorSpace, @@ -3795,6 +3899,34 @@ const char * Config::getVirtualDisplayView(ViewType type, int index) const noexc return ""; } +bool Config::virtualViewsAreEqual(const ConstConfigRcPtr & first, + const ConstConfigRcPtr & second, + const char * viewName) +{ + const char * cs1 = first->getVirtualDisplayViewColorSpaceName(viewName); + const char * cs2 = second->getVirtualDisplayViewColorSpaceName(viewName); + + // If the color space is not null, the display and view exist. + if (cs1 && *cs1 && cs2 && *cs2) + { + if (Platform::Strcasecmp(cs1, cs2) == 0) + { + // Note the remaining strings may be empty in a valid view. + // Intentionally not checking the description since it is not a functional difference. + if ( (Platform::Strcasecmp(first->getVirtualDisplayViewLooks(viewName), + second->getVirtualDisplayViewLooks(viewName)) == 0) && + (Platform::Strcasecmp(first->getVirtualDisplayViewTransformName(viewName), + second->getVirtualDisplayViewTransformName(viewName)) == 0) && + (Platform::Strcasecmp(first->getVirtualDisplayViewRule(viewName), + second->getVirtualDisplayViewRule(viewName)) == 0) ) + { + return true; + } + } + } + return false; +} + const char * Config::getVirtualDisplayViewTransformName(const char * view) const noexcept { if (!view) return ""; @@ -3812,6 +3944,13 @@ const char * Config::getVirtualDisplayViewColorSpaceName(const char * view) cons { if (!view) return ""; + // TODO: Remove the following work-around once bug for shared views is fixed. + // Get the colorspace name for the case where a virtual view is shared. + if (virtualViewIsShared(view)) + { + return getDisplayViewColorSpaceName(nullptr, view); + } + ViewVec::const_iterator iter = FindView(getImpl()->m_virtualDisplay.m_views, view); if (iter != getImpl()->m_virtualDisplay.m_views.end()) { diff --git a/src/bindings/python/PyConfig.cpp b/src/bindings/python/PyConfig.cpp index 675f7155c..c064c7ee8 100644 --- a/src/bindings/python/PyConfig.cpp +++ b/src/bindings/python/PyConfig.cpp @@ -400,6 +400,8 @@ void bindPyConfig(py::module & m) DOC(Config, addSharedView)) .def("removeSharedView", &Config::removeSharedView, "view"_a, DOC(Config, removeSharedView)) + .def("clearSharedViews", &Config::clearSharedViews, + DOC(Config, clearSharedViews)) .def("getSharedViews", [](ConfigRcPtr & self) { return SharedViewIterator(self); @@ -452,6 +454,9 @@ void bindPyConfig(py::module & m) .def("getDisplayViewDescription", &Config::getDisplayViewDescription, "display"_a, "view"_a, DOC(Config, getDisplayViewDescription)) + .def("displayHasView", &Config::displayHasView, + "display"_a, "view"_a, + DOC(Config, displayHasView)) .def("addDisplayView", (void (Config::*)(const char *, const char *, const char *, const char *)) &Config::addDisplayView, @@ -471,20 +476,35 @@ void bindPyConfig(py::module & m) "ruleName"_a = "", "description"_a = "", DOC(Config, addDisplayView)) + .def("viewIsShared", &Config::viewIsShared, "display"_a, "view"_a, + DOC(Config, viewIsShared)) .def("addDisplaySharedView", &Config::addDisplaySharedView, "display"_a, "view"_a, DOC(Config, addDisplaySharedView)) .def("removeDisplayView", &Config::removeDisplayView, "display"_a, "view"_a, DOC(Config, removeDisplayView)) .def("clearDisplays", &Config::clearDisplays, DOC(Config, clearDisplays)) + .def_static("viewsAreEqual", [](const ConstConfigRcPtr & first, + const ConstConfigRcPtr & second, + const char * dispName, + const char * viewName) + { + return Config::viewsAreEqual(first, second, dispName, viewName); + }, + "first"_a, "second"_a, "dispName"_a, "viewName"_a, + DOC(Config, viewsAreEqual)) // Virtual Display + .def("hasVirtualView", &Config::hasVirtualView, "view"_a, + DOC(Config, hasVirtualView)) .def("addVirtualDisplayView", &Config::addVirtualDisplayView, "view"_a, "viewTransformName"_a, "colorSpaceName"_a, "looks"_a = "", "ruleName"_a = "", "description"_a = "", DOC(Config, addVirtualDisplayView)) + .def("virtualViewIsShared", &Config::virtualViewIsShared, "view"_a, + DOC(Config, virtualViewIsShared)) .def("addVirtualDisplaySharedView", &Config::addVirtualDisplaySharedView, "sharedView"_a, DOC(Config, addVirtualDisplaySharedView)) .def("getVirtualDisplayViews", [](ConfigRcPtr & self, ViewType type) @@ -528,6 +548,14 @@ void bindPyConfig(py::module & m) return false; }, "display"_a) + .def_static("virtualViewsAreEqual", [](const ConstConfigRcPtr & first, + const ConstConfigRcPtr & second, + const char * viewName) + { + return Config::virtualViewsAreEqual(first, second, viewName); + }, + "first"_a, "second"_a, "viewName"_a, + DOC(Config, virtualViewsAreEqual)) // Active Displays and Views .def("setActiveDisplays", &Config::setActiveDisplays, "displays"_a, diff --git a/tests/cpu/Config_tests.cpp b/tests/cpu/Config_tests.cpp index 40ac3742b..1551d3d98 100644 --- a/tests/cpu/Config_tests.cpp +++ b/tests/cpu/Config_tests.cpp @@ -6902,17 +6902,28 @@ OCIO_ADD_TEST(Config, display_view) // Add a simple view. const std::string display{ "display" }; + + OCIO_CHECK_ASSERT(!config->displayHasView(display.c_str(), "view1")); + OCIO_CHECK_NO_THROW(config->addDisplayView(display.c_str(), "view1", "scs", "")); + OCIO_CHECK_ASSERT(config->displayHasView(display.c_str(), "view1")); + OCIO_CHECK_NO_THROW(config->validate()); + OCIO_CHECK_ASSERT(!config->displayHasView(display.c_str(), "view2")); + OCIO_CHECK_NO_THROW(config->addDisplayView(display.c_str(), "view2", "view_transform", "scs", "", "", "")); OCIO_CHECK_THROW_WHAT(config->validate(), OCIO::Exception, "color space, 'scs', that is not a display-referred"); + OCIO_CHECK_ASSERT(config->displayHasView(display.c_str(), "view2")); + OCIO_CHECK_NO_THROW(config->addDisplayView(display.c_str(), "view2", "view_transform", "dcs", "", "", "")); + OCIO_CHECK_ASSERT(config->displayHasView(display.c_str(), "view2")); + OCIO_CHECK_NO_THROW(config->validate()); // Validate how the config is serialized. @@ -7338,7 +7349,10 @@ OCIO_ADD_TEST(Config, add_remove_display) // Add a (display, view) pair. + // todo (annie): just a note here that this config will have two (display, view) pairs): sRGB and disp1 + OCIO_CHECK_NO_THROW(config->addDisplayView("disp1", "view1", "raw", nullptr)); + OCIO_CHECK_ASSERT(config->displayHasView("disp1", "view1")); OCIO_REQUIRE_EQUAL(config->getNumDisplays(), 2); OCIO_CHECK_EQUAL(std::string(config->getDisplay(0)), std::string("sRGB")); OCIO_CHECK_EQUAL(std::string(config->getDisplay(1)), std::string("disp1")); @@ -7347,6 +7361,7 @@ OCIO_ADD_TEST(Config, add_remove_display) // Remove a (display, view) pair. OCIO_CHECK_NO_THROW(config->removeDisplayView("disp1", "view1")); + OCIO_CHECK_ASSERT(!config->displayHasView("disp1", "view1")); OCIO_REQUIRE_EQUAL(config->getNumDisplays(), 1); OCIO_CHECK_EQUAL(std::string(config->getDisplay(0)), std::string("sRGB")); } @@ -8489,15 +8504,28 @@ active_views: [] OCIO_CHECK_EQUAL(2, config->getNumViews(OCIO::VIEW_DISPLAY_DEFINED, "sRGB")); OCIO_CHECK_EQUAL(1, config->getNumViews(OCIO::VIEW_SHARED, "sRGB")); + OCIO_CHECK_EQUAL(std::string("sview1"), config->getView(OCIO::VIEW_SHARED, "sRGB", 0)); + OCIO_CHECK_ASSERT(config->displayHasView("sRGB", "sview1")); + OCIO_CHECK_ASSERT(config->viewIsShared("sRGB", "sview1")); + + OCIO_CHECK_EQUAL(std::string("raw"), config->getDisplayViewColorSpaceName("sRGB", "sview1")); + OCIO_CHECK_EQUAL(std::string("raw"), config->getVirtualDisplayViewColorSpaceName("sview2")); + // Step 3 - Validate the virtual display information. { OCIO::ConfigRcPtr cfg = config->createEditableCopy(); + OCIO_CHECK_ASSERT(OCIO::Config::viewsAreEqual(config, cfg, "sRGB", "sview1")); + OCIO_CHECK_ASSERT(OCIO::Config::viewsAreEqual(config, cfg, "sRGB", "Raw")); + OCIO_CHECK_ASSERT(OCIO::Config::viewsAreEqual(config, cfg, "sRGB", "view")); + OCIO_REQUIRE_EQUAL(2, cfg->getVirtualDisplayNumViews(OCIO::VIEW_DISPLAY_DEFINED)); const char * viewName = cfg->getVirtualDisplayView(OCIO::VIEW_DISPLAY_DEFINED, 0); + OCIO_CHECK_ASSERT(cfg->hasVirtualView(viewName)); + OCIO_CHECK_EQUAL(std::string("Raw"), viewName); OCIO_CHECK_EQUAL(std::string(""), cfg->getVirtualDisplayViewTransformName(viewName)); OCIO_CHECK_EQUAL(std::string("raw"), cfg->getVirtualDisplayViewColorSpaceName(viewName)); @@ -8505,22 +8533,36 @@ active_views: [] OCIO_CHECK_EQUAL(std::string(""), cfg->getVirtualDisplayViewRule(viewName)); OCIO_CHECK_EQUAL(std::string(""), cfg->getVirtualDisplayViewDescription(viewName)); + OCIO_CHECK_ASSERT(OCIO::Config::virtualViewsAreEqual(config, cfg, viewName)); + viewName = cfg->getVirtualDisplayView(OCIO::VIEW_DISPLAY_DEFINED, 1); - OCIO_CHECK_EQUAL(std::string("Film"), cfg->getVirtualDisplayView(OCIO::VIEW_DISPLAY_DEFINED, 1)); + OCIO_CHECK_ASSERT(cfg->hasVirtualView(viewName)); + + OCIO_CHECK_EQUAL(std::string("Film"), viewName); OCIO_CHECK_EQUAL(std::string("display_vt"), cfg->getVirtualDisplayViewTransformName(viewName)); OCIO_CHECK_EQUAL(std::string(""), cfg->getVirtualDisplayViewColorSpaceName(viewName)); OCIO_CHECK_EQUAL(std::string(""), cfg->getVirtualDisplayViewLooks(viewName)); OCIO_CHECK_EQUAL(std::string(""), cfg->getVirtualDisplayViewRule(viewName)); OCIO_CHECK_EQUAL(std::string(""), cfg->getVirtualDisplayViewDescription(viewName)); + OCIO_CHECK_ASSERT(OCIO::Config::virtualViewsAreEqual(config, cfg, viewName)); + OCIO_REQUIRE_EQUAL(1, cfg->getVirtualDisplayNumViews(OCIO::VIEW_SHARED)); OCIO_CHECK_EQUAL(std::string("sview2"), cfg->getVirtualDisplayView(OCIO::VIEW_SHARED, 0)); + OCIO_CHECK_EQUAL(std::string("raw"), cfg->getVirtualDisplayViewColorSpaceName("sview2")); + + OCIO_CHECK_ASSERT(cfg->hasVirtualView("sview2")); + OCIO_CHECK_ASSERT(cfg->virtualViewIsShared("sview2")); + OCIO_CHECK_ASSERT(OCIO::Config::virtualViewsAreEqual(config, cfg, "sview2")); // Remove a view from the Virtual Display. cfg->removeVirtualDisplayView("Raw"); + OCIO_CHECK_ASSERT(!OCIO::Config::virtualViewsAreEqual(config, cfg, "Raw")); + OCIO_CHECK_ASSERT(!cfg->hasVirtualView("Raw")); + OCIO_REQUIRE_EQUAL(1, cfg->getVirtualDisplayNumViews(OCIO::VIEW_DISPLAY_DEFINED)); OCIO_CHECK_EQUAL(std::string("Film"), cfg->getVirtualDisplayView(OCIO::VIEW_DISPLAY_DEFINED, 0)); @@ -8532,6 +8574,9 @@ active_views: [] cfg->removeVirtualDisplayView("sview2"); OCIO_REQUIRE_EQUAL(1, cfg->getVirtualDisplayNumViews(OCIO::VIEW_DISPLAY_DEFINED)); OCIO_REQUIRE_EQUAL(0, cfg->getVirtualDisplayNumViews(OCIO::VIEW_SHARED)); + OCIO_CHECK_ASSERT(!cfg->hasVirtualView("sview2")); + OCIO_CHECK_ASSERT(!cfg->virtualViewIsShared("sview2")); + OCIO_CHECK_ASSERT(!OCIO::Config::virtualViewsAreEqual(config, cfg, "sview2")); { // Extra serialize & deserialize validation. @@ -8552,12 +8597,14 @@ active_views: [] cfg->addVirtualDisplaySharedView("sview2"); OCIO_REQUIRE_EQUAL(1, cfg->getVirtualDisplayNumViews(OCIO::VIEW_DISPLAY_DEFINED)); OCIO_REQUIRE_EQUAL(1, cfg->getVirtualDisplayNumViews(OCIO::VIEW_SHARED)); + OCIO_CHECK_ASSERT(cfg->virtualViewIsShared("sview2")); // Remove the Virtual Display. cfg->clearVirtualDisplay(); OCIO_REQUIRE_EQUAL(0, cfg->getVirtualDisplayNumViews(OCIO::VIEW_DISPLAY_DEFINED)); OCIO_REQUIRE_EQUAL(0, cfg->getVirtualDisplayNumViews(OCIO::VIEW_SHARED)); + OCIO_CHECK_ASSERT(!cfg->virtualViewIsShared("sview2")); { // Extra serialize & deserialize validation. diff --git a/tests/python/ConfigTest.py b/tests/python/ConfigTest.py index c6ca03c1e..f9cc88b0a 100644 --- a/tests/python/ConfigTest.py +++ b/tests/python/ConfigTest.py @@ -288,7 +288,7 @@ def test_copy(self): self.assertEqual(other.getFileRules().getNumEntries(), cfg.getFileRules().getNumEntries() - 1) def test_shared_views(self): - # Test these Config functions: addSharedView, getSharedViews, removeSharedView. + # Test these Config functions: addSharedView, getSharedViews, removeSharedView, clearSharedViews. cfg = OCIO.Config.CreateRaw() views = cfg.getSharedViews() @@ -413,11 +413,12 @@ def test_shared_views(self): cfg.removeSharedView('view3') views = cfg.getSharedViews() self.assertEqual(5, len(views)) - cfg.removeSharedView('view4') - cfg.removeSharedView('view5') - cfg.removeSharedView('view6') - cfg.removeSharedView('view1') - cfg.removeSharedView('view2') + cfg.clearSharedViews() + # cfg.removeSharedView('view4') + # cfg.removeSharedView('view5') + # cfg.removeSharedView('view6') + # cfg.removeSharedView('view1') + # cfg.removeSharedView('view2') views = cfg.getSharedViews() self.assertEqual(0, len(views)) @@ -842,12 +843,22 @@ def test_virtual_display(self): "sRGB"))) self.assertEqual(1, len(cfg.getViews(OCIO.VIEW_SHARED, "sRGB"))) + self.assertTrue(cfg.displayHasView("sRGB", "sview1")) + self.assertTrue(cfg.viewIsShared("sRGB", "sview1")) + + other = copy.deepcopy(cfg) + + self.assertTrue(OCIO.Config.viewsAreEqual(cfg, other, "sRGB", "sview1")) + self.assertTrue(OCIO.Config.viewsAreEqual(cfg, other, "sRGB", "Raw")) + self.assertTrue(OCIO.Config.viewsAreEqual(cfg, other, "sRGB", "view")) + # Validate the virtual display information self.assertEqual( 2, len(cfg.getVirtualDisplayViews(OCIO.VIEW_DISPLAY_DEFINED))) view_name = cfg.getVirtualDisplayViews(OCIO.VIEW_DISPLAY_DEFINED)[0] + self.assertTrue(cfg.hasVirtualView(view_name)) self.assertEqual("Raw", view_name) self.assertEqual("", cfg.getVirtualDisplayViewTransformName(view_name)) self.assertEqual("raw", @@ -856,7 +867,10 @@ def test_virtual_display(self): self.assertEqual("", cfg.getVirtualDisplayViewRule(view_name)) self.assertEqual("", cfg.getVirtualDisplayViewDescription(view_name)) + self.assertTrue(OCIO.Config.virtualViewsAreEqual(cfg, other, view_name)) + view_name = cfg.getVirtualDisplayViews(OCIO.VIEW_DISPLAY_DEFINED)[1] + self.assertTrue(cfg.hasVirtualView(view_name)) self.assertEqual("Film", view_name) self.assertEqual("display_vt", cfg.getVirtualDisplayViewTransformName(view_name)) @@ -866,13 +880,22 @@ def test_virtual_display(self): self.assertEqual("", cfg.getVirtualDisplayViewRule(view_name)) self.assertEqual("", cfg.getVirtualDisplayViewDescription(view_name)) + self.assertTrue(OCIO.Config.virtualViewsAreEqual(cfg, other, view_name)) + self.assertEqual(1, len(cfg.getVirtualDisplayViews(OCIO.VIEW_SHARED))) self.assertEqual("sview2", cfg.getVirtualDisplayViews(OCIO.VIEW_SHARED)[0]) + + self.assertTrue(cfg.hasVirtualView("sview2")) + self.assertTrue(cfg.virtualViewIsShared("sview2")) + self.assertTrue(OCIO.Config.virtualViewsAreEqual(cfg, other, "sview2")) # Remove a view from the virtual display cfg.removeVirtualDisplayView("Raw") + self.assertFalse(OCIO.Config.virtualViewsAreEqual(cfg, other, "Raw")) + self.assertFalse(cfg.hasVirtualView("Raw")) + self.assertEqual( 1, len(cfg.getVirtualDisplayViews(OCIO.VIEW_DISPLAY_DEFINED))) @@ -891,6 +914,10 @@ def test_virtual_display(self): len(cfg.getVirtualDisplayViews(OCIO.VIEW_DISPLAY_DEFINED))) self.assertEqual(0, len(cfg.getVirtualDisplayViews(OCIO.VIEW_SHARED))) + self.assertFalse(cfg.hasVirtualView("sview2")) + self.assertFalse(cfg.virtualViewIsShared("sview2")) + self.assertFalse(OCIO.Config.virtualViewsAreEqual(cfg, other, "sview2")) + cfg.addVirtualDisplaySharedView("sview2") self.assertEqual( 1,