1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Guillaume Boulant (EDF)
22 # This script can be used to test the event listener. Note that the
23 # event listener is a CORBA object created inside the XMED GUI and
24 # that it could be reached if and only if the XMED GUI is loaded
27 # Then two tests are defined:
28 # - First you can try to import and use this script in the python
29 # console while the XMED GUI is NOT loaded. Then you will check that
30 # the script detects that the event listener is not available.
31 # - Second you can try to import this script AFTER having load the
32 # XMED GUI. Then the test will be completed.
36 xmed.connectEventListener()
38 if xmed.eventListener is None:
39 raise RuntimeError("The test must stop because the event listener is not defined")
43 # We can first try to retrieve the IOR using the data manager (just
44 # for internal test because it's not required in the use cases)
45 print xmed.dataManager.getEventListenerIOR()
46 print xmed.dataManager.getEventListenerIOR()
47 print xmed.dataManager.getEventListenerIOR()
48 # Make it several time to check the memory releases.
50 # We can then test the standard use case of the event listener
51 fieldHandler = MEDOP.FieldHandler(id = 0,
52 fieldname = "testfield",
53 meshname = "testmesh",
57 source = "test//:test_medEventListener.py")
59 medEvent = MEDOP.MedEvent(type = MEDOP.EVENT_UPDATE_FIELD,
60 fieldid = fieldHandler.id)
65 xmed.eventListener.processMedEvent(medEvent)
66 print "Test completed"