def __init__(self, **kwds): super().__init__(**kwds) fname = "256x512" self.test_actions = [testActions.LoadParameters(filename = test.halXmlFilePathAndName(fname + ".xml")), testActions.LoadParameters(filename = test.halXmlFilePathAndName(fname + ".xml")), ParamTest5Action(p_name = fname)]
def __init__(self, **kwds): super().__init__(**kwds) fname1 = "256x256" fname2 = "256x512" self.test_actions = [testActions.LoadParameters(filename = test.halXmlFilePathAndName(fname1 + ".xml")), testActions.LoadParameters(filename = test.halXmlFilePathAndName(fname2 + ".xml")), SetParametersAction1(name_or_index = fname1), SetParametersAction1(name_or_index = fname2)]
def __init__(self, **kwds): super().__init__(**kwds) fname = "256x512" self.test_actions = [ testActions.LoadParameters( filename=test.halXmlFilePathAndName(fname + ".xml")), testActions.LoadParameters( filename=test.halXmlFilePathAndName(fname + ".xml")), ParamTest5Action(p_name=fname) ]
def test_hal_film_4(qtbot, mock): """ Test filming without actually recording. """ # 'Fix' question boxes to always return yes. # # https://github.com/pytest-dev/pytest-qt/issues/18 # mock.patch.object(QtWidgets.QMessageBox, 'question', return_value = QtWidgets.QMessageBox.Yes) hdebug.startLogging(test.logDirectory(), "hal4000") config = params.config(test.halXmlFilePathAndName("none_classic_config.xml")) hal = hal4000.HalCore(config = config) # Get UI elements we need. mainWindow = hal.findChild(QtWidgets.QMainWindow, "MainWindow") saveMovieCheckBox = hal.findChild(QtWidgets.QCheckBox, "saveMovieCheckBox") recordButton = hal.findChild(QtWidgets.QPushButton, "recordButton") # Start HAL. qtbot.addWidget(hal) qtbot.waitForWindowShown(mainWindow) qtbot.wait(100) # Uncheck save movie and press record. qtbot.mouseClick(saveMovieCheckBox, QtCore.Qt.LeftButton) qtbot.mouseClick(recordButton, QtCore.Qt.LeftButton) # Wait a second for the film to complete, then exit. qtbot.wait(1000)
def test_hal_film_4(qtbot, mock): """ Test filming without actually recording. """ # 'Fix' question boxes to always return yes. # # https://github.com/pytest-dev/pytest-qt/issues/18 # mock.patch.object(QtWidgets.QMessageBox, 'question', return_value=QtWidgets.QMessageBox.Yes) hdebug.startLogging(test.logDirectory(), "hal4000") config = params.config( test.halXmlFilePathAndName("none_classic_config.xml")) hal = hal4000.HalCore(config=config) # Get UI elements we need. mainWindow = hal.findChild(QtWidgets.QMainWindow, "MainWindow") saveMovieCheckBox = hal.findChild(QtWidgets.QCheckBox, "saveMovieCheckBox") recordButton = hal.findChild(QtWidgets.QPushButton, "recordButton") # Start HAL. qtbot.addWidget(hal) qtbot.waitForWindowShown(mainWindow) qtbot.wait(100) # Uncheck save movie and press record. qtbot.mouseClick(saveMovieCheckBox, QtCore.Qt.LeftButton) qtbot.mouseClick(recordButton, QtCore.Qt.LeftButton) # Wait a second for the film to complete, then exit. qtbot.wait(1000)
def __init__(self, **kwds): super().__init__(**kwds) self.test_actions = [ testActions.LoadParameters( filename=test.halXmlFilePathAndName("256x512.xml")), ParamTest1Action(p_name=1) ]
def __init__(self, **kwds): super().__init__(**kwds) self.test_actions = [ SetProgressionAction1( filename=test.halXmlFilePathAndName("prog_test.power"), prog_type="file", test_mode=True) ]
def __init__(self, **kwds): super().__init__(**kwds) self.test_actions = [SetProgressionAction1(filename = test.halXmlFilePathAndName("prog_test.power"), prog_type = "file"), testActions.Timer(500), SetProgressionAction1(prog_type = "lockedout"), testActions.Timer(500), TakeMovieAction1(directory = test.dataDirectory(), length = 5, name = "movie_01"), testActions.Timer(500)]
def __init__(self, **kwds): super().__init__(**kwds) directory = test.dataDirectory() filename = "movie_01" p_name = "256x256" self.test_actions = [testActions.LoadParameters(filename = test.halXmlFilePathAndName(p_name + ".xml")), TakeMovieAction4(directory = directory, length = 50, name = filename, parameters = p_name, test_mode = True)]
def test_hal_error_2(qtbot): """ Test handling of an error in a HAL worker. """ hdebug.startLogging(test.logDirectory(), "hal4000") config = params.config(test.halXmlFilePathAndName("none_hal_error_2.xml")) hal = hal4000.HalCore(config=config, show_gui=False) qtbot.addWidget(hal) qtbot.wait(500) assert not hal.running
def test_hal_error_2(qtbot): """ Test handling of an error in a HAL worker. """ hdebug.startLogging(test.logDirectory(), "hal4000") config = params.config(test.halXmlFilePathAndName("none_hal_error_2.xml")) hal = hal4000.HalCore(config = config, show_gui = False) qtbot.addWidget(hal) qtbot.wait(500) assert not hal.running
def test_hal_sequencing_1(qtbot): """ Test module.processMessage() sequencing. """ hdebug.startLogging(test.logDirectory(), "hal4000") config = params.config(test.halXmlFilePathAndName("none_hal_sequencing_1.xml")) hal = hal4000.HalCore(config = config, show_gui = False) qtbot.addWidget(hal) qtbot.wait(2000) assert not hal.running
def __init__(self, **kwds): super().__init__(**kwds) directory = test.dataDirectory() filename = "movie_01" # Remove old movie (if any). fullname = os.path.join(directory, filename + ".dax") if os.path.exists(fullname): os.remove(fullname) p_name = "256x256" self.test_actions = [testActions.LoadParameters(filename = test.halXmlFilePathAndName(p_name + ".xml")), TakeMovieAction7(directory = directory, length = 5, name = filename, parameters = p_name)]
def __init__(self, **kwds): super().__init__(**kwds) directory = test.dataDirectory() filename = "movie_02" # Remove old movie (if any). fullname = os.path.join(directory, filename + ".dax") if os.path.exists(fullname): os.remove(fullname) self.test_actions = [testActions.SetDirectory(directory = directory), testActions.LoadParameters(filename = test.halXmlFilePathAndName("feed_examples.xml")), testActions.SetParameters(p_name = 0), testActions.Timer(timeout = 1000), testActions.Record(filename = filename), testActions.Timer(timeout = 2000)]
def halTest(config_xml = "", class_name = "Testing", test_module = "", show_gui = False): app = QtWidgets.QApplication(sys.argv) config = params.config(test.halXmlFilePathAndName(config_xml)) # Add the class that will actually do the testing. c_test = config.addSubSection("modules.testing") c_test.add("class_name", class_name) c_test.add("module_name", test_module) hdebug.startLogging(test.logDirectory(), "hal4000") hal = hal4000.HalCore(config = config, testing_mode = True, show_gui = show_gui) app.exec_()
def __init__(self, **kwds): super().__init__(**kwds) directory = test.dataDirectory() filenames = ["movie_01", "movie_02"] # Remove old movies (if any). for elt in filenames: fullname = os.path.join(directory, elt + ".dax") if os.path.exists(fullname): os.remove(fullname) self.test_actions = [testActions.SetDirectory(directory = directory), testActions.LoadParameters(filename = test.halXmlFilePathAndName("feed_test.xml")), testActions.SetParameters(p_name = 0), testActions.Timer(timeout = 200), testActions.Record(filename = filenames[0]), testActions.Timer(timeout = 200), testActions.LoadParameters(filename = os.path.join(test.dataDirectory(), filenames[0] + ".xml")), testActions.SetParameters(p_name = 0), testActions.Timer(timeout = 200), testActions.Record(filename = filenames[1]), testActions.Timer(timeout = 200)]
def __init__(self, **kwds): super().__init__(**kwds) directory = test.dataDirectory() self.reps = 1 # Initial setup. # # Lock focus. self.test_actions.append( tcpTests.SetFocusLockModeAction1(mode_name="Always On", locked=True)) # Load parameters. self.test_actions.append( testActions.LoadParameters( filename=test.halXmlFilePathAndName("256x256.xml"))) self.test_actions.append( testActions.LoadParameters( filename=test.halXmlFilePathAndName("256x512.xml"))) # Turn off live mode. self.test_actions.append(testActions.SetLiveMode(live_mode=False)) # Pause a second so that setup completes. self.test_actions.append(testActions.Timer(1000)) # Add loop parameters. for i in range(10): ## Position 0 # Move stage. self.test_actions.append(testActionsTCP.MoveStage(x=0.0, y=0.0)) # Check focus. self.test_actions.append( testActionsTCP.CheckFocusLock(focus_scan=False, num_focus_checks=30)) # Set parameters. self.test_actions.append( tcpTests.SetParametersAction1(name_or_index="256x256")) # Take Movie. self.test_actions.append( StandardDaveSequenceTakeMovieAction1(directory=directory, length=5, name="movie_01")) # Remove movie. self.test_actions.append( testActions.RemoveFile(directory=directory, name="movie_01.inf")) self.test_actions.append( testActions.RemoveFile(directory=directory, name="movie_01.dax")) ## Position 1 # Move stage. self.test_actions.append(testActionsTCP.MoveStage(x=10.0, y=0.0)) # Check focus. self.test_actions.append( testActionsTCP.CheckFocusLock(focus_scan=False, num_focus_checks=30)) # Set parameters. self.test_actions.append( tcpTests.SetParametersAction1(name_or_index="256x512")) # Take Movie. self.test_actions.append( StandardDaveSequenceTakeMovieAction2(directory=directory, length=5, name="movie_02")) # Remove movie. self.test_actions.append( testActions.RemoveFile(directory=directory, name="movie_02.inf")) self.test_actions.append( testActions.RemoveFile(directory=directory, name="movie_02.dax"))
def __init__(self, **kwds): super().__init__(**kwds) self.test_actions = [testActions.LoadParameters(filename = test.halXmlFilePathAndName("256x512.xml")), ParamTest1Action(p_name = 1)]
def __init__(self, **kwds): super().__init__(**kwds) self.test_actions = [SetProgressionAction1(filename = test.halXmlFilePathAndName("prog_test.power"), prog_type = "file", test_mode = True)]
self.config_xml = config_xml self.error_msg = "" self.process = None self.thread = None def run(self): cmd_line = ["python", "hal/halSteveTest.py", self.config_xml] def target(): try: self.process = subprocess.Popen(cmd_line) except: self.error_msg = traceback.format_exc() self.thread = threading.Thread(target=target) self.thread.start() time.sleep(1.0) def stop(self): self.process.terminate() print(self.error_msg) if (__name__ == "__main__"): app = QtWidgets.QApplication(sys.argv) config = params.config(test.halXmlFilePathAndName(sys.argv[1])) hdebug.startLogging(test.logDirectory(), "hal4000") hal = hal4000.HalCore(config=config, show_gui=True) app.exec_() app = None