Exemple #1
0
	def __init__(self, rescanDelayMS = 250, port = 8989, handlers = [SerialHandler]):
		super(MainWindow, self).__init__()
		self._rescanDelayMS = rescanDelayMS
		self._port = port
		self._handlers = handlers

		self.selectDeviceLab = QtWidgets.QLabel(_("Select the device:"))
		self.selectDevice = QtWidgets.QComboBox()
		self.selectDevice.activated.connect(self.deviceChanged)

		self.deviceSelectionLay = QtWidgets.QVBoxLayout()
		self.deviceSelectionLay.addWidget(self.selectDeviceLab)
		self.deviceSelectionLay.addWidget(self.selectDevice)
		self.deviceSelectionLay.setAlignment(QtCore.Qt.AlignTop)

		self.WebUIUrlLab = QtWidgets.QLabel(_("WebUI:"))
		self.WebUIUrl = QtWidgets.QLabel()
		self.WebUIUrl.setText('<a href="http://*****:*****@ http://localhost:{0}</a>'.format(self._port))
		self.WebUIUrl.setStyleSheet("QLabel {font-size:32pt;}")
		self.WebUIUrl.setOpenExternalLinks(True)
		self.WebUIUrl.setTextFormat(QtCore.Qt.RichText)
		self.WebUIUrl.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
		
		self.WebUIUrlLay = QtWidgets.QVBoxLayout()
		self.WebUIUrlLay.addWidget(self.WebUIUrlLab)
		self.WebUIUrlLay.addWidget(self.WebUIUrl)
		self.WebUIUrlLay.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)

		self.progressLab = QtWidgets.QLabel(_("Current Value:"))
		self.progress = QtWidgets.QProgressBar()
		self.progress.setValue(0)

		self.progressLay = QtWidgets.QVBoxLayout()
		self.progressLay.addWidget(self.progressLab)
		self.progressLay.addWidget(self.progress)
		self.progressLay.setAlignment(QtCore.Qt.AlignBottom)

		self.mainLayout = QtWidgets.QVBoxLayout()
		self.mainLayout.addLayout(self.deviceSelectionLay)
		self.mainLayout.addLayout(self.WebUIUrlLay)
		self.mainLayout.addLayout(self.progressLay)

		self.setLayout(self.mainLayout)

		self.setWindowTitle(_("NorthernLight"))
		self.resize(300,300)

		self.wi = WebInterface(port = self._port)
		self.wi.start()
		
		self.activeHandler = None

		self._devices = []
		self.rescanDevices()
		self._rescanTimer = QtCore.QTimer(self)
		self._rescanTimer.timeout.connect(self.rescanDevices)
		self._rescanTimer.start(self._rescanDelayMS)
Exemple #2
0
def testcase1():
    #step 1: start web and go to link anotepad.com
    try:
        tc1 = WebInterface()
        tc1.start_browser(link)
        #verify 1: verify login button is exist:
        if tc1.check_element_exist(ObjectPage.login_span()):
            print("Passed: Login span is existed")
        else:
            print("Failed: Login span does not exist")
    except:
        print("Failed: Something wrong, please check this function")
    finally:
        tc1.close_browser()
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals

import threading

from WebInterface import WebInterface
from SlideshowController import SlideshowController
from Pi3DDisplayer import Displayer
#from DummyDisplayer import Displayer

controller = SlideshowController();
displayer = Displayer(controller.showQueue);
web = WebInterface(controller.configQueue);

# Run the controller, which controls the slide loading and transition timing.
controllerThread = threading.Thread(target=controller.run)
controllerThread.start();

# Run the web interface
#webThread = threading.Thread(target=web.run)
#webThread.daemon = True
#webThread.start();

