<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/127952/">https://git.reviewboard.kde.org/r/127952/</a>
     </td>
    </tr>
   </table>
   <br />










<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On May 18th, 2016, 9:58 a.m. UTC, <b>Marco Martin</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  


<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://git.reviewboard.kde.org/r/127952/diff/1/?file=465111#file465111line223" style="color: black; font-weight: bold; text-decoration: underline;">src/kicontheme.h</a>
    <span style="font-weight: normal;">

     (Diff revision 1)

    </span>
   </th>
  </tr>
 </thead>



 
 

 <tbody>

  <tr>
    <th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
    <th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">223</font></th>
    <td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">    <span class="k">static</span> <span class="kt">void</span> <span class="nf">forceCurrent</span><span class="p">(</span><span class="k">const</span> <span class="n">QString</span> <span class="o">&</span><span class="n">themeName</span><span class="p">);</span></pre></td>
  </tr>

 </tbody>

</table>

  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">what about just a testmode bool like qstandardpaths?</p></pre>
 </blockquote>





</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">That would be the other approach I talk about in the description. I am fairly indifferent which of the two approaches we use. This one is certainly more to the point as it ultimately allows getting rid of the entire kdeglobals hackery in tests. ::forceCurrent is functionally equal to test env setup like this:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%">    <span style="color: #008000; font-weight: bold">KConfigGroup</span> <span style="color: #008000; font-weight: bold">cg</span><span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">KSharedConfig</span><span style="color: #666666">:</span><span style="color: #AA22FF">:openConfig</span><span style="color: #666666">(),</span> <span style="color: #BA2121">"Icons"</span><span style="color: #666666">);</span>
    <span style="color: #008000; font-weight: bold">cg</span><span style="color: #0000FF; font-weight: bold">.writeEntry</span><span style="color: #666666">(</span><span style="color: #BA2121">"Theme"</span><span style="color: #666666">,</span> <span style="color: #BA2121">"test-theme"</span><span style="color: #666666">);</span>
    <span style="color: #008000; font-weight: bold">cg</span><span style="color: #0000FF; font-weight: bold">.sync</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">KSharedConfig</span><span style="color: #666666">:</span><span style="color: #AA22FF">:openConfig</span><span style="color: #666666">()</span><span style="color: #008000; font-weight: bold">-</span><span style="color: #666666">></span><span style="color: #008000; font-weight: bold">reparseConfiguration</span><span style="color: #666666">();</span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">In fact what we could if we add a new function to KIconLoader do is have the following:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold">KIconTheme</span><span style="color: #666666">:</span><span style="color: #AA22FF">:forceCurrent</span><span style="color: #666666">(</span><span style="color: #BA2121">"test-theme"</span><span style="color: #666666">);</span>
<span style="color: #008000; font-weight: bold">KIconLoader</span><span style="color: #666666">:</span><span style="color: #AA22FF">:global</span><span style="color: #666666">()</span><span style="color: #008000; font-weight: bold">-</span><span style="color: #666666">></span><span style="color: #008000; font-weight: bold">fullReload</span><span style="color: #666666">();</span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">to be equal to what we have now in plasma tests:</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%">    <span style="color: #008000; font-weight: bold">KConfigGroup</span> <span style="color: #008000; font-weight: bold">cg</span><span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">KSharedConfig</span><span style="color: #666666">:</span><span style="color: #AA22FF">:openConfig</span><span style="color: #666666">(),</span> <span style="color: #BA2121">"Icons"</span><span style="color: #666666">);</span>
    <span style="color: #008000; font-weight: bold">cg</span><span style="color: #0000FF; font-weight: bold">.writeEntry</span><span style="color: #666666">(</span><span style="color: #BA2121">"Theme"</span><span style="color: #666666">,</span> <span style="color: #BA2121">"test-theme"</span><span style="color: #666666">);</span>
    <span style="color: #008000; font-weight: bold">cg</span><span style="color: #0000FF; font-weight: bold">.sync</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">KSharedConfig</span><span style="color: #666666">:</span><span style="color: #AA22FF">:openConfig</span><span style="color: #666666">()</span><span style="color: #008000; font-weight: bold">-</span><span style="color: #666666">></span><span style="color: #008000; font-weight: bold">reparseConfiguration</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">KIconTheme</span><span style="color: #666666">:</span><span style="color: #AA22FF">:reconfigure</span><span style="color: #666666">();</span>
    <span style="color: #008000; font-weight: bold">KIconLoader</span><span style="color: #666666">:</span><span style="color: #AA22FF">:global</span><span style="color: #666666">()</span><span style="color: #008000; font-weight: bold">-</span><span style="color: #666666">></span><span style="color: #008000; font-weight: bold">reconfigure</span><span style="color: #666666">(</span><span style="color: #008000; font-weight: bold">QString</span><span style="color: #666666">());</span>
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">So, the way I see it a generic ::setTestingModeEnabled would only solve the issue at hand of QIcon::themeName interfering with expectations, while with the presented ::forceCurrent we can solve the issue at hand and reduce overhead code in testing.</p></pre>
<br />




<p>- Harald</p>


<br />
<p>On May 18th, 2016, 8:25 a.m. UTC, Harald Sitter wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for KDE Frameworks, Christoph Feck, David Edmundson, and Marco Martin.</div>
<div>By Harald Sitter.</div>


<p style="color: grey;"><i>Updated May 18, 2016, 8:25 a.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kiconthemes
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">this allows unit tests to force a specific name to be used regardless of
which branch of the current() resolution would bite first. the override
wins and that is that.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">in particular this allows unit tests to force a fake theme</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">NOTES:
- this approach means tests need to be explicitly adapted to this new thing (e.g. https://paste.kde.org/pjzwg47s7)
- another approach would be to have a switch to disable qicon::theme entirely, which has the advantage of not requiring additional changes to other tests
- the presented approach in the long run (with possibly a bit more rigging in kiconloader) allow a test to force all it's kiconthemes magic to use a given theme without having to touch kdeglobals or running manually reconfigures etc.
- both viable, I like this one better though
- ::overrideCurrent would be another possible name but ::force sounds more like what it ultimately does in terms of impact</p></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">unit test + adapted plasma-framework's themetest to use this</p></pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>autotests/CMakeLists.txt <span style="color: grey">(7af101398774bd138fe57f3765416cfcfb022f75)</span></li>

 <li>src/kicontheme.h <span style="color: grey">(dafece91f401ea0f8188613c55ee92d96d293879)</span></li>

 <li>src/kicontheme.cpp <span style="color: grey">(f3d4cf71c05fe143464952bec89497fb911f2291)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/127952/diff/" style="margin-left: 3em;">View Diff</a></p>






  </td>
 </tr>
</table>







  </div>
 </body>
</html>