File: test_undo_redo.py

package info (click to toggle)
cambalache 1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,212 kB
  • sloc: python: 19,742; xml: 13,309; sql: 422; makefile: 212; ansic: 158; sh: 11
file content (37 lines) | stat: -rwxr-xr-x 837 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
36
37
#!/usr/bin/pytest

"""
Test Undo/Redo API
"""
import os

from cambalache import CmbProject


def undo_test(target_tk, filename, name):
    path = os.path.join(os.path.dirname(__file__), target_tk, filename)

    project = CmbProject(target_tk=target_tk)

    ui, msgs, detail_msg = project.import_file(path)

    for i in range(0, 4):
        obj = project.get_object_by_name(ui.ui_id, name)
        assert obj is not None and obj.name == name

        project.remove_object(obj)

        assert project.get_object_by_name(ui.ui_id, name) is None

        project.undo()

        obj = project.get_object_by_name(ui.ui_id, name)
        assert obj is not None and obj.name == name


def test_gtk3_undo():
    undo_test("gtk+-3.0", "dialog.ui", "dialog")


def test_gtk4_undo():
    undo_test("gtk-4.0", "liststore.ui", "liststore_test")