aboutsummaryrefslogtreecommitdiff
path: root/tools/mnotificationstresstest
blob: 005e6d05906e1e86addf806a3821ad55dbc735bc (plain)
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
#!/usr/bin/perl -w

$INTERVAL = ($#ARGV == 0) ? $ARGV[0] : 10;

my @EVENTTYPES = ( "press", "release", "cancel", "error" );
my @groupIDs;

while(1) {
    my $r = int(rand(2));
    my $group;

    if($#groupIDs < 0 || $r == 0) {
        $group=""
    } else {
        $group="-i ".$groupIDs[int(rand($#groupIDs + 1))];
    }

    $r = int(rand(3));
    $e = int(rand($#EVENTTYPES + 1));

    if($r == 0) {
        system("mnotificationtool -a add $group $EVENTTYPES[$e] '' 'Application Event' Icon-camera");
        $n = $? >> 8;
        print "notification $n created $group\n"
    } elsif($r == 1) {
        system("mnotificationtool -a add $group $EVENTTYPES[$e] '' 'System Event' Icon-camera");
        $n = $? >> 8;
        print "notification $n created $group\n"
    } elsif($r == 2) {
        system("mnotificationtool -a add -g $EVENTTYPES[$e] '' 'Group' Icon-camera");
        $groupID=$? >> 8;
        push @groupIDs, $groupID;
        print "group $groupID created\n";
   }

   sleep($INTERVAL);
}