# test_page.tavern.yaml
---
test_name: Obj Standard Properties

includes:
  - !include config.yaml

paho-mqtt:
  client:
    transport: tcp
    client_id: tavern-tester
  connect:
    host: "{host}"
    port: !int "{port:d}"
    timeout: 3
  auth:
    username: "{username}"
    password: "{password}"

marks:
  - parametrize:
      key: obj
      vals:
        - btnmatrix
        - cpicker
        - table
        - tabview
        - chart
        - gauge
        - btn
        - label
        - slider
        - checkbox
        - switch
        - bar
        - arc
        # - led # has a shadow bug
        - obj
        - linemeter
        - dropdown
        - calendar
        - spinner
        - roller
  - parametrize:
      key:
        - hidden
        - hidden_inv
        - x
        - y
        - w
        - h
        - radius
        - opacity
        - str1
        - str2
      vals:
        - [1, 0, 120, 121, 122, 123, 0, 255, "I'm sorry.", "louie"]
        - [1, 0, -10, -10, 256, 257, 1, 64, "louie", " The cat stretched."]
        - [
            0,
            1,
            1024,
            1025,
            1026,
            1027,
            5,
            0,
            "The pipe began to rust while new.",
            "",
          ]
        - [
            0,
            1,
            80,
            81,
            82,
            83,
            32535,
            192,
            "",
            " Oak is strong and also gives shade.",
          ]

stages:
  - name: Page 1
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "page 1"
    mqtt_response:
      topic: hasp/{plate}/state/page
      payload: "1"
      timeout: 1
    delay_after: 0

  - name: Clear page
    mqtt_publish:
      topic: hasp/{plate}/command/clearpage
      payload: ""
    delay_after: 0.2

  - name: Create object
    mqtt_publish:
      topic: hasp/{plate}/command/jsonl
      json:
        obj: "{obj}"
        id: 1
        x: 128
        y: 128
    delay_after: 0

  - name: Test y
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p1b1.y={y}","p1b1.y"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        y: !int "{y:d}"
      timeout: 1

  - name: Test x
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p1b1.x={x}","p1b1.x"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        x: !int "{x:d}"
      timeout: 1

  - name: Test w
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p1b1.w={w}","p1b1.w"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        w: !int "{w:d}"
      timeout: 1

  - name: Test h
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p1b1.h={h}","p1b1.h"]'
    delay_after: 0
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        h: !int "{h:d}"
      timeout: 1

  - name: Test enabled
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p1b1.enabled={hidden}","p1b1.enabled"]'
    delay_after: 0
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        enabled: !int "{hidden:d}"
      timeout: 1

  - name: Set vis
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.vis={hidden}"
    delay_after: 0
  - name: Get hidden
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.hidden"
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        hidden: !int "{hidden_inv:d}"
      timeout: 1
  - name: Get vis
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.vis"
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        vis: !int "{hidden:d}"
      timeout: 1

  - name: Set hidden
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.hidden={hidden}"
    delay_after: 0
  - name: Get hidden
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.hidden"
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        hidden: !int "{hidden:d}"
      timeout: 1

  - name: Get vis
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.vis"
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        vis: !int "{hidden_inv:d}"
      timeout: 1

  - name: Test opacity
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p1b1.opacity={opacity}","p1b1.opacity"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        opacity: !int "{opacity:d}"
      timeout: 1

  - name: Test radius
    mqtt_publish:
      topic: hasp/{plate}/command/json
      payload: '["p1b1.radius={radius}","p1b1.radius"]'
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        radius: !int "{radius:d}"
      timeout: 1

  - name: Set value_str
    mqtt_publish:
      topic: "hasp/{plate}/command/p1b1.value_str"
      payload: "{str1}{str2}"
    delay_after: 0.05
  - name: Get value_str
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.value_str"
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        value_str: "{str1}{str2}"
      timeout: 1

  - name: Get obj type
    mqtt_publish:
      topic: hasp/{plate}/command
      payload: "p1b1.obj"
    mqtt_response:
      topic: hasp/{plate}/state/p1b1
      json:
        obj: "{obj}"
      timeout: 1
