File: gsimpleactiongroup_test.go

package info (click to toggle)
golang-github-gotk3-gotk3 0.6.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,392 kB
  • sloc: ansic: 914; makefile: 4
file content (70 lines) | stat: -rw-r--r-- 1,589 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package glib

import (
	"testing"
)

func TestSimpleActionGroupNew(t *testing.T) {
	sag := SimpleActionGroupNew()
	if sag == nil {
		t.Error("SimpleActionGroupNew returned nil")
	}

	if sag.IActionGroup == nil {
		t.Error("Embedded IActionGroup is nil")
	}
	if sag.IActionMap == nil {
		t.Error("Embedded IActionGroup is nil")
	}
}

func TestSimpleActionGroup_AddAction_RemoveAction_HasAction(t *testing.T) {
	sag := SimpleActionGroupNew()
	if sag == nil {
		t.Error("SimpleActionGroup returned nil")
	}

	// Check before: empty
	hasAction := sag.HasAction("nope")
	if hasAction {
		t.Error("Action group contained unexpected action 'nope'")
	}
	hasAction = sag.HasAction("yepp")
	if hasAction {
		t.Error("Action group contained unexpected action 'yepp'")
	}

	// Add a new action
	act := SimpleActionNew("yepp", nil)
	if act == nil {
		t.Error("SimpleActionNew returned nil")
	}
	sag.AddAction(act)

	// Check that it exists
	hasAction = sag.HasAction("nope")
	if hasAction {
		t.Error("Action group contained unexpected action 'nope'")
	}
	hasAction = sag.HasAction("yepp")
	if !hasAction {
		t.Error("Action group did not contain action 'yepp' after adding it")
	}

	// Remove the action again
	sag.RemoveAction("yepp")

	// Check that it was removed
	hasAction = sag.HasAction("nope")
	if hasAction {
		t.Error("Action group contained unexpected action 'nope'")
	}
	hasAction = sag.HasAction("yepp")
	if hasAction {
		t.Error("Action group contained unexpected action 'yepp'")
	}

	// NoFail check: removing a non-existing action
	sag.RemoveAction("yepp")
	sag.RemoveAction("nope")
}