aboutsummaryrefslogtreecommitdiffstats
path: root/lib/et/test/et_wx_SUITE.erl
blob: b5f98f86160c892156436a86f5b90008a763011e (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
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2009-2011. 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(et_wx_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("et_test_lib.hrl").

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

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

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

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

all() -> 
    [start_all_windows].

groups() -> 
    [].

init_per_group(_GroupName, Config) ->
    Config.

end_per_group(_GroupName, Config) ->
    Config.


%% The test cases

%% Display all windows and see if something crashes
start_all_windows(TestInfo) when is_atom(TestInfo) ->
    et_test_lib:tc_info(TestInfo);
start_all_windows(_Config) ->
    process_flag(trap_exit, true),
    {ok, ViewerPid} = ?msym({ok, _}, et_viewer:start_link([])),
    CollectorPid = et_viewer:get_collector_pid(ViewerPid),      
    ?msym({ok, _}, et_collector:report_event(CollectorPid,
					     60,
					     some_from_actor,
					     some_to_actor,
					     some_label, 
					     "Some details")),
    timer:sleep(timer:seconds(1)),

    {ok, EventPid1} = ?msym({ok, _}, et_viewer:open_event(ViewerPid, 1)),
    {ok, EventPid2} = ?msym({ok, _}, et_viewer:open_event(ViewerPid, 1)),
    timer:sleep(timer:seconds(10)),

    ?msym(alive, process_state(ViewerPid)),
    ?msym(alive, process_state(CollectorPid)),
    ?msym(alive, process_state(EventPid1)),
    ?msym(alive, process_state(EventPid2)),

    ?m(ok, et_wx_contents_viewer:stop(EventPid1)),
    timer:sleep(timer:seconds(1)),

    ?msym(alive, process_state(ViewerPid)),
    ?msym(alive, process_state(CollectorPid)),
    ?msym(dead,  process_state(EventPid1)),
    ?msym(alive, process_state(EventPid2)),

    ?m(ok, et_viewer:stop(ViewerPid)),
    timer:sleep(timer:seconds(1)),

    ?msym(dead, process_state(ViewerPid)),
    ?msym(dead, process_state(CollectorPid)),
    ?msym(dead, process_state(EventPid1)),
    ?msym(dead, process_state(EventPid2)),

    ?m([], et_test_lib:flush()),

    ok.

process_state(Pid) ->
    case process_info(Pid, group_leader) of
	{group_leader, _} -> alive;
	undefined         -> dead
    end.