Introduce Test.prepareWidget and Test.restoreWidget to simplify common test initializations
Explanation
While working on the safe-reordering-widgets PR noticed a few widget tests calling EnableWidget and EnableWidget, all doing the same thing, namely remembering if the widget was enabled, then disabling and re-enabling it with locals access. On cleanup they will check the previous enabled state and either disable or reenable without locals access as needed.
This PR introduces two methods and needed mechanism inside dbg_test_runner.lua to avoid all the copy paste among tests, also hiding some implementation details from them. Also makes the restoring after the test automatic for tests that did call Test.prepareWidget, although they can also call it manually in case it's needed.
Work done
Explanation
While working on the safe-reordering-widgets PR noticed a few widget tests calling EnableWidget and EnableWidget, all doing the same thing, namely remembering if the widget was enabled, then disabling and re-enabling it with locals access. On cleanup they will check the previous enabled state and either disable or reenable without locals access as needed.
This PR introduces two methods and needed mechanism inside dbg_test_runner.lua to avoid all the copy paste among tests, also hiding some implementation details from them. Also makes the restoring after the test automatic for tests that did call Test.prepareWidget, although they can also call it manually in case it's needed.