| |
1 $MODULE_NAME = "Account Functions Test"; |
| |
2 |
| |
3 use Gaim; |
| |
4 |
| |
5 # All the information Gaim gets about our nifty plugin |
| |
6 %PLUGIN_INFO = ( |
| |
7 perl_api_version => 2, |
| |
8 name => " Perl: $MODULE_NAME", |
| |
9 version => "0.1", |
| |
10 summary => "Test plugin for the Perl interpreter.", |
| |
11 description => "Implements a set of test proccedures to ensure all functions that work in the C API still work in the Perl plugin interface. As XSUBs are added, this *should* be updated to test the changes. Furthermore, this will function as the tutorial perl plugin.", |
| |
12 author => "John H. Kelm <johnhkelm\@gmail.com", |
| |
13 url => "http://sourceforge.net/users/johnhkelm/", |
| |
14 |
| |
15 load => "plugin_load", |
| |
16 unload => "plugin_unload" |
| |
17 ); |
| |
18 |
| |
19 |
| |
20 # These names must already exist |
| |
21 my $GROUP = "UIUC Buddies"; |
| |
22 my $USERNAME = "johnhkelm2"; |
| |
23 |
| |
24 # We will create these on load then destroy them on unload |
| |
25 my $TEST_GROUP = "perlTestGroup"; |
| |
26 my $TEST_NAME = "perlTestName"; |
| |
27 my $TEST_ALIAS = "perlTestAlias"; |
| |
28 my $PROTOCOL_ID = "prpl-oscar"; |
| |
29 |
| |
30 |
| |
31 sub plugin_init { |
| |
32 return %PLUGIN_INFO; |
| |
33 } |
| |
34 |
| |
35 |
| |
36 # This is the sub defined in %PLUGIN_INFO to be called when the plugin is loaded |
| |
37 # Note: The plugin has a reference to itself on top of the argument stack. |
| |
38 sub plugin_load { |
| |
39 my $plugin = shift; |
| |
40 print "#" x 80 . "\n\n"; |
| |
41 Gaim::debug_info("plugin_load()", "Testing $MODULE_NAME Started."); |
| |
42 print "\n\n"; |
| |
43 |
| |
44 |
| |
45 ################################# |
| |
46 # # |
| |
47 # Gaim::Account::Option # |
| |
48 # # |
| |
49 ################################# |
| |
50 |
| |
51 print "Testing: Gaim::Account::Option::new...\n"; |
| |
52 $account_opt = Gaim::Account::Option::new(1, "TEXT", "pref_name"); |
| |
53 Gaim::Account::Option::bool_new("TeXt", "MYprefName", 1); |
| |
54 |
| |
55 ################################# |
| |
56 # # |
| |
57 # Gaim::Account # |
| |
58 # # |
| |
59 ################################# |
| |
60 |
| |
61 |
| |
62 print "Testing: Gaim::Account::new()..."; |
| |
63 $account = Gaim::Account::new($TEST_NAME, $PROTOCOL_ID); |
| |
64 if ($account) { print "ok.\n"; } else { print "fail.\n"; } |
| |
65 |
| |
66 print "Testing: Gaim::Account::add()..."; |
| |
67 Gaim::Accounts::add($account); |
| |
68 print "pending find...\n"; |
| |
69 |
| |
70 print "Testing: Gaim::Accounts::find()..."; |
| |
71 $account = Gaim::Accounts::find($TEST_NAME, $PROTOCOL_ID); |
| |
72 if ($account) { print "ok.\n"; } else { print "fail.\n"; } |
| |
73 |
| |
74 print "Testing: Gaim::Account::get_username()..."; |
| |
75 $user_name = Gaim::Account::get_username($account); |
| |
76 if ($user_name) { print $user_name . "...ok.\n"; } else { print "fail.\n"; } |
| |
77 |
| |
78 |
| |
79 print "Testing: Gaim::Account::is_connected()"; |
| |
80 $user_connected = Gaim::Account::is_connected($account); |
| |
81 if (!($user_connected)) { print "...not connected...ok..\n"; } else { print "...connected...ok.\n"; } |
| |
82 |
| |
83 |
| |
84 print "Testing: Gaim::Accounts::get_active_status()..."; |
| |
85 $status = Gaim::Account::get_active_status($account); |
| |
86 if ($status) { print "ok.\n"; } else { print "fail.\n"; } |
| |
87 |
| |
88 $account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID); |
| |
89 print "Testing: Gaim::Accounts::connect()...pending...\n"; |
| |
90 |
| |
91 Gaim::Account::set_status($account, "available", TRUE); |
| |
92 Gaim::Account::connect($account); |
| |
93 |
| |
94 print "\n\n"; |
| |
95 Gaim::debug_info("plugin_load()", "Testing $MODULE_NAME Completed."); |
| |
96 print "\n\n" . "#" x 80 . "\n\n"; |
| |
97 } |
| |
98 |
| |
99 sub plugin_unload { |
| |
100 my $plugin = shift; |
| |
101 |
| |
102 print "#" x 80 . "\n\n"; |
| |
103 Gaim::debug_info("plugin_unload()", "Testing $MODULE_NAME Started."); |
| |
104 print "\n\n"; |
| |
105 |
| |
106 ######### TEST CODE HERE ########## |
| |
107 |
| |
108 print "\n\n"; |
| |
109 Gaim::debug_info("plugin_unload()", "Testing $MODULE_NAME Completed."); |
| |
110 print "\n\n" . "#" x 80 . "\n\n"; |
| |
111 } |
| |
112 |