D11034: CoreApplicationSettingsTest

Johnny Jazeix noreply at phabricator.kde.org
Sat Mar 24 18:41:19 UTC 2018


jjazeix closed this revision.
jjazeix added a comment.


  In D11034#232060 <https://phabricator.kde.org/D11034#232060>, @himanshuvishwakarma wrote:
  
  > In D11034#231907 <https://phabricator.kde.org/D11034#231907>, @jjazeix wrote:
  >
  > > 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?
  > >  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).
  > >
  > > 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
  >
  >
  > Hi,
  >
  > 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.
  
  
  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.
  I added a getInstance in the mock to create the m_instance as a Mock.
  
  > 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( )
  > 
  > I have checked it by this methods
  > 
  > 1. Change in the file ApplicationSettingsTest.cpp like this: https://paste.kde.org/pkfzgqgtx 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
  > 2. Change in the file ApplicationSettingsTest.cpp like this: https://paste.kde.org/ps9i5vfdg 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
  > 
  >   Correct me if I am wrong...

REPOSITORY
  R2 GCompris

REVISION DETAIL
  https://phabricator.kde.org/D11034

To: himanshuvishwakarma, jjazeix, dmadaan, rudranilbasu, timotheegiet, #gcompris
Cc: #kde_edu, #gcompris, himanshuvishwakarma, harrymecwan, ganeshredcobra, nityanandkumar, echarruau, rahulyadav, narvaez, scagarwal, apol, timotheegiet, hkaelberer, jjazeix, bcoudoin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20180324/82dd2a43/attachment.html>


More information about the kde-edu mailing list