Druid: Add ability to save a render of a widget to file during tests

Created on 7 Feb 2020  路  6Comments  路  Source: linebender/druid

This would be a debug tool, but I think it would be quite useful; basically it would be helpful if there was a method on the test harness, like paint_to_file(path: AsRef<Path>) that would call paint, and then write the buffer to disk.

This is currently blocked on https://github.com/linebender/piet/pull/132, which will provide us with an API in piet_common that we can use to write a png.

One thing I'm not sure about is whether or not we will be able to continue calling harness methods after doing this; it's possible that it consumes the render context. That's okay, though, for our purposes.

D-Easy help wanted

All 6 comments

I was thinking that i might be able to use this to test how the fill function is working for image and svg. if you point me in the right direction i may be able to help.

There's an example of writing a piet context to an image in piet itself: https://github.com/linebender/piet/tree/master/piet-cairo/examples/basic-cairo.rs

^^ That is cairo only example, common one is here https://github.com/linebender/piet/blob/master/piet-common/examples/png.rs

I played around with this a week or two ago, you can maybe use this as somewhere to start? https://github.com/xi-editor/druid/tree/write-image-in-tests

I have been busy using druid rather then developing it recently, I want to circle back to this soon. thanks for all the links they all look really useful!

closed in #784

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andrewdavidmackenzie picture andrewdavidmackenzie  路  5Comments

MGlolenstine picture MGlolenstine  路  6Comments

cmyr picture cmyr  路  3Comments

psychon picture psychon  路  6Comments

cmyr picture cmyr  路  3Comments