<table><tr><td style="">jjazeix closed this revision.<br />jjazeix 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/D11034">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
          color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D11034#232060" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: line-through;">D11034#232060</a>, <a href="https://phabricator.kde.org/p/himanshuvishwakarma/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@himanshuvishwakarma</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><blockquote style="border-left: 3px solid #8C98B8;
          color: #6B748C;
          font-style: italic;
          margin: 4px 0 12px 0;
          padding: 8px 12px;
          background-color: #F8F9FC;">
<div style="font-style: normal;
          padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D11034#231907" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: line-through;">D11034#231907</a>, <a href="https://phabricator.kde.org/p/jjazeix/" style="
              border-color: #f1f7ff;
              color: #19558d;
              background-color: #f1f7ff;
                border: 1px solid transparent;
                border-radius: 3px;
                font-weight: bold;
                padding: 0 4px;">@jjazeix</a> wrote:</div>
<div style="margin: 0;
          padding: 0;
          border: 0;
          color: rgb(107, 116, 140);"><p>Can you check that if you instantiate a ApplicationSettingsMock object, then use ApplicationSettings::getInstance(), it returns the mock instead of creating a new ApplicationSettings object?<br />
 As we use it this way on other classes (like ApplicationInfo), it would be better that, for tests, the getInstance() returns the mock instead of the real one (else we'll have the same issue as we had here, writing on the real configuration).</p>

<p>Except this point (and the small one regarding parameters ordering), it seems good to me, I'll take a closer look this week-end to integrate it</p></div>
</blockquote>

<p>Hi,</p>

<p>I have checked that it the when we use the ApplicationSettings::getInstance( ), after the instantiate object of ApplicationSettingsMock. It will not disturb the main config file anyway.</p></div>
</blockquote>

<p>Yes, it does, the getInstance by default will get the static object m_instance. Even if the mock is created before, the m_instance is still null when calling getInstance and thus it is instanciated to a simple ApplicationSettings which will write on the main config file instead of the dummy one.<br />
I added a getInstance in the mock to create the m_instance as a Mock.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>It will disturb only when the object of ApplicationSettingsMock is not destroyed, that is the object of ApplicationSettingsMock is existing and then we call the function ApplicationSettings::getInstance( )</p>

<p>I have checked it by this methods</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Change in the file ApplicationSettingsTest.cpp like this: <a href="https://paste.kde.org/pkfzgqgtx" class="remarkup-link" target="_blank" rel="noreferrer">https://paste.kde.org/pkfzgqgtx</a> Run the test. Result: Function ApplcationSettingsTest will reflect the change in the file build/test/core/DummyApplicationSettingsTest.conf && Function ActivitySettingsTest will change in the file ~/.config/gcompris/gcompris-qt.conf</li>
<li class="remarkup-list-item">Change in the file ApplicationSettingsTest.cpp like this: <a href="https://paste.kde.org/ps9i5vfdg" class="remarkup-link" target="_blank" rel="noreferrer">https://paste.kde.org/ps9i5vfdg</a> Run the test Result: Now the result is reverse as expected i.e. Function ApplcationSettingsTest will reflect the change in the file: ~/.config/gcompris/gcompris-qt.conf && Function ActivitySettingsTest will change in the file:  build/test/core/DummyApplicationSettingsTest.conf
<br /><br />
Correct me if I am wrong...</li>
</ol></blockquote>

</div></div><br /><div><strong>REPOSITORY</strong><div><div>R2 GCompris</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D11034">https://phabricator.kde.org/D11034</a></div></div><br /><div><strong>To: </strong>himanshuvishwakarma, jjazeix, dmadaan, rudranilbasu, timotheegiet, GCompris<br /><strong>Cc: </strong>KDE Edu, GCompris, himanshuvishwakarma, harrymecwan, ganeshredcobra, nityanandkumar, echarruau, rahulyadav, narvaez, scagarwal, apol, timotheegiet, hkaelberer, jjazeix, bcoudoin<br /></div>