The Trunk: ToolsTests-mt.98.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: ToolsTests-mt.98.mcz

commits-2
Marcel Taeumel uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-mt.98.mcz

==================== Summary ====================

Name: ToolsTests-mt.98
Author: mt
Time: 4 August 2020, 10:52:30.205047 am
UUID: c6795330-9d71-bd41-811f-76dec78f8ef6
Ancestors: ToolsTests-mt.97

Based on KernelTests-tcj.350 (inbox -> treated), add a test to check whether all menu actions are actually implemented in either model or widget.

Currently works for model's code-pane menus only. Test design requires agreement on communication between model and builder such as through #buildCodePaneWith:.

Not yet working for MVCToolBuilder. We do need to harmonize the interfaces of MenuMorph (Morphic) and PopUpMenu (MVC), e.g., by adding #items.

Not yet passing for MorphicToolBuilder bc. missing implementation of #makeProjectLink in either CodeHolder or PluggableTextMorph. :-)

=============== Diff against ToolsTests-mt.97 ===============

Item was changed:
  SystemOrganization addCategory: #'ToolsTests-Browser'!
  SystemOrganization addCategory: #'ToolsTests-Debugger'!
  SystemOrganization addCategory: #'ToolsTests-FileList'!
  SystemOrganization addCategory: #'ToolsTests-Inspector'!
+ SystemOrganization addCategory: #'ToolsTests-Menus'!

Item was added:
+ TestCase subclass: #ToolMenusTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Menus'!

Item was added:
+ ----- Method: ToolMenusTest>>testCodePaneMenu (in category 'tests') -----
+ testCodePaneMenu
+ "Checks whether all menu actions are implemented in either the model or the widget."
+
+ | builder builderSelector menuSelector result |
+ builder := ToolBuilder default.
+ builderSelector := #buildCodePaneWith:.
+ menuSelector := #menu.
+ result := Dictionary new.
+
+ Model withAllSubclasses
+ select: [:modelClass | modelClass includesSelector: builderSelector]
+ thenDo: [:modelClass |
+ | model spec widget menu selectors |
+ result at: modelClass put: OrderedCollection new.
+ model := modelClass new.
+ spec := model perform: builderSelector with: builder.
+ (spec respondsTo: menuSelector) ifFalse: [
+ "Little hack to allow code panes being wrapped in panels."
+ spec := spec children detect: [:child |
+ (child respondsTo: menuSelector) and: [(child perform: menuSelector) notNil]]].
+ [widget := builder build: spec] on: Error do: [:ex | ex resume: nil].
+ #(false true) do: [:shifted |
+ menu := builder build: (builder pluggableMenuSpec new items; yourself).
+ menu := model perform: spec menu withEnoughArguments: {menu. shifted}.
+ selectors := menu items collect: [:item | item selector].
+ "MVC: selectors := menu selections select: [:sel | sel isSymbol]"
+ (result at: modelClass)
+ addAll: (selectors reject: [:selector |
+ (model respondsTo: selector) or: [widget respondsTo: selector]])]].
+
+ self assert: (result values allSatisfy: [:notImplementedSelectors | notImplementedSelectors isEmpty]).!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ToolsTests-mt.98.mcz

marcel.taeumel
... "model or widget" because of the use of Object >> #perform:orSendTo:.

Best,
Marcel

Am 04.08.2020 10:52:39 schrieb [hidden email] <[hidden email]>:

Marcel Taeumel uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-mt.98.mcz

==================== Summary ====================

Name: ToolsTests-mt.98
Author: mt
Time: 4 August 2020, 10:52:30.205047 am
UUID: c6795330-9d71-bd41-811f-76dec78f8ef6
Ancestors: ToolsTests-mt.97

Based on KernelTests-tcj.350 (inbox -> treated), add a test to check whether all menu actions are actually implemented in either model or widget.

Currently works for model's code-pane menus only. Test design requires agreement on communication between model and builder such as through #buildCodePaneWith:.

Not yet working for MVCToolBuilder. We do need to harmonize the interfaces of MenuMorph (Morphic) and PopUpMenu (MVC), e.g., by adding #items.

Not yet passing for MorphicToolBuilder bc. missing implementation of #makeProjectLink in either CodeHolder or PluggableTextMorph. :-)

=============== Diff against ToolsTests-mt.97 ===============

Item was changed:
SystemOrganization addCategory: #'ToolsTests-Browser'!
SystemOrganization addCategory: #'ToolsTests-Debugger'!
SystemOrganization addCategory: #'ToolsTests-FileList'!
SystemOrganization addCategory: #'ToolsTests-Inspector'!
+ SystemOrganization addCategory: #'ToolsTests-Menus'!

