From b5fd027f5e549d74c70508d1734b36e9d91042e8 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 17 Nov 2020 18:43:02 +0000 Subject: [PATCH] (Automated Tests) Synchronise with dali-core following Semaphore class addition Change-Id: Ib72d70e3ba4a5407658610a73584ca293e0adb9b --- .../dali-test-suite-utils.h | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h index 2c1c703..b8de978 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h @@ -378,6 +378,34 @@ inline void DALI_TEST_PRINT_ASSERT(DaliException& e) DALI_TEST_ASSERT(e, assertstring, TEST_LOCATION); \ } +/** + * Test that given piece of code triggers an exception + * Fails the test if the exception didn't occur. + * Turns off logging during the execution of the code to avoid excessive false positive log output from the assertions + * @param expressions code to execute + * @param except the exception expected in the assert + */ +#define DALI_TEST_THROWS(expressions, except) \ + try \ + { \ + TestApplication::EnableLogging(false); \ + expressions; \ + TestApplication::EnableLogging(true); \ + fprintf(stderr, "Test failed in %s, expected exception: '%s' didn't occur\n", __FILELINE__, #except); \ + tet_result(TET_FAIL); \ + throw("TET_FAIL"); \ + } \ + catch(except &) \ + { \ + tet_result(TET_PASS); \ + } \ + catch(...) \ + { \ + fprintf(stderr, "Test failed in %s, unexpected exception\n", __FILELINE__); \ + tet_result(TET_FAIL); \ + throw; \ + } + // Functor to test whether an Applied signal is emitted struct ConstraintAppliedCheck { -- 2.7.4