~eliasnaur/gio

4 2

testing key pressed

Details
Message ID
<tU566EvhWwYfqLP5g0R8Tg-BMGJw-DSs50MaV27hIrupjBBgOJ71_IjSMf-sAWGaeezE5ytgzJ6TnDtWYADavV_3Bi9u6gg6DGftB_7oLmI=@sbinet.org>
DKIM signature
missing
Download raw message
hi,

(apologies for the barrage of questions lately)

I am trying to test a code path is taken inside my application.
That part is listening for the 'Q' key or escape key to be pressed and does something.

What is the idiomatic way in Gio to simulate a user hitting, e.g. the escape key?
I tried to grep on the _test.go files in the repository but nothing obvious jumped at me.
Any pointers?

cheers,
-s
Details
Message ID
<C3RRGULRHI8B.1ENRSJ0KKGFUQ@themachine>
In-Reply-To
<tU566EvhWwYfqLP5g0R8Tg-BMGJw-DSs50MaV27hIrupjBBgOJ71_IjSMf-sAWGaeezE5ytgzJ6TnDtWYADavV_3Bi9u6gg6DGftB_7oLmI=@sbinet.org> (view parent)
DKIM signature
pass
Download raw message
On Fri Jun 26, 2020 at 19:11, Sebastien Binet wrote:
> hi,
>
> (apologies for the barrage of questions lately)
>
> I am trying to test a code path is taken inside my application.
> That part is listening for the 'Q' key or escape key to be pressed and does something.
>
> What is the idiomatic way in Gio to simulate a user hitting, e.g. the escape key?
> I tried to grep on the _test.go files in the repository but nothing obvious jumped at me.
> Any pointers?
>

I'm not sure what exactly you're after, but you can drive the input machinery yourself
through gioui.org/router.Router. See gioui.org/example/glfw that converts GLFW events
to Gio events.

-- elias
Details
Message ID
<zxu53eMiP9KGjXkGuGme4QJ4Gr5AsNKCPa7HiGgts41cA3_ahQmwbFQejb-FSzEb5-XKUGlMdpgiprW1U1KiYJyY2p3DAwCx4oIlZqju2YI=@sbinet.org>
In-Reply-To
<C3RRGULRHI8B.1ENRSJ0KKGFUQ@themachine> (view parent)
DKIM signature
missing
Download raw message




‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, June 27, 2020 11:02 AM, Elias Naur <mail@eliasnaur.com> wrote:

> On Fri Jun 26, 2020 at 19:11, Sebastien Binet wrote:
>
> > hi,
> > (apologies for the barrage of questions lately)
> > I am trying to test a code path is taken inside my application.
> > That part is listening for the 'Q' key or escape key to be pressed and does something.
> > What is the idiomatic way in Gio to simulate a user hitting, e.g. the escape key?
> > I tried to grep on the _test.go files in the repository but nothing obvious jumped at me.
> > Any pointers?
>
> I'm not sure what exactly you're after, but you can drive the input machinery yourself
> through gioui.org/router.Router. See gioui.org/example/glfw that converts GLFW events
> to Gio events.

thanks.

I've tried a bit to wrangle router.Router into my app, but I am not sure one can use Router.Add(evt) to send events to an app.Window and have those appear in the  app.Window.Events() channel.

basically, I am trying to exercize this part of the code:
https://github.com/go-hep/hep/blob/cb3f7b30f63560185e2b7323cbfb12fb81d9de94/pawgo/wmgr.go#L89..L107

with something along the lines of:
https://github.com/go-hep/hep/blob/cb3f7b30f63560185e2b7323cbfb12fb81d9de94/pawgo/wmgr_test.go

