Powerful and easy way to testing text

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

Powerful and easy way to testing text

Mickael Istria-5
Hi all,

As we're having fun with StyledText and editors these days, some of us contributors have had discussions about how to test things.
I'd like to share with you a simple and powerful approach to test Text rendering (in a widget, in an editor, wherever): using an OCR like Tesseract.

I've tried the following:
* Open a Java editor with codeminings enabled
* Took a screenshot of the editor (cropped to remove ruler and keep only text)
* then ran from CLI `tesseract /path/to/screenshot.png stdout -psm 6` and got as output a string that matches almost perfectly the text in the editor; more particularly showing the codeminings were rendered and read properly.

I think it's an extremely powerful way to do rendering test for StyledText and the family (editors, code minings...).
Would is seem acceptable to start adopting such OCR-based tests where needed in Platform? I really think it's 1000 times worth it.

Cheers,

--
Mickael Istria
Eclipse IDE developer, for Red Hat Developers

_______________________________________________
platform-ui-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-ui-dev
Reply | Threaded
Open this post in threaded view
|

Re: Powerful and easy way to testing text

Angelo zerr
Hi Mickael,

I love it your idea. As codemining is more and more used, we MUST write test, because rendering of codemining is very hard to manage (because rendering is done with CompletableFuture when mining is resolved) and each time we try to improve the renderer, we break every time a iven gusecase.

For codemining tests, I would like to have simple written test like:

--------------------------------------------------------------
String actual = "class A {}"
String expected = "[0 references]
                               class A {}"  
CodeMiningAssert.assert(actual, expected, classCodeMiningProvider);
-------------------------------------------------------------- 

I find it's very easy to read the test. I would like to test too when text changed (codemining changed too).

Thanks for investigating about this test topic.

Regard's Angelo

Le ven. 23 nov. 2018 à 15:42, Mickael Istria <[hidden email]> a écrit :
Hi all,

As we're having fun with StyledText and editors these days, some of us contributors have had discussions about how to test things.
I'd like to share with you a simple and powerful approach to test Text rendering (in a widget, in an editor, wherever): using an OCR like Tesseract.

I've tried the following:
* Open a Java editor with codeminings enabled
* Took a screenshot of the editor (cropped to remove ruler and keep only text)
* then ran from CLI `tesseract /path/to/screenshot.png stdout -psm 6` and got as output a string that matches almost perfectly the text in the editor; more particularly showing the codeminings were rendered and read properly.

I think it's an extremely powerful way to do rendering test for StyledText and the family (editors, code minings...).
Would is seem acceptable to start adopting such OCR-based tests where needed in Platform? I really think it's 1000 times worth it.

Cheers,

--
Mickael Istria
Eclipse IDE developer, for Red Hat Developers
_______________________________________________
platform-ui-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-ui-dev

_______________________________________________
platform-ui-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-ui-dev
Reply | Threaded
Open this post in threaded view
|

Re: Powerful and easy way to testing text

Mickael Istria-5
Hey Angelo,

If we go for an OCR-based implementation, you can write something like

```
styledText.setText("class A {}");
assertEquals("0 references\nclass A {}", OCRHelper.read(styledText))
```

_______________________________________________
platform-ui-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-ui-dev
Reply | Threaded
Open this post in threaded view
|

Re: Powerful and easy way to testing text

Angelo zerr
Wow exactly that I had in my mind.

+1000 for OCR!

Le ven. 23 nov. 2018 à 18:48, Mickael Istria <[hidden email]> a écrit :
Hey Angelo,

If we go for an OCR-based implementation, you can write something like

```
styledText.setText("class A {}");
assertEquals("0 references\nclass A {}", OCRHelper.read(styledText))
```
_______________________________________________
platform-ui-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-ui-dev

_______________________________________________
platform-ui-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-ui-dev
Reply | Threaded
Open this post in threaded view
|

Re: Powerful and easy way to testing text

Mickael Istria-5
Hi all,

So I didn't see any objection against it. I guess that it means that an OCRHelper class in org.eclipse.ui.tests.harness which invokes tesseract is welcome as soon as it's necessary?

_______________________________________________
platform-ui-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-ui-dev