[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 74a6ed1903b0bd02b394bd0418b922140d78576d..acc8a9ead6b1dcbd46a85e6fcce540425683b82a 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 9caab22011bdd8038249c6c035c04f7d4a4ebcf7..a1c47dc6c2cd63ed7f483485bee43b91f2438f28 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 443188436a5f98a524f447d29f3b5e807c69362a..6079a3e42f322bb8f207c5bf7e358a369009d82e 100644 (file)
@@ -410,6 +410,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 461d2eb96bafe290c437410d60cf27638b507256..caa9cc130bcdf9ad31f4a8ce41cb17e0ca39206c 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 e7a2a86dc0a16057bdcdf143f409c4af12dfc2b8..4c6974315db2cc3fce196fad504c59b63ec556a3 100644 (file)
@@ -184,6 +184,11 @@ public:
    */
   void UnregisterProcessor(Dali::Integration::Processor& processor, bool postProcessor = false);
 
+  /**
+   * @copydoc Dali::Integration::Core::UnregisterProcessors
+   */
+  void UnregisterProcessors();
+
   /**
    * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
    */