Hi, I'm writing tests for RewriteTool which I build with spec. I have a TextModel in this tool. When I do: /RewriteTool new openWithSpec/, /TextModel sourceTextArea/ is initialized, however in tests I don't want to open a tool, just want to initialize it. So I wrote /RewriteTool new/. Everything is initialized, but/ TextModel sourceTextArea/ is /nil/. And I don't know why. Any thoughts? Best, Mark -- View this message in context: http://forum.world.st/Question-on-Spec-tp4771958.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
I will say it depends how you initialise your objects ;) The good way to do it is in the method `initializeWidgets` Could you post it so I can tell you a bit more? Ben On 06 Aug 2014, at 10:56, Mark Rizun <mrizun@gmail.com> wrote:
Hi,
I'm writing tests for RewriteTool which I build with spec. I have a TextModel in this tool. When I do: /RewriteTool new openWithSpec/, /TextModel sourceTextArea/ is initialized, however in tests I don't want to open a tool, just want to initialize it. So I wrote /RewriteTool new/. Everything is initialized, but/ TextModel sourceTextArea/ is /nil/. And I don't know why. Any thoughts?
Best, Mark
-- View this message in context: http://forum.world.st/Question-on-Spec-tp4771958.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
initializeWidgets self instantiateModels: #(#sourcePanel #SourcePanel #resultPanel #ResultPanel #matchPanel #MatchPanel #transformPanel #TransformPanel #acceptButton #ButtonModel). 2014-08-06 10:58 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com>:
I will say it depends how you initialise your objects ;)
The good way to do it is in the method `initializeWidgets`
Could you post it so I can tell you a bit more?
Ben
On 06 Aug 2014, at 10:56, Mark Rizun <mrizun@gmail.com> wrote:
Hi,
I'm writing tests for RewriteTool which I build with spec. I have a TextModel in this tool. When I do: /RewriteTool new openWithSpec/, /TextModel sourceTextArea/ is initialized, however in tests I don't want to open a tool, just want to initialize it. So I wrote /RewriteTool new/. Everything is initialized, but/ TextModel sourceTextArea/ is /nil/. And I don't know why. Any thoughts?
Best, Mark
-- View this message in context: http://forum.world.st/Question-on-Spec-tp4771958.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
On 06 Aug 2014, at 11:04, Mark Rizun <mrizun@gmail.com> wrote:
initializeWidgets self instantiateModels: #(#sourcePanel #SourcePanel #resultPanel #ResultPanel #matchPanel #MatchPanel #transformPanel #TransformPanel #acceptButton #ButtonModel).
Sounds correct so far :) In wich panel is your TextModel? Can you show me your `initializeWidgets` method for this panel? Ben
Actually in each:) I have a class AbstractPanel and there is: initializeWidgets self instantiateModels: #(#templateText #MyTextModel). templateText dragEnabled; text: self demoText; ast: (RBParser parseRewriteExpression: self demoText); aboutToStyle: true; model: self; menuOptionsSelector: #menuActions MyTextModel is a subclass of TextModel 2014-08-06 11:13 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com>:
On 06 Aug 2014, at 11:04, Mark Rizun <mrizun@gmail.com> wrote:
initializeWidgets self instantiateModels: #(#sourcePanel #SourcePanel #resultPanel #ResultPanel #matchPanel #MatchPanel #transformPanel #TransformPanel #acceptButton #ButtonModel).
Sounds correct so far :)
In wich panel is your TextModel? Can you show me your `initializeWidgets` method for this panel?
Ben
Hi ! Did you call 'super initailizeWidgets' in the 'initializeWidgets' method of all the subclass of AbstractPanel ? Thomas. 2014-08-06 11:16 GMT+02:00 Mark Rizun <mrizun@gmail.com>:
Actually in each:) I have a class AbstractPanel and there is:
initializeWidgets self instantiateModels: #(#templateText #MyTextModel). templateText dragEnabled; text: self demoText; ast: (RBParser parseRewriteExpression: self demoText); aboutToStyle: true; model: self; menuOptionsSelector: #menuActions
MyTextModel is a subclass of TextModel
2014-08-06 11:13 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com> :
On 06 Aug 2014, at 11:04, Mark Rizun <mrizun@gmail.com> wrote:
initializeWidgets self instantiateModels: #(#sourcePanel #SourcePanel #resultPanel #ResultPanel #matchPanel #MatchPanel #transformPanel #TransformPanel #acceptButton #ButtonModel).
Sounds correct so far :)
In wich panel is your TextModel? Can you show me your `initializeWidgets` method for this panel?
Ben
On 06 Aug 2014, at 11:16, Mark Rizun <mrizun@gmail.com> wrote:
Actually in each:) I have a class AbstractPanel and there is:
initializeWidgets self instantiateModels: #(#templateText #MyTextModel). templateText dragEnabled; text: self demoText; ast: (RBParser parseRewriteExpression: self demoText); aboutToStyle: true; model: self; menuOptionsSelector: #menuActions
This should then be initialised :S Could you try to put a `self halt` here to see if you hit it when you initialise your main model? Ben P.S.: why did you need to subclass TextModel? Is there something missing you wanted to have?
Yes it is invoked(I mean initializeWidgets in AbstractPanel) if I do: RewriteTool new. And yes, I needed more functionality for TextModel 2014-08-06 11:26 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com>:
On 06 Aug 2014, at 11:16, Mark Rizun <mrizun@gmail.com> wrote:
Actually in each:) I have a class AbstractPanel and there is:
initializeWidgets self instantiateModels: #(#templateText #MyTextModel). templateText dragEnabled; text: self demoText; ast: (RBParser parseRewriteExpression: self demoText); aboutToStyle: true; model: self; menuOptionsSelector: #menuActions
This should then be initialised :S Could you try to put a `self halt` here to see if you hit it when you initialise your main model?
Ben
P.S.: why did you need to subclass TextModel? Is there something missing you wanted to have?
Thomas, no I don't have super call, because in subclasses I don't have initializeWidget method 2014-08-06 11:30 GMT+02:00 Mark Rizun <mrizun@gmail.com>:
Yes it is invoked(I mean initializeWidgets in AbstractPanel) if I do: RewriteTool new. And yes, I needed more functionality for TextModel
2014-08-06 11:26 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com> :
On 06 Aug 2014, at 11:16, Mark Rizun <mrizun@gmail.com> wrote:
Actually in each:) I have a class AbstractPanel and there is:
initializeWidgets self instantiateModels: #(#templateText #MyTextModel). templateText dragEnabled; text: self demoText; ast: (RBParser parseRewriteExpression: self demoText); aboutToStyle: true; model: self; menuOptionsSelector: #menuActions
This should then be initialised :S Could you try to put a `self halt` here to see if you hit it when you initialise your main model?
Ben
P.S.: why did you need to subclass TextModel? Is there something missing you wanted to have?
On 06 Aug 2014, at 11:30, Mark Rizun <mrizun@gmail.com> wrote:
Yes it is invoked(I mean initializeWidgets in AbstractPanel) if I do: RewriteTool new.
If you put the halt after `self instantiateModels: #(#templateText #MyTextModel).` can you confirm that templateText is not nil?
And yes, I needed more functionality for TextModel
Which ones? :) Maybe they deserve to be pushed into TextModel Ben
The templateText was always initialized. But templateText sourceTextArea is still nil. No they don't:) I just replaced a menu of TextModel with my own, and added some ast support. 2014-08-06 11:45 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com>:
On 06 Aug 2014, at 11:30, Mark Rizun <mrizun@gmail.com> wrote:
Yes it is invoked(I mean initializeWidgets in AbstractPanel) if I do: RewriteTool new.
If you put the halt after `self instantiateModels: #(#templateText #MyTextModel).` can you confirm that templateText is not nil?
And yes, I needed more functionality for TextModel
Which ones? :) Maybe they deserve to be pushed into TextModel
Ben
Maybe it can, but it's more convenient for me to subclass it So, how do I initialize it for tests without opening it with spec? 6 ÑеÑп. 2014 12:00, коÑиÑÑÑÐ²Ð°Ñ "Benjamin" < Benjamin.VanRyseghem.Pharo@gmail.com> напиÑав:
On 06 Aug 2014, at 11:50, Mark Rizun <mrizun@gmail.com> wrote:
No they don't:) I just replaced a menu of TextModel with my own, and added some ast support.
Canât the menu be changed dynamically in TextModel?
Ben
Maybe you can manually set the Adapter? Ben On 06 Aug 2014, at 12:39, Mark Rizun <mrizun@gmail.com> wrote:
Maybe it can, but it's more convenient for me to subclass it So, how do I initialize it for tests without opening it with spec?
6 ÑеÑп. 2014 12:00, коÑиÑÑÑÐ²Ð°Ñ "Benjamin" <Benjamin.VanRyseghem.Pharo@gmail.com> напиÑав: On 06 Aug 2014, at 11:50, Mark Rizun <mrizun@gmail.com> wrote:
No they don't:) I just replaced a menu of TextModel with my own, and added some ast support.
Canât the menu be changed dynamically in TextModel?
Ben
Going through the execution of 'openWithSpec', it looks like the method you are looking for is 'buildWithSpec'. It definitely instantiate the adapters as well as the morphs, with the root of the morph tree being nil. I can't tell you if everything will work as intended though, but I don't see why not. Benjamin developed Spec and might be able to answer that. Finaly, I don't quite see what is wrong with opening a window in a test, as long as you send 'close' to your model at the end ? Thomas. 2014-08-06 14:01 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com>:
Maybe you can manually set the Adapter?
Ben
On 06 Aug 2014, at 12:39, Mark Rizun <mrizun@gmail.com> wrote:
Maybe it can, but it's more convenient for me to subclass it So, how do I initialize it for tests without opening it with spec? 6 ÑеÑп. 2014 12:00, коÑиÑÑÑÐ²Ð°Ñ "Benjamin" < Benjamin.VanRyseghem.Pharo@gmail.com> напиÑав:
On 06 Aug 2014, at 11:50, Mark Rizun <mrizun@gmail.com> wrote:
No they don't:) I just replaced a menu of TextModel with my own, and added some ast support.
Canât the menu be changed dynamically in TextModel?
Ben
On 06 Aug 2014, at 14:11, Thomas Bany <mun.sysdev@gmail.com> wrote:
Going through the execution of 'openWithSpec', it looks like the method you are looking for is 'buildWithSpec'. It definitely instantiate the adapters as well as the morphs, with the root of the morph tree being nil.
I can't tell you if everything will work as intended though, but I don't see why not. Benjamin developed Spec and might be able to answer that.
`builtWithSpec` should definitely do it :)
Finaly, I don't quite see what is wrong with opening a window in a test, as long as you send 'close' to your model at the end ?
Usually you want tests to be runnable in headless mode :) Ben
Thomas, The problem is that I already have lots of tests and it's only the beginning. Imagine running 50 tests at one time:) You will see 50 windows on screen. Not very good 2014-08-06 14:11 GMT+02:00 Thomas Bany <mun.sysdev@gmail.com>:
Going through the execution of 'openWithSpec', it looks like the method you are looking for is 'buildWithSpec'. It definitely instantiate the adapters as well as the morphs, with the root of the morph tree being nil.
I can't tell you if everything will work as intended though, but I don't see why not. Benjamin developed Spec and might be able to answer that.
Finaly, I don't quite see what is wrong with opening a window in a test, as long as you send 'close' to your model at the end ?
Thomas.
2014-08-06 14:01 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com> :
Maybe you can manually set the Adapter?
Ben
On 06 Aug 2014, at 12:39, Mark Rizun <mrizun@gmail.com> wrote:
Maybe it can, but it's more convenient for me to subclass it So, how do I initialize it for tests without opening it with spec? 6 ÑеÑп. 2014 12:00, коÑиÑÑÑÐ²Ð°Ñ "Benjamin" < Benjamin.VanRyseghem.Pharo@gmail.com> напиÑав:
On 06 Aug 2014, at 11:50, Mark Rizun <mrizun@gmail.com> wrote:
No they don't:) I just replaced a menu of TextModel with my own, and added some ast support.
Canât the menu be changed dynamically in TextModel?
Ben
Thank you very much. buildWithSpec did it:) 2014-08-06 14:20 GMT+02:00 Mark Rizun <mrizun@gmail.com>:
Thomas,
The problem is that I already have lots of tests and it's only the beginning. Imagine running 50 tests at one time:) You will see 50 windows on screen. Not very good
2014-08-06 14:11 GMT+02:00 Thomas Bany <mun.sysdev@gmail.com>:
Going through the execution of 'openWithSpec', it looks like the method
you are looking for is 'buildWithSpec'. It definitely instantiate the adapters as well as the morphs, with the root of the morph tree being nil.
I can't tell you if everything will work as intended though, but I don't see why not. Benjamin developed Spec and might be able to answer that.
Finaly, I don't quite see what is wrong with opening a window in a test, as long as you send 'close' to your model at the end ?
Thomas.
2014-08-06 14:01 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com
:
Maybe you can manually set the Adapter?
Ben
On 06 Aug 2014, at 12:39, Mark Rizun <mrizun@gmail.com> wrote:
Maybe it can, but it's more convenient for me to subclass it So, how do I initialize it for tests without opening it with spec? 6 ÑеÑп. 2014 12:00, коÑиÑÑÑÐ²Ð°Ñ "Benjamin" < Benjamin.VanRyseghem.Pharo@gmail.com> напиÑав:
On 06 Aug 2014, at 11:50, Mark Rizun <mrizun@gmail.com> wrote:
No they don't:) I just replaced a menu of TextModel with my own, and added some ast support.
Canât the menu be changed dynamically in TextModel?
Ben
Okey, I hadn't read your question carefully :) Looking at TextModel>>sourceTextArea, it returns the widget of the model, meaning the adapter to PluggableTextMorph. The adapter (and the Morph behind) is instantiated during the building (called in openWithSpec) of the model, not its initialization. In short, when you call RewriteTool new, you have a fully initialized description of the GUI, but you don't have the GUI. Thomas. 2014-08-06 11:45 GMT+02:00 Benjamin <Benjamin.VanRyseghem.Pharo@gmail.com>:
On 06 Aug 2014, at 11:30, Mark Rizun <mrizun@gmail.com> wrote:
Yes it is invoked(I mean initializeWidgets in AbstractPanel) if I do: RewriteTool new.
If you put the halt after `self instantiateModels: #(#templateText #MyTextModel).` can you confirm that templateText is not nil?
And yes, I needed more functionality for TextModel
Which ones? :) Maybe they deserve to be pushed into TextModel
Ben
On 06 Aug 2014, at 11:52, Thomas Bany <mun.sysdev@gmail.com> wrote:
In short, when you call RewriteTool new, you have a fully initialized description of the GUI, but you don't have the GUI.
Exactly :) The model hierarchy is made to be independent of the rendering framework behind. Ben
participants (3)
-
Benjamin -
Mark Rizun -
Thomas Bany