Item was added:
+ TestCase subclass: #ToolMenusTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Menus'!

Item was added:
+ ----- Method: ToolMenusTest>>testCodePaneMenu (in category 'tests') -----
+ testCodePaneMenu
+ "Checks whether all menu actions are implemented in either the model or the widget."
+
+ | builder builderSelector menuSelector result |
+ builder := ToolBuilder default.
+ builderSelector := #buildCodePaneWith:.
+ menuSelector := #menu.
+ result := Dictionary new.
+
+ Model withAllSubclasses
+ select: [:modelClass | modelClass includesSelector: builderSelector]
+ thenDo: [:modelClass |
+ | model spec widget menu selectors |
+ result at: modelClass put: OrderedCollection new.
+ model := modelClass new.
+ spec := model perform: builderSelector with: builder.
+ (spec respondsTo: menuSelector) ifFalse: [
+ "Little hack to allow code panes being wrapped in panels."
+ spec := spec children detect: [:child |
+ (child respondsTo: menuSelector) and: [(child perform: menuSelector) notNil]]].
+ [widget := builder build: spec] on: Error do: [:ex | ex resume: nil].
+ #(false true) do: [:shifted |
+ menu := builder build: (builder pluggableMenuSpec new items; yourself).
+ menu := model perform: spec menu withEnoughArguments: {menu. shifted}.
+ selectors := menu items collect: [:item | item selector].
+ "MVC: selectors := menu selections select: [:sel | sel isSymbol]"
+ (result at: modelClass)
+ addAll: (selectors reject: [:selector |
+ (model respondsTo: selector) or: [widget respondsTo: selector]])]].
+
+ self assert: (result values allSatisfy: [:notImplementedSelectors | notImplementedSelectors isEmpty]).!




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ToolsTests-mt.98.mcz

Jakob Reschke
You could provide template methods for the ToolBuilder instance or the different aspects of inspecting the menu that are UI framework-specific.

Then you could have a subclass of this test case class per framework and run them all at once.

Marcel Taeumel <[hidden email]> schrieb am Di., 4. Aug. 2020, 10:55:
... "model or widget" because of the use of Object >> #perform:orSendTo:.

Best,
Marcel

Am 04.08.2020 10:52:39 schrieb [hidden email] <[hidden email]>:

Marcel Taeumel uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-mt.98.mcz

==================== Summary ====================

Name: ToolsTests-mt.98
Author: mt
Time: 4 August 2020, 10:52:30.205047 am
UUID: c6795330-9d71-bd41-811f-76dec78f8ef6
Ancestors: ToolsTests-mt.97

Based on KernelTests-tcj.350 (inbox -> treated), add a test to check whether all menu actions are actually implemented in either model or widget.

Currently works for model's code-pane menus only. Test design requires agreement on communication between model and builder such as through #buildCodePaneWith:.

Not yet working for MVCToolBuilder. We do need to harmonize the interfaces of MenuMorph (Morphic) and PopUpMenu (MVC), e.g., by adding #items.

Not yet passing for MorphicToolBuilder bc. missing implementation of #makeProjectLink in either CodeHolder or PluggableTextMorph. :-)

=============== Diff against ToolsTests-mt.97 ===============

Item was changed:
SystemOrganization addCategory: #'ToolsTests-Browser'!
SystemOrganization addCategory: #'ToolsTests-Debugger'!
SystemOrganization addCategory: #'ToolsTests-FileList'!
SystemOrganization addCategory: #'ToolsTests-Inspector'!
+ SystemOrganization addCategory: #'ToolsTests-Menus'!

Item was added:
+ TestCase subclass: #ToolMenusTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'ToolsTests-Menus'!