-s
Details
Message ID
<C3TP7U9KFAVP.2ZZK81N93K2M@themachine>
In-Reply-To
<zxu53eMiP9KGjXkGuGme4QJ4Gr5AsNKCPa7HiGgts41cA3_ahQmwbFQejb-FSzEb5-XKUGlMdpgiprW1U1KiYJyY2p3DAwCx4oIlZqju2YI=@sbinet.org> (view parent)
DKIM signature
pass
Download raw message
On Mon Jun 29, 2020 at 14:00, Sebastien Binet wrote:
>
>
>
>
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Saturday, June 27, 2020 11:02 AM, Elias Naur <mail@eliasnaur.com> wrote:
>
> > On Fri Jun 26, 2020 at 19:11, Sebastien Binet wrote:
> >
> > > hi,
> > > (apologies for the barrage of questions lately)
> > > I am trying to test a code path is taken inside my application.
> > > That part is listening for the 'Q' key or escape key to be pressed and does something.
> > > What is the idiomatic way in Gio to simulate a user hitting, e.g. the escape key?
> > > I tried to grep on the _test.go files in the repository but nothing obvious jumped at me.
> > > Any pointers?
> >
> > I'm not sure what exactly you're after, but you can drive the input machinery yourself
> > through gioui.org/router.Router. See gioui.org/example/glfw that converts GLFW events
> > to Gio events.
>
> thanks.
>
> I've tried a bit to wrangle router.Router into my app, but I am not sure one can use Router.Add(evt) to send events to an app.Window and have those appear in the  app.Window.Events() channel.
>
> basically, I am trying to exercize this part of the code:
> https://github.com/go-hep/hep/blob/cb3f7b30f63560185e2b7323cbfb12fb81d9de94/pawgo/wmgr.go#L89..L107
>
> with something along the lines of:
> https://github.com/go-hep/hep/blob/cb3f7b30f63560185e2b7323cbfb12fb81d9de94/pawgo/wmgr_test.go
>

I see. Why not extract the content of the `case e := <-w.w.Events()` into a function and call that?

I suppose we could add a app.Window.Inject(event.Event) if you like.

-- elias
Details
Message ID
<OjD_JgYwRMXATrPEpKLj-A9W5rxpvovjiQghmgRoaMf6cIIdmY16mm2E-seyGjpTafR6PvLXu6ctATo9oKLuN8fE5HMMpatFqk1uphZjrYM=@sbinet.org>
In-Reply-To
<C3TP7U9KFAVP.2ZZK81N93K2M@themachine> (view parent)
DKIM signature
missing
Download raw message

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, June 29, 2020 5:41 PM, Elias Naur <mail@eliasnaur.com> wrote:

> On Mon Jun 29, 2020 at 14:00, Sebastien Binet wrote:
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > On Saturday, June 27, 2020 11:02 AM, Elias Naur mail@eliasnaur.com wrote:
> >
> > > On Fri Jun 26, 2020 at 19:11, Sebastien Binet wrote:
> > >
> > > > hi,
> > > > (apologies for the barrage of questions lately)
> > > > I am trying to test a code path is taken inside my application.
> > > > That part is listening for the 'Q' key or escape key to be pressed and does something.
> > > > What is the idiomatic way in Gio to simulate a user hitting, e.g. the escape key?
> > > > I tried to grep on the _test.go files in the repository but nothing obvious jumped at me.
> > > > Any pointers?
> > >
> > > I'm not sure what exactly you're after, but you can drive the input machinery yourself
> > > through gioui.org/router.Router. See gioui.org/example/glfw that converts GLFW events
> > > to Gio events.
> >
> > thanks.
> > I've tried a bit to wrangle router.Router into my app, but I am not sure one can use Router.Add(evt) to send events to an app.Window and have those appear in the app.Window.Events() channel.
> > basically, I am trying to exercize this part of the code:
> > https://github.com/go-hep/hep/blob/cb3f7b30f63560185e2b7323cbfb12fb81d9de94/pawgo/wmgr.go#L89..L107
> > with something along the lines of:
> > https://github.com/go-hep/hep/blob/cb3f7b30f63560185e2b7323cbfb12fb81d9de94/pawgo/wmgr_test.go
>
> I see. Why not extract the content of the`case e := <-w.w.Events()` into a function and call that?
>
> I suppose we could add a app.Window.Inject(event.Event) if you like.

I guess that could reduce the amount of boilerplate code and/or scaffolding to setup "just" to test how a window behaves.

-s
Export thread (mbox)