<table><tr><td style="">zzag added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D15907">View Revision</a></tr></table><br /><div><div><div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="cpp" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);"><span style="color: #aa4000">void</span> <span class="n">DecorationButtonTest</span><span style="color: #aa2211">::</span><span class="n">testContains_data</span><span class="p">()</span>
<span class="p">{</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">addColumn</span><span style="color: #aa2211"><</span><span class="n">QRectF</span><span style="color: #aa2211">></span><span class="p">(</span><span style="color: #766510">"geometry"</span><span class="p">);</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">addColumn</span><span style="color: #aa2211"><</span><span class="n">QPointF</span><span style="color: #aa2211">></span><span class="p">(</span><span style="color: #766510">"pos"</span><span class="p">);</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">addColumn</span><span style="color: #aa2211"><</span><span style="color: #aa4000">bool</span><span style="color: #aa2211">></span><span class="p">(</span><span style="color: #766510">"contains"</span><span class="p">);</span>

    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"left edge (integer)"</span><span class="p">)</span>   <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">5</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"top edge (integer)"</span><span class="p">)</span>    <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"right edge (integer)"</span><span class="p">)</span>  <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">9</span><span class="p">,</span> <span style="color: #601200">5</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"bottom edge (integer)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5</span><span class="p">,</span> <span style="color: #601200">9</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"inside (integer)"</span><span class="p">)</span>      <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5</span><span class="p">,</span> <span style="color: #601200">5</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>

    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 1 (integer)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #aa2211">-</span><span style="color: #601200">1</span><span class="p">,</span> <span style="color: #601200">5</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 2 (integer)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5</span><span class="p">,</span> <span style="color: #aa2211">-</span><span style="color: #601200">1</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 3 (integer)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">5</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 4 (integer)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">0</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5</span><span class="p">,</span> <span style="color: #601200">10</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>

    <span style="color: #aa4000">const</span> <span class="n">qreal</span> <span class="n">eps</span> <span style="color: #aa2211">=</span> <span style="color: #601200">1e-3</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"left edge (float)"</span><span class="p">)</span>   <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">5.1</span><span class="p">)</span>        <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"top edge (float)"</span><span class="p">)</span>    <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">)</span>        <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"right edge (float)"</span><span class="p">)</span>  <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">10.1</span> <span style="color: #aa2211">-</span> <span class="n">eps</span><span class="p">,</span> <span style="color: #601200">5.1</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"bottom edge (float)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5.1</span><span class="p">,</span> <span style="color: #601200">10.1</span> <span style="color: #aa2211">-</span> <span class="n">eps</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"inside (float)"</span><span class="p">)</span>      <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5.0</span><span class="p">,</span> <span style="color: #601200">5.0</span><span class="p">)</span>        <span style="color: #aa2211"><<</span> <span style="color: #304a96">true</span><span class="p">;</span>

    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 1 (float)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">0.1</span> <span style="color: #aa2211">-</span> <span class="n">eps</span><span class="p">,</span> <span style="color: #601200">5.1</span><span class="p">)</span>  <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 2 (float)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5.1</span><span class="p">,</span> <span style="color: #601200">0.1</span> <span style="color: #aa2211">-</span> <span class="n">eps</span><span class="p">)</span>  <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 3 (float)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">10.1</span><span class="p">,</span> <span style="color: #601200">5.1</span><span class="p">)</span>       <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 4 (float)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5.1</span><span class="p">,</span> <span style="color: #601200">10.1</span><span class="p">)</span>       <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 5 (float)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">10.1</span> <span style="color: #aa2211">+</span> <span class="n">eps</span><span class="p">,</span> <span style="color: #601200">5.1</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
    <span class="n">QTest</span><span style="color: #aa2211">::</span><span class="n">newRow</span><span class="p">(</span><span style="color: #766510">"outside 6 (float)"</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QRectF</span><span class="p">(</span><span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">0.1</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">,</span> <span style="color: #601200">10.0</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span class="n">QPointF</span><span class="p">(</span><span style="color: #601200">5.1</span><span class="p">,</span> <span style="color: #601200">10.1</span> <span style="color: #aa2211">+</span> <span class="n">eps</span><span class="p">)</span> <span style="color: #aa2211"><<</span> <span style="color: #304a96">false</span><span class="p">;</span>
<span class="p">}</span>

<span style="color: #aa4000">void</span> <span class="n">DecorationButtonTest</span><span style="color: #aa2211">::</span><span class="n">testContains</span><span class="p">()</span>
<span class="p">{</span>
    <span class="n">MockBridge</span> <span class="n">bridge</span><span class="p">;</span>
    <span class="n">MockDecoration</span> <span style="color: #004012">mockDecoration</span><span class="p">(</span><span style="color: #aa2211">&</span><span class="n">bridge</span><span class="p">);</span>

    <span class="n">QFETCH</span><span class="p">(</span><span class="n">QRectF</span><span class="p">,</span> <span class="n">geometry</span><span class="p">);</span>
    <span class="n">MockButton</span> <span style="color: #004012">button</span><span class="p">(</span><span class="n">KDecoration2</span><span style="color: #aa2211">::</span><span class="n">DecorationButtonType</span><span style="color: #aa2211">::</span><span class="n">Custom</span><span class="p">,</span> <span style="color: #aa2211">&</span><span class="n">mockDecoration</span><span class="p">);</span>
    <span class="n">button</span><span class="p">.</span><span class="n">setGeometry</span><span class="p">(</span><span class="n">geometry</span><span class="p">);</span>
    <span class="n">button</span><span class="p">.</span><span class="n">setEnabled</span><span class="p">(</span><span style="color: #304a96">true</span><span class="p">);</span>
    <span class="n">button</span><span class="p">.</span><span class="n">setVisible</span><span class="p">(</span><span style="color: #304a96">true</span><span class="p">);</span>

    <span class="n">QFETCH</span><span class="p">(</span><span class="n">QPointF</span><span class="p">,</span> <span class="n">pos</span><span class="p">);</span>
    <span class="n">QTEST</span><span class="p">(</span><span class="n">button</span><span class="p">.</span><span class="n">contains</span><span class="p">(</span><span class="n">pos</span><span class="p">),</span> <span style="color: #766510">"contains"</span><span class="p">);</span>
<span class="p">}</span></pre></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R129 Window Decoration Library</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D15907">https://phabricator.kde.org/D15907</a></div></div><br /><div><strong>To: </strong>romangg, KWin, zzag, davidedmundson<br /><strong>Cc: </strong>plasma-devel, jraleigh, GB_2, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br /></div>