From c8dd1379b949762c17832d71b33a5abb83b60cde Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Wed, 22 May 2024 12:59:24 +0200 Subject: [PATCH] tests: Add focus_visibility_change test This test verifies the behavior of focus when its visibility is changed. --- .../avm1/focus_visibility_change/output.txt | 45 ++++++++++++++++++ .../swfs/avm1/focus_visibility_change/test.as | 39 +++++++++++++++ .../avm1/focus_visibility_change/test.swf | Bin 0 -> 552 bytes .../avm1/focus_visibility_change/test.toml | 1 + 4 files changed, 85 insertions(+) create mode 100644 tests/tests/swfs/avm1/focus_visibility_change/output.txt create mode 100644 tests/tests/swfs/avm1/focus_visibility_change/test.as create mode 100644 tests/tests/swfs/avm1/focus_visibility_change/test.swf create mode 100644 tests/tests/swfs/avm1/focus_visibility_change/test.toml diff --git a/tests/tests/swfs/avm1/focus_visibility_change/output.txt b/tests/tests/swfs/avm1/focus_visibility_change/output.txt new file mode 100644 index 0000000000000..c4f9f3a9a307f --- /dev/null +++ b/tests/tests/swfs/avm1/focus_visibility_change/output.txt @@ -0,0 +1,45 @@ +===== clip +Object: _level0.clip +Made visible +Focus changed + old: null + new: _level0.clip +Focus: _level0.clip +Focus changed + old: _level0.clip + new: null +Made invisible +Focus: null +Made visible +Focus: null +Made invisible +===== text +Object: _level0.text +Made visible +Focus changed + old: null + new: _level0.text +Focus: _level0.text +Focus changed + old: _level0.text + new: null +Made invisible +Focus: null +Made visible +Focus: null +Made invisible +===== button +Object: _level0.button +Made visible +Focus changed + old: null + new: _level0.button +Focus: _level0.button +Focus changed + old: _level0.button + new: null +Made invisible +Focus: null +Made visible +Focus: null +Made invisible diff --git a/tests/tests/swfs/avm1/focus_visibility_change/test.as b/tests/tests/swfs/avm1/focus_visibility_change/test.as new file mode 100644 index 0000000000000..ddb37079532ca --- /dev/null +++ b/tests/tests/swfs/avm1/focus_visibility_change/test.as @@ -0,0 +1,39 @@ +var listener = new Object(); +listener.onSetFocus = function(oldFocus, newFocus) { + trace("Focus changed"); + trace(" old: " + oldFocus); + trace(" new: " + newFocus); +}; +Selection.addListener(listener); + +function testObject(obj) { + trace("Object: " + obj); + obj._visible = true; + trace("Made visible"); + obj.focusEnabled = true; + Selection.setFocus(obj); + trace("Focus: " + Selection.getFocus()); + obj._visible = false; + trace("Made invisible"); + trace("Focus: " + Selection.getFocus()); + + obj._visible = true; + trace("Made visible"); + trace("Focus: " + Selection.getFocus()); + obj._visible = false; + trace("Made invisible"); +} + +var clip = _root.createEmptyMovieClip("clip", 10); +var text = _root.createTextField("text", 11, 0, 0, 150, 20); +text.type = "input"; +var button = _root.attachMovie("CustomButton", "button", 12); + +trace("===== clip"); +testObject(clip); + +trace("===== text"); +testObject(text); + +trace("===== button"); +testObject(button); diff --git a/tests/tests/swfs/avm1/focus_visibility_change/test.swf b/tests/tests/swfs/avm1/focus_visibility_change/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..5bbcdf0bbdd5ec1a7720391cc0a273750a6b3f8e GIT binary patch literal 552 zcmV+@0@wXRS5pXR1ONbdoRw2MZ_`i|KG#mtv<(Hf1@j1%kx+)NNu>%=5s|cAD3wwM zw#cz>8&|F!#W#gYu(QyCArmVS|DwNxg)aO8gjmBl$JaDY7w~Xi-{W2%%dg=*h+hB| z0c{KLX&D$U;1R~U=>BeBep>-SfLH~XfK~s|`usKd^mF*ViL}QEG-hd&`o!Ak58z$O zd)eNEi!!QVgBWIAU@BA^oM19<<8Tw3kENO*N^hi896=Mu){;P|HA+-`@;n_sGryPs z9~xo}!XQyHl0(?<9ZOF^934ot6MLfsI67Y6jgF)bjuVIe69;o7-(WtFA@T!sbAA6s z-UZ?AX^;fHP{N+;ODAg%$#Oe#vGyU!9fX>rY`~fz%2Zw$44^xVV+Gz&x=L=J4Aj|P zd>Y6WK}x>OkXKml1TyqNoed-e(O{&qW#m@iD&=~8_JA#V951y>l-@)-W$(1qHe&BjWirN~le)*9IQ zX6>H^Q+N6Q6K;`UK?}GsbYro4xx?RJg%J8nD35i9nY^f#OfKbYR<#W`w<+A=OV~uM qXe#gME=|mw_+Bc$pI$ik5g%-^s9MwR*P(|D*|QM;!G8cV(CL0wXa#%# literal 0 HcmV?d00001 diff --git a/tests/tests/swfs/avm1/focus_visibility_change/test.toml b/tests/tests/swfs/avm1/focus_visibility_change/test.toml new file mode 100644 index 0000000000000..cf6123969a1d6 --- /dev/null +++ b/tests/tests/swfs/avm1/focus_visibility_change/test.toml @@ -0,0 +1 @@ +num_ticks = 1