Item was added:
+ ----- Method: ToolMenusTest>>testCodePaneMenu (in category 'tests') -----
+ testCodePaneMenu
+ "Checks whether all menu actions are implemented in either the model or the widget."
+
+ | builder builderSelector menuSelector result |
+ builder := ToolBuilder default.
+ builderSelector := #buildCodePaneWith:.
+ menuSelector := #menu.
+ result := Dictionary new.
+
+ Model withAllSubclasses
+ select: [:modelClass | modelClass includesSelector: builderSelector]
+ thenDo: [:modelClass |
+ | model spec widget menu selectors |
+ result at: modelClass put: OrderedCollection new.
+ model := modelClass new.
+ spec := model perform: builderSelector with: builder.
+ (spec respondsTo: menuSelector) ifFalse: [
+ "Little hack to allow code panes being wrapped in panels."
+ spec := spec children detect: [:child |
+ (child respondsTo: menuSelector) and: [(child perform: menuSelector) notNil]]].
+ [widget := builder build: spec] on: Error do: [:ex | ex resume: nil].
+ #(false true) do: [:shifted |
+ menu := builder build: (builder pluggableMenuSpec new items; yourself).
+ menu := model perform: spec menu withEnoughArguments: {menu. shifted}.
+ selectors := menu items collect: [:item | item selector].
+ "MVC: selectors := menu selections select: [:sel | sel isSymbol]"
+ (result at: modelClass)
+ addAll: (selectors reject: [:selector |
+ (model respondsTo: selector) or: [widget respondsTo: selector]])]].
+
+ self assert: (result values allSatisfy: [:notImplementedSelectors | notImplementedSelectors isEmpty]).!





Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ToolsTests-mt.98.mcz

Jakob Reschke
In reply to this post by commits-2
This is nice to detect bad menus for a Squeak release. But it will fail if you have a non-conforming third party Model loaded. On the other hand the tests of that third party code will probably not fail. And they have no easy easy to reuse this test facility for their own classes to make their test suite fail. So: how about making the list of classes to test overridable? The base implementation could either collect all the Model subclasses as currently, or get only the classes of the Trunk packages.

Of course this is a different direction for new subclasses than what I wrote in my other mail about subclasses for UI frameworks. So one of those aspects should probably be in a different object (composition) or for now just another test method.

<[hidden email]> schrieb am Di., 4. Aug. 2020, 10:52:
Marcel Taeumel uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-mt.98.mcz

==================== Summary ====================

Name: ToolsTests-mt.98
Author: mt
Time: 4 August 2020, 10:52:30.205047 am
UUID: c6795330-9d71-bd41-811f-76dec78f8ef6
Ancestors: ToolsTests-mt.97

Based on KernelTests-tcj.350 (inbox -> treated), add a test to check whether all menu actions are actually implemented in either model or widget.

Currently works for model's code-pane menus only. Test design requires agreement on communication between model and builder such as through #buildCodePaneWith:.

Not yet working for MVCToolBuilder. We do need to harmonize the interfaces of MenuMorph (Morphic) and PopUpMenu (MVC), e.g., by adding #items.

Not yet passing for MorphicToolBuilder bc. missing implementation of #makeProjectLink in either CodeHolder or PluggableTextMorph. :-)

=============== Diff against ToolsTests-mt.97 ===============

Item was changed:
  SystemOrganization addCategory: #'ToolsTests-Browser'!
  SystemOrganization addCategory: #'ToolsTests-Debugger'!
  SystemOrganization addCategory: #'ToolsTests-FileList'!
  SystemOrganization addCategory: #'ToolsTests-Inspector'!
+ SystemOrganization addCategory: #'ToolsTests-Menus'!

Item was added:
+ TestCase subclass: #ToolMenusTest
+       instanceVariableNames: ''
+       classVariableNames: ''
+       poolDictionaries: ''
+       category: 'ToolsTests-Menus'!

Item was added:
+ ----- Method: ToolMenusTest>>testCodePaneMenu (in category 'tests') -----
+ testCodePaneMenu
+       "Checks whether all menu actions are implemented in either the model or the widget."
+
+       | builder builderSelector menuSelector result |
+       builder := ToolBuilder default.
+       builderSelector := #buildCodePaneWith:.
+       menuSelector := #menu.
+       result := Dictionary new.
+
+       Model withAllSubclasses
+               select: [:modelClass | modelClass includesSelector: builderSelector]
+               thenDo: [:modelClass |
+                       | model spec widget menu selectors |
+                       result at: modelClass put: OrderedCollection new.
+                       model := modelClass new.
+                       spec := model perform: builderSelector with: builder.
+                       (spec respondsTo: menuSelector) ifFalse: [
+                               "Little hack to allow code panes being wrapped in panels."
+                               spec := spec children detect: [:child |
+                                       (child respondsTo: menuSelector) and: [(child perform: menuSelector) notNil]]].
+                       [widget := builder build: spec] on: Error do: [:ex | ex resume: nil].
+                       #(false true) do: [:shifted |
+                               menu := builder build: (builder pluggableMenuSpec new items; yourself).
+                               menu := model perform: spec menu withEnoughArguments: {menu. shifted}. 
+                               selectors := menu items collect: [:item | item selector].
+                               "MVC: selectors := menu selections select: [:sel | sel isSymbol]"
+                               (result at: modelClass)
+                                       addAll: (selectors reject: [:selector |
+                                               (model respondsTo: selector) or: [widget respondsTo: selector]])]].
+
+       self assert: (result values allSatisfy: [:notImplementedSelectors | notImplementedSelectors isEmpty]).!




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ToolsTests-mt.98.mcz

