Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tm-dev] TextCanvas in automatic testing - a method to read the content is missing

Hello Michael,

thank you very much for the quite extensive reply, especially
for the explanation why my first attempt could not work.

...
> > I distilled a new attempt:
> > 
> >   public String getTextContent() {
> > 
> >       ITerminalTextDataReadOnly terminalText
> >           = fCellCanvasModel.getTerminalText();
> > 
> >       ITerminalTextDataSnapshot snapshot
> >           = ((ITerminalTextDataSnapshot)terminalText)
> >               .getTerminalTextData().makeSnapshot();
> >       snapshot.updateSnapshot(true);
> >       snapshot.detach();
> > 
> >       // Collect all snapshot.getChars(i), skipped for brevity.
> >   }
> > 
> > This seems to work, at least as a proof of concept. However,
> > the need to cast terminalText to ITerminalTextDataSnapshot
> > indicates that I'm working on a wrong level of abstraction.
> 
> Int he original version, I have tried to hide the implementation.
> I think for a test, the cast may be OK. Unfortunately, I am
> currently not actively working on the terminal.

Well, the primary use case is in testing, but it's a public
method nevertheless and I didn't feel comfortable with that
bit of "cheating" :-)

I gave it another try and eventually created two small patches
([1], [2]). The first is just a trivial refactoring so part of
the existing code ("scrub a line") can be reused. The second
patch is the proposal itself. In essence:

 - add getAllText() to ITextCanvasModel - my though was "if it
   can provide getSelectedText() then it might as well provide
   getAllText()"

 - implement it in AbstractTextCanvasModel - quite simple: get
   a snapshot, read all its characters and do the same scrubbing
   as getSelectedText() does

 - create TextCanvas.getTextContent() as a simple redirection,
   just fCellCanvasModel.getAllText()

Now no casting is needed and overall, it "feels" better. (But
I have to admit I don't actually understand the surrounding
code, much less the overall architecture...)

If the idea looks reasonable, let's finish the details in
Bugzilla.

[1] https://bugs.eclipse.org/bugs/attachment.cgi?id=268695&action=diff
[2] https://bugs.eclipse.org/bugs/attachment.cgi?id=268696&action=diff

> 
> What I can offer you is to have live session where we share
> a screen and we add our knowledge to find a good solution..

That's very kind of you, thanks! At this moment it might not
be necessary but I'll contact you off-list if it gets opaque
again :-)

> 
> Which timezone are you in?

CEST (UTC+2)

Thanks,
Vaclav


Back to the top