Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [swtbot-dev] Workaround for Native Dialogs

Hi, it's me again,

I before you start playing with the code, I better give you some
advice, so you don't run into the same frustrating surprises on your
first attempts.

My project layout:
Three SWT plugin projects take part in this test example:

MockFactory project: This is the project, where the
NativeDialogFactory and the DummyInputValidator reside.
Application project:   The application I create (i.e. what the user will get)
Test Project: the SWTBot test project

I exported the MockFactory project as a plugin. I first tried to
import the MockFactory project as a plugin into the Application
project. This however broke my PDE build (it did build, but the
application failed to start). So instead, I took plugin jar-file and
placed it into the application project.

The NativeDialogFactory is desinged as singleton with a "global
variable", the operation mode (remember, in test mode you set it to
TESTING). This works only of course, when there is really only one
NativeDialogFactory around. The application project must export the
mockfactory package to make the NativeDialogFactory visible from the
Test project.

Don't include the MockFactory jar directly into your Test project,
too. In this case, your test code will set the NativeDialogFactory to
test mode - but there seem to be two NativeDialogFactories: One lives
in the jar within the Application project, the other lives in the jar
within the Test project. When the code in each project calls it, its
Classloader will resolve to its own jar.

Hope this posting wasn't too confusing,

Jan Petranek


Back to the top