# Finally, in this thread run the display loop.
displayer.run();
Exemple #4
0
class MainWindow(QtWidgets.QWidget):

	def __init__(self, rescanDelayMS = 250, port = 8989, handlers = [SerialHandler]):
		super(MainWindow, self).__init__()
		self._rescanDelayMS = rescanDelayMS
		self._port = port
		self._handlers = handlers

		self.selectDeviceLab = QtWidgets.QLabel(_("Select the device:"))
		self.selectDevice = QtWidgets.QComboBox()
		self.selectDevice.activated.connect(self.deviceChanged)

		self.deviceSelectionLay = QtWidgets.QVBoxLayout()
		self.deviceSelectionLay.addWidget(self.selectDeviceLab)
		self.deviceSelectionLay.addWidget(self.selectDevice)
		self.deviceSelectionLay.setAlignment(QtCore.Qt.AlignTop)

		self.WebUIUrlLab = QtWidgets.QLabel(_("WebUI:"))
		self.WebUIUrl = QtWidgets.QLabel()
		self.WebUIUrl.setText('<a href="http://*****:*****@ http://localhost:{0}</a>'.format(self._port))
		self.WebUIUrl.setStyleSheet("QLabel {font-size:32pt;}")
		self.WebUIUrl.setOpenExternalLinks(True)
		self.WebUIUrl.setTextFormat(QtCore.Qt.RichText)
		self.WebUIUrl.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
		
		self.WebUIUrlLay = QtWidgets.QVBoxLayout()
		self.WebUIUrlLay.addWidget(self.WebUIUrlLab)
		self.WebUIUrlLay.addWidget(self.WebUIUrl)
		self.WebUIUrlLay.setAlignment(QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)

		self.progressLab = QtWidgets.QLabel(_("Current Value:"))
		self.progress = QtWidgets.QProgressBar()
		self.progress.setValue(0)

		self.progressLay = QtWidgets.QVBoxLayout()
		self.progressLay.addWidget(self.progressLab)
		self.progressLay.addWidget(self.progress)
		self.progressLay.setAlignment(QtCore.Qt.AlignBottom)

		self.mainLayout = QtWidgets.QVBoxLayout()
		self.mainLayout.addLayout(self.deviceSelectionLay)
		self.mainLayout.addLayout(self.WebUIUrlLay)
		self.mainLayout.addLayout(self.progressLay)

		self.setLayout(self.mainLayout)

		self.setWindowTitle(_("NorthernLight"))
		self.resize(300,300)

		self.wi = WebInterface(port = self._port)
		self.wi.start()
		
		self.activeHandler = None

		self._devices = []
		self.rescanDevices()
		self._rescanTimer = QtCore.QTimer(self)
		self._rescanTimer.timeout.connect(self.rescanDevices)
		self._rescanTimer.start(self._rescanDelayMS)

	def updateValue(self, value):
		self.wi.updateValue(value)
		self.progress.setValue(0 if value < 0 else value*100)

	def updateDeviceStatus(self, value):
		self.wi.updateDeviceStatus(value)
		if value:
			self._rescanTimer.stop()
			for ix in range(self.selectDevice.count()):
				deviceIndex = self.selectDevice.itemData(ix)
				if deviceIndex is not None:
					currentDevice = self._devices[deviceIndex].getConnectedDevice()
					if currentDevice is not None and currentDevice == self.activeHandler.getConnectedDevice():
						self.selectDevice.setCurrentIndex(ix)
		else:
			self.updateValue(-1)
			self._rescanTimer.start(self._rescanDelayMS)

	def rescanDevices(self):
		self._devices = []
		self.selectDevice.clear()
		
		for handler in self._handlers:
			self._devices += handler.listDevices()

		if len(self._devices) == 0:
			self.selectDevice.addItem(_("Device Not found."), None)
			self.selectDevice.setDisabled(True)
		else:
			self.selectDevice.addItem(_("Select a device."), None)
			for index, device in zip(range(len(self._devices)),self._devices):
				self.selectDevice.addItem(str(device.deviceName), index)
			self.selectDevice.setDisabled(False)

	def closeEvent(self, event):
		if self.activeHandler.isRunning:
			self.activeHandler.stop()
			self.activeHandler.wait(5)
			
		if self.wi.isRunning:
			self.wi.stopTornado()
			self.wi.wait(5)

	def deviceChanged(self, event = None):
		if self.activeHandler is not None:
			self.activeHandler.stop()
			self.activeHandler.wait(5)

		deviceIndex = self.selectDevice.currentData()
		if deviceIndex is not None:
			self.activeHandler = self._devices[deviceIndex]
			self.activeHandler.value.connect(self.updateValue)
			self.activeHandler.connectionState.connect(self.updateDeviceStatus)
			self.activeHandler.start()
Exemple #5
0
def testcase3():
    try:
        tc3 = WebInterface()
        tc3.start_browser(link)
        # verify 1: verify login button is exist:
        if tc3.check_element_exist(ObjectPage.login_span()):
            print("Passed: Login span is existed")
        else:
            print("Failed: Login span does not exist")
        # step 2: click on login span:
        tc3.click_on_xpath(ObjectPage.login_span())
        # step 2: verify all information is displays after click login
        if tc3.check_element_exist(ObjectPage.login_password()):
            print("Passed: Login span is existed")
        else:
            print("Failed: Element does not exist")
        if tc3.check_element_exist(ObjectPage.login_email()):
            print("Passed: Element is existed")
        else:
            print("Failed: Login span does not exist")
        if tc3.check_element_exist(ObjectPage.login_button()):
            print("Passed: Element is existed")
        else:
            print("Failed: Element does not exist")
        if tc3.check_element_exist(ObjectPage.remember_check()):
            print("Passed: Element is existed")
        else:
            print("Failed: Element does not exist")
        if tc3.check_element_exist(ObjectPage.forgot_password_button()):
            print("Passed: Element is existed")
        else:
            print("Failed: Element does not exist")

        #step 3: input all information
        tc3.send_key_on_element(ObjectPage.login_email(),loginEmail)
        tc3.send_key_on_element(ObjectPage.login_password(),loginPassword)
        tc3.click_on_xpath(ObjectPage.login_button())

        #Verify 3: Verify can login in this page (notepad login failed)
        if tc3.check_element_exist(ObjectPage.verify_login_success()):
            print("Passed: Element is existed")
        else:
            print("Failed: Element does not exist")
    except:
        print("Failed: Something wrong, please check this function")
    finally:
        tc3.close_browser()
Exemple #6
0
def testcase2():
    try:
        tc2 = WebInterface()
        tc2.start_browser(link)
        # verify 1: verify login button is exist:
        if tc2.check_element_exist(ObjectPage.login_span()):
            print("Passed: Login span is existed")
        else:
            print("Failed: Login span does not exist")
        # step 2: click on login span:
        tc2.click_on_xpath(ObjectPage.login_span())
        # step 2: verify all information is displays after click login
        if tc2.check_element_exist(ObjectPage.login_password()):
            print("Passed: Login span is existed")
        else:
            print("Failed: Element does not exist")
        if tc2.check_element_exist(ObjectPage.login_email()):
            print("Passed: Element is existed")
        else:
            print("Failed: Login span does not exist")
        if tc2.check_element_exist(ObjectPage.login_button()):
            print("Passed: Element is existed")
        else:
            print("Failed: Element does not exist")
        if tc2.check_element_exist(ObjectPage.remember_check()):
            print("Passed: Element is existed")
        else:
            print("Failed: Element does not exist")
        if tc2.check_element_exist(ObjectPage.forgot_password_button()):
            print("Passed: Element is existed")
        else:
            print("Failed: Element does not exist")
    except:
        print("Failed: Something wrong, please check this function")
    finally:
        tc2.close_browser()