Question on Spec

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

Question on Spec

Mark Rizun
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
Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)
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 <[hidden email]> 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.


Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun
initializeWidgets
self
instantiateModels: #(#sourcePanel #SourcePanel #resultPanel #ResultPanel #matchPanel #MatchPanel #transformPanel #TransformPanel #acceptButton #ButtonModel).


2014-08-06 10:58 GMT+02:00 Benjamin <[hidden email]>:
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 <[hidden email]> 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.



Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)
On 06 Aug 2014, at 11:04, Mark Rizun <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun
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 <[hidden email]>:
On 06 Aug 2014, at 11:04, Mark Rizun <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Thomas Bany
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 <[hidden email]>:
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 <[hidden email]>:

On 06 Aug 2014, at 11:04, Mark Rizun <[hidden email]> 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


Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)
In reply to this post by Mark Rizun
On 06 Aug 2014, at 11:16, Mark Rizun <[hidden email]> 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?

Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun
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 <[hidden email]>:
On 06 Aug 2014, at 11:16, Mark Rizun <[hidden email]> 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?


Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun
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 <[hidden email]>:
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 <[hidden email]>:

On 06 Aug 2014, at 11:16, Mark Rizun <[hidden email]> 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?



Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)
In reply to this post by Mark Rizun
On 06 Aug 2014, at 11:30, Mark Rizun <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun
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 <[hidden email]>:
On 06 Aug 2014, at 11:30, Mark Rizun <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Thomas Bany
In reply to this post by Benjamin Van Ryseghem (Pharo)
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 <[hidden email]>:
On 06 Aug 2014, at 11:30, Mark Rizun <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)
On 06 Aug 2014, at 11:52, Thomas Bany <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)
In reply to this post by Mark Rizun
On 06 Aug 2014, at 11:50, Mark Rizun <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun

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" <[hidden email]> написав:
On 06 Aug 2014, at 11:50, Mark Rizun <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)
Maybe you can manually set the Adapter?

Ben

On 06 Aug 2014, at 12:39, Mark Rizun <[hidden email]> 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" <[hidden email]> написав:
On 06 Aug 2014, at 11:50, Mark Rizun <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Thomas Bany
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 <[hidden email]>:
Maybe you can manually set the Adapter?

Ben

On 06 Aug 2014, at 12:39, Mark Rizun <[hidden email]> 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" <[hidden email]> написав:
On 06 Aug 2014, at 11:50, Mark Rizun <[hidden email]> 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


Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Benjamin Van Ryseghem (Pharo)

On 06 Aug 2014, at 14:11, Thomas Bany <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun
In reply to this post by Thomas Bany
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 <[hidden email]>:
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 <[hidden email]>:

Maybe you can manually set the Adapter?

Ben

On 06 Aug 2014, at 12:39, Mark Rizun <[hidden email]> 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" <[hidden email]> написав:
On 06 Aug 2014, at 11:50, Mark Rizun <[hidden email]> 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



Reply | Threaded
Open this post in threaded view
|

Re: Question on Spec

Mark Rizun
Thank you very much. buildWithSpec did it:)


2014-08-06 14:20 GMT+02:00 Mark Rizun <[hidden email]>:
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 <[hidden email]>:

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 <[hidden email]>:

Maybe you can manually set the Adapter?

Ben

On 06 Aug 2014, at 12:39, Mark Rizun <[hidden email]> 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" <[hidden email]> написав:
On 06 Aug 2014, at 11:50, Mark Rizun <[hidden email]> 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