FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
plugdata/Tests/DialogCoverageTest.h at develop · plugdata-team/plugdata · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
plugdata-team
/
plugdata
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
104
Star
2.3k
Code
Issues
237
Pull requests
2
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
plugdata
/
Tests
/
DialogCoverageTest.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
126 lines (105 loc) · 4.33 KB
Breadcrumbs
plugdata
/
Tests
/
DialogCoverageTest.h
Copy path
File metadata and controls
126 lines (105 loc) · 4.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
include
"
Dialogs/Dialogs.h
"
#
include
"
Dialogs/AboutPanel.h
"
//
Opens, paints and closes every dialog that can be shown without network
//
access or native OS windows.
//
//
The Dialogs/ folder is almost entirely unreachable from the other tests
//
(helpfiles and canvas edits never open dialogs), so each dialog is shown
//
here explicitly: all six settings panels (audio, MIDI, theme, paths, key
//
mappings, advanced - which also run the bulk of PropertiesPanel),
//
about, object browser, object reference, Heavy export, save prompt,
//
multi-choice prompt, and the popup menus (main menu, add-object menu,
//
canvas right-click menu).
//
//
Each dialog gets a tick to lay itself out, is force-painted via
//
createComponentSnapshot() so paint() coverage doesn't depend on vblank
//
timing, and is then closed through the same openedDialog pointer the real
//
UI uses. Deken and the patch store are deliberately skipped: they fetch
//
from the network on open, which would make the suite flaky offline.
class
DialogCoverageTest
:
public
PlugDataUnitTest
{
public:
DialogCoverageTest
(PluginEditor* editor) : PlugDataUnitTest(editor,
"
Dialog Coverage Test
"
)
{
}
private:
void
perform
()
override
{
//
An open canvas, so canvas-dependent menus have something to target
cnv = editor->
getTabComponent
().
newPatch
();
steps.
clear
();
//
All settings panels: 0=audio, 1=MIDI, 2=theme, 3=paths, 4=key mappings, 5=advanced
for
(
int
panel =
0
; panel <
6
; panel++) {
steps.
add
([
this
, panel] {
beginTest
(
"
Settings panel
"
+
String
(panel));
Dialogs::showSettingsDialog
(editor, panel);
});
}
steps.
add
([
this
] {
beginTest
(
"
About panel
"
);
auto
* dialog =
new
Dialog
(&editor->
openedDialog
, editor,
360
,
490
,
true
);
dialog->
setViewedComponent
(
new
AboutPanel
());
editor->
openedDialog
.
reset
(dialog);
});
steps.
add
([
this
] {
beginTest
(
"
Object browser
"
);
Dialogs::showObjectBrowserDialog
(&editor->
openedDialog
, editor);
});
steps.
add
([
this
] {
beginTest
(
"
Object reference
"
);
Dialogs::showObjectReferenceDialog
(&editor->
openedDialog
, editor,
"
osc~
"
);
});
steps.
add
([
this
] {
beginTest
(
"
Heavy export dialog
"
);
Dialogs::showHeavyExportDialog
(&editor->
openedDialog
, editor);
});
steps.
add
([
this
] {
beginTest
(
"
Ask-to-save dialog
"
);
Dialogs::showAskToSaveDialog
(&editor->
openedDialog
, editor,
"
test.pd
"
, [](
int
) { },
0
,
true
);
});
steps.
add
([
this
] {
beginTest
(
"
Multi-choice dialog
"
);
Dialogs::showMultiChoiceDialog
(&editor->
openedDialog
, editor,
"
Test question?
"
, [](
int
) { }, {
"
Yes
"
,
"
No
"
,
"
Maybe
"
});
});
steps.
add
([
this
] {
beginTest
(
"
Main menu
"
);
Dialogs::showMainMenu
(editor, editor);
});
steps.
add
([
this
] {
beginTest
(
"
Add-object menu
"
);
Dialogs::showObjectMenu
(editor, editor);
});
steps.
add
([
this
] {
beginTest
(
"
Canvas right-click menu
"
);
if
(cnv)
Dialogs::showCanvasRightClickMenu
(cnv, cnv, cnv->
getScreenBounds
().
getCentre
());
});
runNextStep
(
0
);
}
void
runNextStep
(
int
const
stepIndex)
{
if
(stepIndex >= steps.
size
()) {
auto
& tabbar = editor->
getTabComponent
();
while
(
auto
* c = tabbar.
getCurrentCanvas
())
tabbar.
closeTab
(c);
signalDone
(
true
);
return
;
}
steps[stepIndex]();
//
Give the dialog a tick to lay out and run any async setup, then
//
force a paint pass and close it again
Timer::callAfterDelay
(
100
, [
this
, stepIndex] {
if
(editor->
openedDialog
) {
editor->
openedDialog
->
createComponentSnapshot
(editor->
openedDialog
->
getLocalBounds
());
}
PopupMenu::dismissAllActiveMenus
();
ModalComponentManager::getInstance
()->
cancelAllModalComponents
();
editor->
openedDialog
.
reset
(
nullptr
);
Timer::callAfterDelay
(
50
, [
this
, stepIndex] {
runNextStep
(stepIndex +
1
);
});
});
}
HeapArray<std::function<
void
()>> steps;
Component::SafePointer<Canvas> cnv;
};
Back
|
FazBrowse Home
|
New Git URL