11 comments

Hi Tomas,

Sorry, it's not clear what are you trying to do, can you please specify? Are you working on custom plugin?

0

Hi,

i am sorry. I am developing plugin, where i paint additional text at the end of some lines (line extensions). For this, i am using EditorLinePainter.class and i am overriding getLineExtensions method to paint a text.

And i would like to write unittest for this functionality, to check if the text was painted at specified line.

I would expect testHighlighting() from  CodeInsightTestFixture.class would run my plugin code and paint the text or something similar. But it doesnt work and i didnt find any function to do that. 

How can i test EditorLinePainter?

 

 

0

Hello Tomas,

If possible please describe in more details what are you planning to test. Thank you

0

Hi Olga,

of course. So firsly i will describe functionality of my plugin. As i said i have a class which extend from:
https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/openapi/editor/EditorLinePainter.java

In this class i override method getLineExtensions(). Inside the method, i create instances of the object:
https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/openapi/editor/LineExtensionInfo.java
I return collection of these instances.

This way i am able to paint custom text at different lines to different files in editor. Example:

The red text (its not clickable and cannot be edited, its just painted there) is result. And i want to unit test this.

 

Tomas

0
Hello Tomas, Sorry for a long time to reply. Unfortunately, IntelliJ Platform does not provide a way to unit test Line Extensions. They are rendered as graphical elements, not the text, and you may test them using some image comparison tool.
0

Thank you for answer. So how could i retrieve those 'rendered graphical elements'/pictures in my unittest? So i can compare then with expected ones.

0

For example, I can suggest a tool which our QA Automation Team is using: https://mvnrepository.com/artifact/ru.yandex.qatools.ashot

0

If read about that tool here:
https://github.com/pazone/ashot
It looks like it can retrieve graphical elements from websites. But i need to retrieve graphical elements generated using getLineExtensions() function. Maybe i am missing something. Could you tell me more how could i use that tool to compare line extensions graphical elements?

0

If i understand it correctly, i can use this class to compare two images. But the problem is, i dont know how to retrieve 'actual' image. By that, i mean, i dont know how to automatically retrieve line extention image in unittest of my plugin.

0

You can make a screenshot, and then compare it with the expected one using ImageDiffer#makeDiff.

For that, you may use tools from java.awt package: https://stackoverflow.com/questions/4490454/how-to-take-a-screenshot-in-java

0

Please sign in to leave a comment.