aboutsummaryrefslogtreecommitdiffstats
path: root/lib/reltool/test/reltool_manual_gui_SUITE.erl
blob: 1ebee9fae13afb1f7d363ec06a405cb11abb0532 (plain) (blame)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2012. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%

-module(reltool_manual_gui_SUITE).

-export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2,
	 init_per_suite/1, end_per_suite/1,
	 init_per_testcase/2, end_per_testcase/2]).

-compile(export_all).

-include_lib("common_test/include/ct.hrl").
-include("reltool_test_lib.hrl").

%% Initialization functions.
init_per_suite(Config) ->
    reltool_test_lib:wx_init_per_suite(Config).

end_per_suite(Config) ->
    reltool_test_lib:wx_end_per_suite(Config).

init_per_testcase(Func,Config) ->
    reltool_test_lib:init_per_testcase(Func,Config).
end_per_testcase(Func,Config) ->
    reltool_test_lib:end_per_testcase(Func,Config).

%% SUITE specification
suite() -> [{ct_hooks,[ts_install_cth]}].

all() ->
    [config, depgraphs].

groups() ->
    [].

init_per_group(_GroupName, Config) ->
    Config.

end_per_group(_GroupName, Config) ->
    Config.


%% The test cases

%% Semi-automatic walkthrough of the GUI
config(Config) ->
    DataDir = ?config(data_dir,Config),
    PrivDir = ?config(priv_dir,Config),
    {ok, SysPid} = ?msym({ok, _}, reltool:start([])),
    link(SysPid),

    SimpleConfigFile = create_simple_config(PrivDir),
    WarningConfigFile = create_warning_config(PrivDir,DataDir),

    break("there are no modules in the 'Included' and 'Excluded' columns, "
	  "and now warnings are displayed",
	  {"load configuration ~p",[SimpleConfigFile]}),
    break("kernel, stdlib and sasl are included and all other are excluded",
	  "undo"),
    break("we are back to default - no included and no excluded applications",
	  "undo again"),
    break("kernel, stdlib and sasl are included and all other are excluded",
	  {"load configuration ~p",
	   [WarningConfigFile]}),
    break("a warning is displayed in the warning list",
	  "undo"),
    break("no warning is displayed in the warning list",
	  "load same configuration again"),
    break("application a is added in the 'Included' column and "
	  "one warning is displayed",
	  "reset configuration"),
    break("we are back to default - no included and no excluded applications, "
	  "and no warnings",
	  "undo"),
    break("a, kernel, stdlib and sasl are included and all other are excluded. "
	  "One warning should now exist through the rest of this test case",
	  "double click the warning"),
    break("a popup window occurs displaying the warning text",
	  "close it with the 'Close' button"),
    break("it disappears",
	  "open it again"),
    break("the warning text can be marked, copied and pasted",
	  "close the popup with the close box on the top frame"),
    break("it disappears",
	  "select application a from 'Included' column and click red cross to "
	  "exclude it"),
    break("application a is moved to 'Excluded' column",
	  "select application tools from 'Excluded' column and click green V to "
	  "include it"),
    break("application tools is moved to 'Included' column",
	  "select application runtime_tools from 'Excluded' column and click "
	  "green V to include it"),
    break("application runtime_tools is moved to 'Included' column",
	  "undo"),

    ExplicitConfig = filename:join(PrivDir,"explicit.config"),
    break("application runtime_tools is moved back to 'Excluded' column",
	  {"save configuration as 'explicit' to ~p",[ExplicitConfig]}),
    ExpectedExplicitConfig =
	{sys,[{lib_dirs,[filename:join(DataDir,"faulty_app_file")]},
	      {incl_cond,exclude},
	      {app,a,[{incl_cond,exclude}]},
	      {app,kernel,[{incl_cond,include}]},
	      {app,sasl,[{incl_cond,include}]},
	      {app,stdlib,[{incl_cond,include}]},
	      {app,tools,[{incl_cond,include}]}]},
    check_config(ExpectedExplicitConfig,ExplicitConfig),

    break("The saved configuration file is checked and is ok.\n"
	  "Now go to the 'Libraries' tab and change the root directory to "
	  "some invalid directory."),
    break("an error dialog occurs saying that there is no lib dir",
	  {"add library directory ~p",
	   [filename:join(DataDir,"dependencies")]}),
    break("applications x, y and z are added to the 'Excluded' column in "
	  "'Applications' tab",
	  "go to the 'System settings' tab and set application inclusion policy "
	  "to 'derived'"),
    break("a is excluded, kernel, stdlib, sasl and tools are included and "
	  "x, y and z are available in the 'Applications' tab",
	  "undo"),
    break("all non included application are moved to the 'Excluded' column "
	  "and that 'Application inclusion policy' under 'System settings' "
	  "tab is set back to 'exclude'",
	  "undo again"),
    break("applications x, y and z are in the 'Available' column",
	  "open application x, go to the 'Application settings' tab and set "
	  "'Application inclusion policy' to 'Use application specific config' "
	  "and 'include'. Close the window"),
    break("application x is moved to the 'Included' column and z and y are moved "
	  "to the 'Derived' column in the system window",
	  "open application y"),
    break("modules y1, y2 and y3 are in the 'Derived' column",
	  "go to 'Application dependencies' tab"),
    break("application y is used by x, requires kernel and stdlib, and uses z",
	  "go to 'Module dependencies' tab"),
    break("y is used by x2 and x3, and uses z1",
	  "got to 'Application settings' tab and select "
	  "'Source selection policy' 'Use selected version'"),
    break("'Directories' frame becomes enabled (clickable)",
	  "select 'Module inclusion policy' 'Use application specific config' "
	  "and select 'app file + derived'"),
    break("module y3 is moved to the 'Available' column in the 'Modules' tab",
	  "open module y1"),
    break("module y1 is used by x2 and uses z1",
	  "go to the 'Code' tab and double click the line with call to z1:f()"),
    break("new tab is opened with module z1",
	  "find something"),
    break("it is found",
	  "goto some line"),
    break("the cursor is moved to that line",
	  "click the 'Back' button"),
    break("the cursor is moved back to the line of your previous 'find'",
	  "terminate the application window (but keep the module window)."),

    {ok,ServerPid} = reltool:get_server(SysPid),
    unlink(SysPid),
    break("the system window is still alive",
	  "terminate reltool by hitting 'Ctrl-q' when system window is active"),
    false = erlang:is_process_alive(SysPid),
    false = erlang:is_process_alive(ServerPid),

    break("Check that both module window and system window are terminated"),

    ok.


