Skip to main content

Testwizard for Smart TV testobjects

Project description

Testwizard - Smart-Tv

Python language support for testing Smart-Tv devices using testwizard

Usage

  • Import the testwizard.test and the testwizard.smart_tv packages
  • Get a session and use it to create a Smart TV testobject.
  • Use this object to execute commands.
  • You can use the session to add results that will be reported to the robot when the script finishes or set results that will be posted immediately.

Sample script

Python (smart-tv.py)

from sys import path
path.append("../packages/test")
path.append("../packages/testobjects/core")
path.append("../packages/testobjects/smartTv")
path.append("../packages/commands/core")
path.append("../packages/commands/audio")
path.append("../packages/commands/powerswitch")
path.append("../packages/commands/remotecontrol")
path.append("../packages/commands/video")
path.append("../packages/commands/camera")

from testwizard.test import TestWizard
from testwizard.test import ResultCodes
from testwizard.smart_tv import SmartTv

with TestWizard() as TW:
    session = TW.session

    print("-- Parameter usage ---")
    print("  Param1 = " + session.parameters["param1"])
    print("  Param2 = " + session.parameters["param2"])

    print("-- Session info ---")
    print("  scriptFilePath = " + session.info["scriptFilePath"])
    print("  scriptFileName = " + session.info["scriptFileName"])
    print("  storagePath = " + session.info["storagePath"])
    print("  tester = " + session.info["tester"])
    print("  environment.scriptsBasePath = " + session.info["environment"]["scriptsBasePath"])
    print("  environment.storageBasePath = " + session.info["environment"]["storageBasePath"])
    print("  environment.ocrEngine = " + session.info["environment"]["ocrEngine"])
    print("  environment.testWizardVersion = " + session.info["environment"]["testWizardVersion"])

    if session.info["session"] is not None:
        print("Script was started by the Manager:")
        print("  session.id = " + session.info["session"]["id"])
        print("  session.name = " + session.info["session"]["name"])
        print("  session.scriptIndex = " + session.info["session"]["scriptIndex"])
    else:
        print("Script was started from the IDE")

    print("-- Create Smart TV test object ---")
    smartTv = SmartTv(session, "SmartTv")

    print("-- Smart TV test object info ---")
    print("  id = " + smartTv.info.id)
    print("  name = " + smartTv.info.name)
    print("  category = " + smartTv.info.category)
    print("  device.serialNo = " + smartTv.info.device.serialNo)
    print("  device.hardwareVersion = " + smartTv.info.device.hardwareVersion)
    print("  device.softwareVersion = " + smartTv.info.device.softwareVersion)
    print("  device.description = " + smartTv.info.device.description)
    print("  device.vendor.name = " + smartTv.info.device.vendor.name)
    print("  device.vendor.modelName = " + smartTv.info.device.vendor.modelName)
    print("  device.vendor.serialNo = " + smartTv.info.device.vendor.serialNo)

    print("-- Commands ---")

    basePath = session.info["environment"]["scriptsBasePath"]

    print("smartTV: cameraInitializeNetwork")
    result = smartTv.cameraInitializeNetwork()
    print(result.message)
    if result.success is False:
        print("Fail")
        session.addFail(result.message)

    snapShotFilePath = basePath + "smart-tv-py-test.jpg"

    print("smartTV: cameraSnapShot")
    result = smartTv.cameraSnapShot(snapShotFilePath)
    print(result.message)
    if result.success is False:
        print("Fail")
        session.addFail(result.message)

    motionX = 347
    motionY = 2
    motionWidth = 64
    motionHeight = 30
    motionDuration = 5
    motionDistanceThreshold = 10

    print("smartTV: cameraDetectMotion with motion - custom distanceThreshold")
    result = smartTv.cameraDetectMotion(motionX, motionY, motionWidth, motionHeight, motionDuration, motionDistanceThreshold)
    print(result.message)
    if result.success is False or not result.hasMotion:
        print("Fail")
        session.addFail(result.message)

    print("smartTV: cameraDetectMotion with motion - default distanceThreshold")
    result = smartTv.cameraDetectMotion(motionX, motionY, motionWidth, motionHeight, motionDuration)
    print(result.message)
    if result.success is False or result.hasMotion:
        print("Fail")
        session.addFail(result.message)

    print("smartTV: cameraDetectMotion with no motion - custom distanceThreshold")
    result = smartTv.cameraDetectMotion(motionX + 64, motionY, motionWidth, motionHeight, motionDuration, motionDistanceThreshold)
    print(result.message)
    if result.success is False or result.hasMotion:
        print("Fail")
        session.addFail(result.message)

    matchingReference = basePath + "Mibox_Home.bmp"
    nonMatchingReference = basePath + "Mibox_NotHome.bmp"
    roiX = 146
    roiY = 257
    roiWidth = 150
    roiHeight = 145
    sampleMatchDuration = 5
    sampleMatchDistanceThreshold = 21

    print("smartTV: cameraWaitForSampleNoMatch with no match - custom distanceThreshold")
    result = smartTv.loadReferenceBitmap(nonMatchingReference)
    print(result.message)
    if result.success is False:
        print("Fail")
        session.addFail(result.message)
    result = smartTv.cameraWaitForSampleNoMatch(roiX, roiY, roiWidth, roiHeight, sampleMatchDuration, sampleMatchDistanceThreshold)
    print(result.message)
    if result.success is False or result.hasMatch is True:
        print("Fail")
        session.addFail(result.message)

    print("smartTV: cameraWaitForSample with match - default distanceThreshold")
    result = smartTv.loadReferenceBitmap(matchingReference)
    print(result.message)
    if result.success is False:
        print("Fail")
        session.addFail(result.message)
    result = smartTv.cameraWaitForSample(roiX, roiY, roiWidth, roiHeight, sampleMatchDuration)
    print(result.message)
    if result.success is False or result.hasMatch is False:
        print("Fail")
        session.addFail(result.message)

    matchingPattern = basePath + "Mibox_Home_Pattern.bmp"
    patternX = 180
    patternY = 96
    patternWidth = 81
    patternHeight = 81
    patternMatchDuration = 5
    patternMatchDistanceThreshold = 21

    print("smartTV: cameraWaitForPattern with match - custom distanceThreshold")
    result = smartTv.cameraWaitForPattern(matchingPattern, patternX, patternY, patternWidth, patternHeight, patternMatchDuration, patternMatchDistanceThreshold)
    print(result.message)
    if result.success is False or result.hasMatch is False:
        print("Fail")
        session.addFail(result.message)

    nonMatchingPattern = basePath + "Mibox_NotHome_Pattern.bmp"

    print("smartTV: cameraWaitForPatternNoMatch with no match - default distanceThreshold")
    result = smartTv.cameraWaitForPatternNoMatch(nonMatchingPattern, patternX, patternY, patternWidth, patternHeight, patternMatchDuration)
    print(result.message)
    if result.success is False or result.hasMatch is True:
        print("Fail")
        session.addFail(result.message)

    if not (session.hasFails or session.hasErrors):
        session.setResult(ResultCodes.PASS, "Test was successful")

