File: z_05_muc3.t

package info (click to toggle)
libanyevent-xmpp-perl 0.52-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 896 kB
  • sloc: perl: 7,937; makefile: 12
file content (39 lines) | stat: -rw-r--r-- 891 bytes parent folder | download | duplicates (6)
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
#!perl

use strict;
no warnings;
use Test::More;
use AnyEvent::XMPP::TestClient;
use AnyEvent::XMPP::IM::Message;
use AnyEvent::XMPP::Util qw/bare_jid prep_bare_jid split_jid cmp_jid/;
use AnyEvent::XMPP::Ext::MUC;

my $cl =
   AnyEvent::XMPP::TestClient->new_or_exit (
      tests => 1, two_accounts => 1, muc_test => 1, finish_count => 1
   );
my $C = $cl->client;

my $newsubject = '';

$C->reg_cb (
   two_rooms_joined => sub {
      my ($C) = @_;

      $cl->{muc}->reg_cb (
         subject_change => sub {
            my ($muc, $room, $msg, $is_echo) = @_;
            return if $is_echo;
            return unless cmp_jid ($room->nick_jid, $cl->{room2}->nick_jid);
            $newsubject = $msg->any_subject;
            $cl->finish;
         }
      );

      $cl->{room}->change_subject ("TEST ABC");
   }
);

$cl->wait;

is ($newsubject, 'TEST ABC', "subject has been changed");