File: test_globject.py

package info (click to toggle)
python-vispy 0.15.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,868 kB
  • sloc: python: 59,799; javascript: 6,800; makefile: 69; sh: 6
file content (35 lines) | stat: -rw-r--r-- 1,086 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright (c) 2014, Nicolas P. Rougier. All rights reserved.
# Distributed under the terms of the new BSD License.
# -----------------------------------------------------------------------------

from vispy.testing import run_tests_if_main
from vispy.gloo.globject import GLObject


def test_globject():
    """Test gl object uinique id and GLIR CREATE command"""
    objects = [GLObject() for i in range(10)]
    ids = [ob.id for ob in objects]

    # Verify that each id is unique (test should not care how)
    assert len(set(ids)) == len(objects)

    # Verify that glir commands have been created
    commands = []
    for ob in objects:
        commands.extend(ob._glir.clear())
    assert len(commands) == len(objects)
    for cmd in commands:
        assert cmd[0] == 'CREATE'

    # Delete
    ob = objects[-1]
    q = ob._glir  # get it now, because its gone after we delete it
    ob.delete()
    cmd = q.clear()[-1]
    assert cmd[0] == 'DELETE'


run_tests_if_main()