sidecar file (smart-tv.json)

{
    "tester": "John Smith",
    "parameters": [
        { "name": "param1", "value": "value1"},
        { "name": "param2", "value": "value2"}
    ],
    "resources": [
        { "category": "SMART_TV", "name": "SmartTv", "id": "TV Model 1"}
    ],
    "outputFolder": "c:\\temp"
}

License

Testwizard licensing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

testwizard.smart-tv-3.4.4b1055.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

testwizard.smart_tv-3.4.4b1055-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file testwizard.smart-tv-3.4.4b1055.tar.gz.

File metadata

  • Download URL: testwizard.smart-tv-3.4.4b1055.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for testwizard.smart-tv-3.4.4b1055.tar.gz
Algorithm Hash digest
SHA256 d4384d0ffacee8bba7d5c4099b2c1dcfcffc2f58f0e3affecb4d74a622d12d99
MD5 8061e6b26c9607a1220f799ca8b5119f
BLAKE2b-256 4818855b279d68f570a41b462417069c56b9389a87656b7397c0b7523bc93c1b

See more details on using hashes here.

File details

Details for the file testwizard.smart_tv-3.4.4b1055-py3-none-any.whl.

File metadata

  • Download URL: testwizard.smart_tv-3.4.4b1055-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

File hashes

Hashes for testwizard.smart_tv-3.4.4b1055-py3-none-any.whl
Algorithm Hash digest
SHA256 fe3bca5dabacf0a59a42c47dbdca701b604452baa8491bfa602c7c460f650d1d
MD5 badd6b263d0ee257f7207e96362063df
BLAKE2b-256 57c71c8350cb39ed1c995c86dde1401f7ee4ff9263c98b6ffed5d18ec5d36e86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page