예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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
예제 #4
0
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
예제 #5
0
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
예제 #6
0
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_()
예제 #7
0
    # Start..
    app = QtWidgets.QApplication(sys.argv)

    # This keeps Qt from closing everything if a message box is displayed
    # before HAL's main window is shown.
    app.setQuitOnLastWindowClosed(False)

    # Splash Screen.
    pixmap = QtGui.QPixmap("splash.png")
    splash = QtWidgets.QSplashScreen(pixmap)
    splash.show()
    app.processEvents()

    # Load configuration.
    config = params.config(args.config)

    # Start logger.
    hdebug.startLogging(config.get("directory") + "logs/", "hal4000")

    # Setup HAL and all of the modules.
    hal = HalCore(config=config, parameters_file_name=args.default_xml)

    # Hide splash screen and start.
    splash.hide()

    app.exec_()

#
# The MIT License
#
예제 #8
0
    
    # Start..
    app = QtWidgets.QApplication(sys.argv)

    # This keeps Qt from closing everything if a message box is displayed
    # before HAL's main window is shown.
    app.setQuitOnLastWindowClosed(False)

    # Splash Screen.
    pixmap = QtGui.QPixmap("splash.png")
    splash = QtWidgets.QSplashScreen(pixmap)
    splash.show()
    app.processEvents()

    # Load configuration.
    config = params.config(args.config)

    # Start logger.
    hdebug.startLogging(config.get("directory") + "logs/", "hal4000")
    
    # Setup HAL and all of the modules.
    hal = HalCore(config = config,
                  parameters_file_name = args.default_xml)

    # Hide splash screen and start.
    splash.hide()

    # Configure ctrl-c handling.
    signal.signal(signal.SIGINT, ctrlCHandler)
    
    app.exec_()
예제 #9
0
        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