depgraphs(Config) ->
    PrivDir = ?config(priv_dir,Config),
    SimpleConfigFile = create_simple_config(PrivDir),
    {ok, SysPid} = ?msym({ok, _}, reltool:start([{config,SimpleConfigFile}])),
    link(SysPid),

    break("Open the application dependency graph and \n\n"
	  "*move the complete graph by left clicking somewhere over it and drag\n"
	  "*move one node left clicking the node and drag\n"
	  "*lock node to position by holding down shift while releasing\n"
	  "*select several nodes with ctrl and left mouse button\n"
	  "*lock/unlock selected nodes with suitable buttons\n"
	  "*freeze\n"
	  "*reset\n"
	  "*left slider: push nodes apart\n"
	  "*right slider: pull nodes together\n"
	  "*middle slider: adjust length of links\n"
	  "*select node and delete\n"),
    break("Open the module dependency graph and meditate over it... "),

    unlink(SysPid),
    break("Terminate reltool from the file menu in the system window"),
    false = erlang:is_process_alive(SysPid),

    break("Check that system window and graphs are terminated"),

    ok.




%%%-----------------------------------------------------------------
%%% Internal functions
break(CheckStr,DoStr) when is_list(CheckStr), is_list(DoStr) ->
    Str = io_lib:format("Check that ~s.~n~nThen ~s.",[CheckStr,DoStr]),
    break(Str);
break(Check,Do) ->
    CheckStr =
	case Check of
	    {CheckFormat,CheckArgs} -> io_lib:format(CheckFormat,CheckArgs);
	    _ -> Check
	end,
    DoStr =
	case Do of
	    {DoFormat,DoArgs} -> io_lib:format(DoFormat,DoArgs);
	    _ -> Do
	end,
    break(CheckStr,DoStr).

break(Str) ->
    Count =
	case get(count) of
	    undefined -> 1;
	    C -> C
	end,
    put(count,Count+1),
    test_server:break("Step " ++ integer_to_list(Count) ++ ":\n" ++ Str).

check_config(Expected,File) ->
    {ok,[Config]} = file:consult(File),
    ?m(Expected,Config).

create_simple_config(PrivDir) ->
    SimpleConfigFile = filename:join(PrivDir,"simple.config"),
    SimpleConfig = {sys,[{incl_cond,exclude},
			 {app,kernel,[{incl_cond,include}]},
			 {app,stdlib,[{incl_cond,include}]},
			 {app,sasl,[{incl_cond,include}]}]},
    ok=file:write_file(SimpleConfigFile,io_lib:format("~p.~n",[SimpleConfig])),
    SimpleConfigFile.

create_warning_config(PrivDir,DataDir) ->
    WarningConfigFile = filename:join(PrivDir,"warning.config"),
    FaultyAppFileDir = filename:join(DataDir,"faulty_app_file"),
    WarningConfig = {sys,[{lib_dirs,[FaultyAppFileDir]},
			  {incl_cond,exclude},
			  {app,kernel,[{incl_cond,include}]},
			  {app,sasl,[{incl_cond,include}]},
			  {app,stdlib,[{incl_cond,include}]},
			  {app,a,[{incl_cond,include}]}
			 ]},
    ok=file:write_file(WarningConfigFile,io_lib:format("~p.~n",[WarningConfig])),
    WarningConfigFile.