[Tizen] Unregister all processors if we need 13/307913/1 accepted/tizen/8.0/unified/20240318.143303
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 12 Mar 2024 08:19:14 +0000 (17:19 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 14 Mar 2024 07:10:17 +0000 (16:10 +0900)
Let we ensure that all processor are unregistered after call
Core::UnregisterProcessors() API.

It will remove both Processor, and PostProcessor.

Change-Id: Ie70f287d8e0ec33579a5128ce2268a66aa4de277
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/utc-Dali-Processors.cpp
dali/integration-api/core.cpp
dali/integration-api/core.h
dali/internal/common/core-impl.cpp
dali/internal/common/core-impl.h

index 74a6ed1..acc8a9e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -285,3 +285,57 @@ int UtcDaliCoreProcessorGetProcessorName(void)
 
   END_TEST;
 }
+
+int UtcDaliCoreProcessorUnregisterProcessors(void)
+{
+  TestApplication application;
+
+  TestProcessor testProcessor1;
+  TestProcessor testProcessor2;
+  TestProcessor testProcessor3;
+
+  Integration::Core& core = application.GetCore();
+  core.RegisterProcessor(testProcessor1);
+
+  tet_infoline("Test that the processor has not been executed yet:");
+  DALI_TEST_CHECK(testProcessor1.processRun == false);
+
+  application.SendNotification();
+
+  tet_infoline("Test that the processor has been executed:");
+  DALI_TEST_CHECK(testProcessor1.processRun);
+
+  // Clear down for next part of test
+  testProcessor1.processRun = false;
+
+  core.RegisterProcessor(testProcessor2);
+  core.RegisterProcessor(testProcessor3, true); // Register as post processor
+
+  tet_infoline("Test that the processors have not been executed yet:");
+  DALI_TEST_CHECK(testProcessor1.processRun == false);
+  DALI_TEST_CHECK(testProcessor2.processRun == false);
+  DALI_TEST_CHECK(testProcessor3.processRun == false);
+
+  application.SendNotification();
+
+  tet_infoline("Test that the processors have been executed:");
+  DALI_TEST_CHECK(testProcessor1.processRun);
+  DALI_TEST_CHECK(testProcessor2.processRun);
+  DALI_TEST_CHECK(testProcessor3.processRun);
+
+  // Clear down for next part of test
+  testProcessor1.processRun = false;
+  testProcessor2.processRun = false;
+  testProcessor3.processRun = false;
+
+  core.UnregisterProcessors();
+  application.SendNotification();
+  tet_infoline("Test that all processors has not been executed again");
+  DALI_TEST_CHECK(testProcessor1.processRun == false);
+  DALI_TEST_CHECK(testProcessor2.processRun == false);
+  DALI_TEST_CHECK(testProcessor3.processRun == false);
+
+  END_TEST;
+
+  END_TEST;
+}
index 9caab22..a1c47dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -145,6 +145,11 @@ void Core::UnregisterProcessor(Processor& processor, bool postProcessor)
   mImpl->UnregisterProcessor(processor, postProcessor);
 }
 
+void Core::UnregisterProcessors()
+{
+  mImpl->UnregisterProcessors();
+}
+
 ObjectRegistry Core::GetObjectRegistry() const
 {
   return ObjectRegistry(&mImpl->GetObjectRegistry());
index 4431884..6079a3e 100644 (file)
@@ -411,6 +411,11 @@ public:
   void UnregisterProcessor(Processor& processor, bool postProcessor = false);
 
   /**
+   * @brief Unregister all processors and post processors what we registered before.
+   */
+  void UnregisterProcessors();
+
+  /**
    * @brief Gets the Object registry.
    * @return The object registry
    */
index 461d2eb..caa9cc1 100644 (file)
@@ -421,6 +421,14 @@ void Core::UnregisterProcessor(Integration::Processor& processor, bool postProce
   }
 }
 
+void Core::UnregisterProcessors()
+{
+  mPostProcessors.Clear();
+  mPostProcessorUnregistered = true;
+  mProcessors.Clear();
+  mProcessorUnregistered = true;
+}
+
 void Core::RunProcessors()
 {
   if(mProcessors.Count() != 0)
index e7a2a86..4c69743 100644 (file)
@@ -185,6 +185,11 @@ public:
   void UnregisterProcessor(Dali::Integration::Processor& processor, bool postProcessor = false);
 
   /**
+   * @copydoc Dali::Integration::Core::UnregisterProcessors
+   */
+  void UnregisterProcessors();
+
+  /**
    * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
    */
   void AddScene(Scene* scene);