marcel.taeumel
Hi Jakob,

it checks for "includesSelector: #buildCodePaneWith:". Should be specific enough to discard other models in the system. Of course, models can chose to implement that in a totally different way. Well, that would be bad luck. :-)

Best,
Marcel

Am 04.08.2020 13:27:26 schrieb Jakob Reschke <[hidden email]>:

This is nice to detect bad menus for a Squeak release. But it will fail if you have a non-conforming third party Model loaded. On the other hand the tests of that third party code will probably not fail. And they have no easy easy to reuse this test facility for their own classes to make their test suite fail. So: how about making the list of classes to test overridable? The base implementation could either collect all the Model subclasses as currently, or get only the classes of the Trunk packages.

Of course this is a different direction for new subclasses than what I wrote in my other mail about subclasses for UI frameworks. So one of those aspects should probably be in a different object (composition) or for now just another test method.

<[hidden email]> schrieb am Di., 4. Aug. 2020, 10:52:
Marcel Taeumel uploaded a new version of ToolsTests to project The Trunk:
http://source.squeak.org/trunk/ToolsTests-mt.98.mcz

==================== Summary ====================

Name: ToolsTests-mt.98
Author: mt
Time: 4 August 2020, 10:52:30.205047 am
UUID: c6795330-9d71-bd41-811f-76dec78f8ef6
Ancestors: ToolsTests-mt.97

Based on KernelTests-tcj.350 (inbox -> treated), add a test to check whether all menu actions are actually implemented in either model or widget.

Currently works for model's code-pane menus only. Test design requires agreement on communication between model and builder such as through #buildCodePaneWith:.

Not yet working for MVCToolBuilder. We do need to harmonize the interfaces of MenuMorph (Morphic) and PopUpMenu (MVC), e.g., by adding #items.

Not yet passing for MorphicToolBuilder bc. missing implementation of #makeProjectLink in either CodeHolder or PluggableTextMorph. :-)

=============== Diff against ToolsTests-mt.97 ===============

Item was changed:
  SystemOrganization addCategory: #'ToolsTests-Browser'!
  SystemOrganization addCategory: #'ToolsTests-Debugger'!
  SystemOrganization addCategory: #'ToolsTests-FileList'!
  SystemOrganization addCategory: #'ToolsTests-Inspector'!
+ SystemOrganization addCategory: #'ToolsTests-Menus'!

Item was added:
+ TestCase subclass: #ToolMenusTest
+       instanceVariableNames: ''
+       classVariableNames: ''
+       poolDictionaries: ''
+       category: 'ToolsTests-Menus'!

Item was added:
+ ----- Method: ToolMenusTest>>testCodePaneMenu (in category 'tests') -----
+ testCodePaneMenu
+       "Checks whether all menu actions are implemented in either the model or the widget."
+
+       | builder builderSelector menuSelector result |
+       builder := ToolBuilder default.
+       builderSelector := #buildCodePaneWith:.
+       menuSelector := #menu.
+       result := Dictionary new.
+
+       Model withAllSubclasses
+               select: [:modelClass | modelClass includesSelector: builderSelector]
+               thenDo: [:modelClass |
+                       | model spec widget menu selectors |
+                       result at: modelClass put: OrderedCollection new.
+                       model := modelClass new.
+                       spec := model perform: builderSelector with: builder.
+                       (spec respondsTo: menuSelector) ifFalse: [
+                               "Little hack to allow code panes being wrapped in panels."
+                               spec := spec children detect: [:child |
+                                       (child respondsTo: menuSelector) and: [(child perform: menuSelector) notNil]]].
+                       [widget := builder build: spec] on: Error do: [:ex | ex resume: nil].
+                       #(false true) do: [:shifted |
+                               menu := builder build: (builder pluggableMenuSpec new items; yourself).
+                               menu := model perform: spec menu withEnoughArguments: {menu. shifted}. 
+                               selectors := menu items collect: [:item | item selector].
+                               "MVC: selectors := menu selections select: [:sel | sel isSymbol]"
+                               (result at: modelClass)
+                                       addAll: (selectors reject: [:selector |
+                                               (model respondsTo: selector) or: [widget respondsTo: selector]])]].
+
+       self assert: (result values allSatisfy: [:notImplementedSelectors | notImplementedSelectors isEmpty]).!