<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi Ezequiel,<br>
    <br>
    Testing UIs is generally considered difficult and fragile.<br>
    <br>
    You raise several valid questions. I don't have good answers for any
    of them.<br>
    <br>
    The more 'clever' code you add, the more removed from reality the
    test becomes. That increases the risk of 1) the test not testing the
    actual behavior of a live UI and 2) even if the test is ok, the test
    will eventually break (due to excessive assumptions on the internals
    of the UI framework). This critique applies to LayoutMorphTest, that
    was, most likely, written by me... As I said before, I don't have
    good answers in this area.<br>
    <br>
    On 3/13/2025 1:54 PM, Ezequiel Birman via Cuis-dev wrote:
    <blockquote
cite="mid:CAOo=t4cdd5hDaemdK1hoNG8KP6-1VHUUj=P1ZO9Mpp1=z4GOCA@mail.gmail.com"
      type="cite">
      <div dir="ltr">After more tinkering, I can make the test pass
        without sending <b>privateDisplayBounds:</b> It seems enough to
        write:<br>
        <div><br>
        </div>
        <blockquote class="gmail_quote" style="margin: 0px 0px 0px
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">test02_BoundedUnopenedMorphCollides<br>
          <br>
          | m1 |<br>
          <br>
          m1 := Morph new.<br>
          <br>
          "Hack to avoid opening morphs in the world.`#collides:` relies
          on the morphs having a display bound, so we use
          `findFullBoundsInOwner` for its side-effects"<br>
          "m1 setProperty: #fullBoundsInOwner toValue: m1
          findFullBoundsInOwner."<br>
          m1 findFullBoundsInOwner.<br>
          <br>
          self assert: (m1 collides: m1)</blockquote>
        <div><br>
        </div>
        <div>Any objections?</div>
      </div>
      <br>
      <div class="gmail_quote gmail_quote_container">
        <div dir="ltr" class="gmail_attr">On Mon, 23 Dec 2024 at 22:08,
          Ezequiel Birman <<a moz-do-not-send="true"
            href="mailto:ebirman77@gmail.com">ebirman77@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin: 0px 0px 0px
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div dir="ltr">
            <div dir="ltr">I've just realised that the code snippet I
              quoted in my previous message is missing the final part.
              Here it is in full:
              <div><br>
                <blockquote class="gmail_quote" style="margin: 0px 0px
                  0px 0.8ex; border-left: 1px solid rgb(204, 204, 204);
                  padding-left: 1ex;">(UISupervisor animatedUIOf:
                  Processor activeProcess)<br>
                   ifNotNil: [ :ui | ui doOneCycleNowOn: ui mainCanvas ]<br>
                    ifNil: [ | updated d |<br>
                      updated := false.<br>
                      d := Delay forMilliseconds: 10.<br>
                      UISupervisor whenUIinSafeState: [ UISupervisor
                  whenUIinSafeState: [updated := true ]].<br>
                      [updated] whileFalse: [<br>
                        d wait ]].</blockquote>
                <div><br>
                </div>
                <div>To clarify comment/question (3) in my previous
                  message, If I remove one of <b>whenUIinSafeState:</b> leaving
                  the snippet as this:</div>
                <div>
                  <blockquote class="gmail_quote" style="margin: 0px 0px
                    0px 0.8ex; border-left: 1px solid rgb(204, 204,
                    204); padding-left: 1ex;">(UISupervisor
                    animatedUIOf: Processor activeProcess)<br>
                     ifNotNil: [ :ui | ui doOneCycleNowOn: ui mainCanvas
                    ]<br>
                      ifNil: [ | updated d |<br>
                        updated := false.<br>
                        d := Delay forMilliseconds: 10.<br>
                        UISupervisor whenUIinSafeState: [updated := true
                    ].<br>
                        [updated] whileFalse: [<br>
                          d wait ]].</blockquote>
                  <div>The LayoutMorph tests still pass.</div>
                </div>
              </div>
            </div>
            <br>
            <div class="gmail_quote">
              <div dir="ltr" class="gmail_attr">On Sat, 21 Dec 2024 at
                22:32, Ezequiel Birman <<a moz-do-not-send="true"
                  href="mailto:ebirman77@gmail.com" target="_blank">ebirman77@gmail.com</a>>
                wrote:<br>
              </div>
              <blockquote class="gmail_quote" style="margin: 0px 0px 0px
                0.8ex; border-left: 1px solid rgb(204, 204, 204);
                padding-left: 1ex;">
                <div dir="ltr">
                  <div>Hi! I am revisiting the <i>Spacewar!</i>
                    exercise from The Cuis Smalltalk Book, and I am
                    testing things that deal with morph collisions.</div>
                  <div><span><br>
                    </span></div>
                  <div><span>The </span><b>LayoutMorphTest</b> tests in
                    BaseImageTests insert clever code before the
                    assertions, to ensure things happen orderly:</div>
                  <blockquote class="gmail_quote" style="margin: 0px 0px
                    0px 0.8ex; border-left: 1px solid rgb(204, 204,
                    204); padding-left: 1ex;">(UISupervisor
                    animatedUIOf: Processor activeProcess)<br>
                      ifNotNil: [ :ui | ui doOneCycleNowOn: ui
                    mainCanvas ]<br>
                      ifNil: [ | updated d |<br>
                        updated := false.<br>
                        d := Delay forMilliseconds: 10.<br>
                        UISupervisor whenUIinSafeState: [ UISupervisor
                    whenUIinSafeState: [ updated := true ]].</blockquote>
                  <div><br>
                  </div>
                  <div>Since I don't need (or I can't see the need) for
                    my tests to display morphs on the screen, and since
                    <b>Morph>>collides:</b> relies on the morphs
                    having a display bound, in my tests it was enough to
                    insert</div>
                  <blockquote class="gmail_quote" style="margin: 0px 0px
                    0px 0.8ex; border-left: 1px solid rgb(204, 204,
                    204); padding-left: 1ex;">space
                    privateDisplayBounds: space fullBoundsInOwner</blockquote>
                  <div>before the assertions, where <i>space</i> owns
                    the colliding morphs in the test; and since I don't
                    display things on screen, test runs feel snappier.</div>
                  <div><br>
                  </div>
                  <div>1) The thing I'm doing with <b>privateDisplayBounds:</b>
                    will it come back to bite me?</div>
                  <div>2) Is it better, for some definition of better,
                    for morphic tests to display morphs on screen while
                    they run?</div>
                  <div>3) I don't understand the need for the nesting in
                    <b>UISupervisor whenUIinSafeState: [ UISupervisor
                      whenUIinSafeState: [ updated := true ]]</b>, I
                    removed the outer level and the LayoutMorph tests
                    still pass. Maybe by chance? Things are hard to
                    debug when they behave differently when debugging.</div>
                  <div>4) Can you imagine another way of writing
                    these kinds of tests?</div>
                  <div><br>
                  </div>
                  <div>I attached a couple of simple examples so you
                    don't have to type them.</div>
                  <div><br>
                  </div>
                  <div>-- </div>
                  <div>Eze</div>
                </div>
              </blockquote>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich</pre>
  </body>
</html>