Trolltech Home | Qt-jambi-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-jambi-interest Archive, March 2007
JUnit tests and QT Jambi Plugins


Message 1 in thread

Hello,

I am writing some junit tests and I have a problem to get the qt jambi
plugins to be loaded.
Any attempt to load/write a jpeg in a test is a failure, but it works in the
application.

Can you explain how to proceed ?

Thanks,
Bruno

Message 2 in thread

Bruno Janvier wrote:
> Hello,
> 
> I am writing some junit tests and I have a problem to get the qt jambi 
> plugins to be loaded.
> Any attempt to load/write a jpeg in a test is a failure, but it works in 
> the application.
 >
> Can you explain how to proceed ?

Hi Bruno,

There shouldn't be any difference between running a normal application 
and running a test via junit. You have set your QT_PLUGIN_PATH to the 
right location both for the test and the app?

An alternative approach to setting the QT_PLUGIN_PATH is to hardcode the 
location in the running application, or test in this case, using 
QCoreApplication.addLibraryPath().

I hope this helps,
Gunnar


Message 3 in thread

Hi Gunnar,


> There shouldn't be any difference between running a normal
> application and running a test via junit.

ok, but there is one major difference. I never call in my test the
QApplication.exec() because I am testing only methods. Is it the problem ?
how to proceed then ? because calling it will just freeze the test until it
is exited which does not help.

> You have set your QT_PLUGIN_PATH to the
> right location both for the test and the app?
yes it is a global environment variable. Applications are able to use
plugins in a proper way...


On 3/12/07, Gunnar Sletta <gunnar@xxxxxxxxxxxxx> wrote:
>
> Bruno Janvier wrote:
> > Hello,
> >
> > I am writing some junit tests and I have a problem to get the qt jambi
> > plugins to be loaded.
> > Any attempt to load/write a jpeg in a test is a failure, but it works in
> > the application.
> >
> > Can you explain how to proceed ?
>
> Hi Bruno,
>
>
> An alternative approach to setting the QT_PLUGIN_PATH is to hardcode the
> location in the running application, or test in this case, using
> QCoreApplication.addLibraryPath().
>
> I hope this helps,
> Gunnar
>

Message 4 in thread

Bruno Janvier wrote:
> Hi Gunnar,
> 
> 
>  > There shouldn't be any difference between running a normal
>  > application and running a test via junit.
> 
> ok, but there is one major difference. I never call in my test the 
> QApplication.exec () because I am testing only methods. Is it the 
> problem ? how to proceed then ? because calling it will just freeze the 
> test until it is exited which does not help.

I think this is the problem... The one that propegates the 
QT_PLUGIN_PATH to the plugin loader is QCoreApplication. If you don't 
have a QCoreApplication or QApplication, your QT_PLUGIN_PATH will be 
igonred. You should be able to fix this simply initializing a 
QCoreApplication as part of your test setup phase.

I hope this solves the problem.

best regards,
Gunnar


Message 5 in thread

>
> I think this is the problem... The one that propegates the
> QT_PLUGIN_PATH to the plugin loader is QCoreApplication. If you don't
> have a QCoreApplication or QApplication, your QT_PLUGIN_PATH will be
> igonred. You should be able to fix this simply initializing a
> QCoreApplication as part of your test setup phase.
>
> I hope this solves the problem.



ok, works fine

thanks