From 0b2884e08bd61b98a71dc26d7a1e170efd95d675 Mon Sep 17 00:00:00 2001 From: Thiago Goulart Date: Tue, 24 Oct 2023 13:53:19 -0700 Subject: [PATCH] Add unit tests for IContext::isCurrentSharegroup() Summary: This augments the test added in D49297661 to validate `Context::isCurrentContext()` and `Context::isCurrentSharegroup()`. Reviewed By: EricGriffith Differential Revision: D50542256 fbshipit-source-id: 748c6da5c713926d607716530e7725abdf8dd806 --- src/igl/tests/ogl/Context.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/igl/tests/ogl/Context.cpp b/src/igl/tests/ogl/Context.cpp index 7d0db0e847..8f21e6b924 100644 --- a/src/igl/tests/ogl/Context.cpp +++ b/src/igl/tests/ogl/Context.cpp @@ -329,6 +329,15 @@ TEST_F(ContextOGLTest, BasicSharedContexts) { // Create texture from context (1) context_->setCurrent(); + + ASSERT_TRUE(context_->isCurrentContext()); + ASSERT_FALSE(sharedContext->isCurrentContext()); + ASSERT_FALSE(unsharedContext->isCurrentContext()); + + ASSERT_TRUE(context_->isCurrentSharegroup()); + ASSERT_TRUE(sharedContext->isCurrentSharegroup()); + ASSERT_FALSE(unsharedContext->isCurrentSharegroup()); + const igl::TextureDesc textureDesc = igl::TextureDesc::new2D( igl::TextureFormat::RGBA_UNorm8, 16, 16, igl::TextureDesc::TextureUsageBits::Sampled); auto texture = device_->createTexture(textureDesc, &result); @@ -339,10 +348,28 @@ TEST_F(ContextOGLTest, BasicSharedContexts) { // Confirm that texture is visible from context (2) sharedContext->setCurrent(); + + ASSERT_FALSE(context_->isCurrentContext()); + ASSERT_TRUE(sharedContext->isCurrentContext()); + ASSERT_FALSE(unsharedContext->isCurrentContext()); + + ASSERT_TRUE(context_->isCurrentSharegroup()); + ASSERT_TRUE(sharedContext->isCurrentSharegroup()); + ASSERT_FALSE(unsharedContext->isCurrentSharegroup()); + ASSERT_TRUE(sharedContext->isTexture(glTextureId)); // Confirm that texture is not visible from context (3) unsharedContext->setCurrent(); + + ASSERT_FALSE(context_->isCurrentContext()); + ASSERT_FALSE(sharedContext->isCurrentContext()); + ASSERT_TRUE(unsharedContext->isCurrentContext()); + + ASSERT_FALSE(context_->isCurrentSharegroup()); + ASSERT_FALSE(sharedContext->isCurrentSharegroup()); + ASSERT_TRUE(unsharedContext->isCurrentSharegroup()); + ASSERT_FALSE(unsharedContext->isTexture(glTextureId)); }