1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 1996-2016. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20-module(dummy1_h). 21 22%% Test event handler for gen_event_SUITE.erl 23 24-export([init/1, handle_event/2, handle_call/2, handle_info/2, 25 terminate/2, format_status/2]). 26 27init(make_error) -> 28 {error, my_error}; 29init({_, error}) -> % swap from non-existing handler. 30 non_existing; 31init({swap, {ok, OldState}}) -> 32 {ok, OldState}; 33init([Parent]) -> 34 {ok, Parent}. %% We will send special responses for every handled event. 35 36handle_event(delete_event, _Parent) -> 37 remove_handler; 38handle_event(do_crash, _State) -> 39 erlang:error({badmatch,4}); 40%%Inverse of dummy_h 41handle_event(hibernate, Parent) -> 42 {ok,Parent}; 43handle_event(wakeup, Parent) -> 44 {ok,Parent,hibernate}; 45handle_event(Event, Parent) -> 46 Parent ! {dummy1_h, Event}, 47 {ok, Parent}. 48 49handle_call(delete_call, _State) -> 50 {remove_handler, ok}; 51handle_call(_Query, State) -> 52 {ok, ok, State}. 53 54handle_info(delete_info, _Parent) -> 55 remove_handler; 56handle_info(do_crash, _State) -> 57 erlang:error({badmatch,4}); 58handle_info(gnurf, Parent) -> 59 {ok, Parent, hibernate}; 60handle_info(Info, Parent) -> 61 Parent ! {dummy1_h, Info}, 62 {ok, Parent}. 63 64terminate(return_hej, _State) -> 65 return_hej; 66terminate(remove_handler, Parent) -> 67 Parent ! {dummy1_h, removed}; 68terminate(_Reason, _State) -> 69 ok. 70 71format_status(_Opt, [_PDict, _State]) -> 72 "dummy1_h handler state". 73