Ruby4Skype 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/README +95 -7
  2. data/Rakefile +3 -3
  3. data/lib/{skypeapi.rb → skype.rb} +102 -89
  4. data/lib/{skypeapi → skype}/application.rb +5 -5
  5. data/lib/{skypeapi → skype}/call.rb +9 -9
  6. data/lib/{skypeapi → skype}/chat.rb +176 -176
  7. data/lib/{skypeapi → skype}/chatmember.rb +31 -31
  8. data/lib/{skypeapi → skype}/chatmessage.rb +9 -9
  9. data/lib/{skypeapi → skype}/error.rb +1 -1
  10. data/lib/{skypeapi → skype}/event.rb +2 -2
  11. data/lib/{skypeapi → skype}/filetransfer.rb +2 -2
  12. data/lib/{skypeapi → skype}/group.rb +8 -8
  13. data/lib/{skypeapi → skype}/menuitem.rb +4 -4
  14. data/lib/{skypeapi → skype}/message.rb +1 -1
  15. data/lib/{skypeapi → skype}/object.rb +16 -15
  16. data/lib/{skypeapi → skype}/os/etc.rb +35 -9
  17. data/lib/skype/os/linux.rb +115 -0
  18. data/lib/skype/os/linux.rb~ +117 -0
  19. data/lib/skype/os/mac.rb +217 -0
  20. data/lib/{skypeapi → skype}/os/notifier.rb +1 -1
  21. data/lib/skype/os/timer.rb +108 -0
  22. data/lib/{skypeapi → skype}/os/window_event_queue.rb +16 -16
  23. data/lib/{skypeapi → skype}/os/window_messagehandler.rb +12 -12
  24. data/lib/{skypeapi → skype}/os/windows.rb +10 -10
  25. data/lib/{skypeapi → skype}/profile.rb +3 -3
  26. data/lib/{skypeapi → skype}/sharefunctions.rb +6 -6
  27. data/lib/{skypeapi → skype}/sms.rb +3 -3
  28. data/lib/{skypeapi → skype}/user.rb +1 -1
  29. data/lib/{skypeapi → skype}/version.rb +2 -2
  30. data/lib/{skypeapi → skype}/voicemail.rb +4 -4
  31. data/spec/{skypeapi → skype}/application_spec.rb +13 -15
  32. data/spec/{skypeapi → skype}/chat_spec.rb +75 -77
  33. data/spec/{skypeapi → skype}/chatmember_spec.rb +13 -13
  34. data/spec/{skypeapi → skype}/chatmessage_spec.rb +12 -13
  35. data/spec/skype/event_spec.rb +33 -0
  36. data/spec/{skypeapi → skype}/filetransfer_spec.rb +10 -11
  37. data/spec/skype/group_spec.rb +15 -0
  38. data/spec/{skypeapi → skype}/menuitem_spec.rb +11 -9
  39. data/spec/skype/os/linux_spec.rb +59 -0
  40. data/spec/skype/os/linux_spec.rb~ +58 -0
  41. data/spec/{skypeapi → skype}/os/windows_spec.rb +8 -8
  42. data/spec/skype/profile_spec.rb +24 -0
  43. data/spec/skype/user_spec.rb +25 -0
  44. data/spec/skype_spec.rb +530 -0
  45. metadata +44 -40
  46. data/lib/skypeapi/os/linux.rb +0 -110
  47. data/lib/skypeapi/os/mac.rb +0 -98
  48. data/spec/skypeapi/event_spec.rb +0 -31
  49. data/spec/skypeapi/group_spec.rb +0 -16
  50. data/spec/skypeapi/profile_spec.rb +0 -22
  51. data/spec/skypeapi/user_spec.rb +0 -25
  52. data/spec/skypeapi_spec.rb +0 -528
@@ -0,0 +1,530 @@
1
+ # -*- coding: utf-8 -*-
2
+ $LOAD_PATH << 'lib'
3
+
4
+ require 'spec/matcher_be_boolean'
5
+ require 'skype'
6
+ require 'timeout'
7
+
8
+ describe Skype do
9
+ it "VERSION should 0.4.1" do
10
+ Skype::VERSION.to_s.should == '0.4.1'
11
+ end
12
+
13
+ it "should init and attach and close" do
14
+ Skype.init 'hoge'
15
+ timeout(3){Skype.attach_wait}
16
+ Skype.close
17
+ end
18
+
19
+ it "should more time attach and close" do
20
+ Thread.abort_on_exception = true
21
+ 5.times do |i|
22
+ Skype.init 'hoge'
23
+ timeout(3){ Skype.attach_wait }
24
+ Skype.close
25
+ end
26
+ end
27
+
28
+ it "user(handle) should be instance of Skype::User" do
29
+ Skype.user('hoge').should be_instance_of Skype::User
30
+ end
31
+
32
+ describe 'when attached' do
33
+ before :each do
34
+ Skype.init 'hoge'
35
+ Skype.attach_wait
36
+ end
37
+
38
+ after :each do
39
+ Skype.close
40
+ end
41
+
42
+ it "Skype::Chat should create.send_message" do
43
+ Skype::Chat.create('echo123').send_message('hoge test')
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ describe Skype, 'general methods' do
51
+ before :all do
52
+ Skype.init 'hoge'
53
+ Skype.attach_wait
54
+ end
55
+
56
+ after :all do
57
+ Skype.close
58
+ end
59
+
60
+ it "ping should be true" do
61
+ Skype.ping.should be_true
62
+ end
63
+
64
+ it "get_skype_version should match \d\.\d\.\d\.\d" do
65
+ Skype.getSkypeVersion.should match /\d+\.\d+.\d+.\d+/
66
+ end
67
+
68
+ it "get_current_user_handle should be instance of String and not be empty" do
69
+ Skype.getCurrentUserHandle.should be_instance_of String
70
+ Skype.getCurrentUserHandle.should_not be_empty
71
+ end
72
+
73
+ it "get_user_status should match /^(UNKNOWN)|(ONLINE)|(OFFLINE)|(SKYPEME)|(AWAY)|(NA)|(DND)|(INVISIBLE)|(LOGGEDOUT)$/" do
74
+ Skype.getUserStatus.should match /^(UNKNOWN)|(ONLINE)|(OFFLINE)|(SKYPEME)|(AWAY)|(NA)|(DND)|(INVISIBLE)|(LOGGEDOUT)$/
75
+ end
76
+
77
+ it "set_user_status(s) should == s" do
78
+ s = Skype.getUserStatus
79
+ Skype.setUserStatus(s).should == s
80
+ end
81
+
82
+ it "get_privilege should be boolean" do
83
+ ['SkypeOut','SkypeIn','VOICEMAIL'].each do |user_privilege|
84
+ Skype.getPrivilege(user_privilege).should be_boolean
85
+ end
86
+ end
87
+
88
+ it "get_predictive_dialer_country should be instance of String and size 2" do
89
+ pdCountry = Skype.getPredictiveDialerCountry
90
+ pdCountry.should be_instance_of String
91
+ pdCountry.size.should == 2
92
+ end
93
+
94
+ it "get_connstatus should match (OFFLINE)|(CONNECTING)|(PAUSING)|(ONLINE)" do
95
+ Skype.getConnstatus.should match /^(OFFLINE)|(CONNECTING)|(PAUSING)|(ONLINE)$/
96
+ end
97
+
98
+ describe "device and file methods" do
99
+ it "get_adudio_in should be instance of String and not be empty" do
100
+ Skype.getAudioIn.should be_instance_of String
101
+ Skype.getAudioIn.should_not be_empty
102
+ end
103
+
104
+ it "set_audio_in(device) should device" do
105
+ device = Skype.getAudioIn
106
+ Skype.setAudioIn(device).should == device
107
+ end
108
+
109
+ it "get_audio_out should be instance of String" do# and not be empty" do
110
+ Skype.getAudioOut.should be_instance_of String
111
+ #Skype.getAudioOut.should_not be_empty
112
+ end
113
+
114
+ it "set_audio_out(device) should device" do
115
+ device = Skype.getAudioOut
116
+ Skype.setAudioOut(device).should == device
117
+ end
118
+
119
+ it "get_ringer should be instance of String and not be empty" do
120
+ Skype.getRinger.should be_instance_of String
121
+ Skype.getRinger.should_not be_empty
122
+ end
123
+
124
+ it "set_ringer(device) should device" do
125
+ pending "SET RINGER speaker => ERROR 50 cannot set device"
126
+ device = Skype.getRinger
127
+ Skype.setRinger(device).should == device
128
+ end
129
+
130
+ it "get_mute should be boolean" do
131
+ Skype.getMute.should be_boolean
132
+ end
133
+
134
+ it "set_mute(flag) should flag" do
135
+ flag = Skype.getMute
136
+ Skype.setMute(flag).should == flag
137
+ end
138
+
139
+ def prepare_avator &block
140
+ path = File.dirname(File.expand_path(__FILE__ )) << '/skype_avatar.jpg'
141
+ violated "exist #{path}" if test(?e, path)
142
+ block.call path
143
+ File.delete path
144
+ end
145
+
146
+ it "get_avator(path) should be nil and save jpg file" do
147
+ prepare_avator do |path|
148
+ Skype.getAvatar(path).should be_nil
149
+ test(?e, path).should be_true
150
+ end
151
+ end
152
+
153
+ it "set_avator(path) should path" do
154
+ prepare_avator do |path|
155
+ Skype.getAvatar(path)
156
+ test(?e, path).should be_true
157
+ Skype.setAvatar(path).should == path
158
+ end
159
+ end
160
+
161
+ it "get_ringtone should be instance of String and not be empty" do
162
+ Skype.getRingtone.should be_instance_of String
163
+ Skype.getRingtone.should_not be_empty
164
+ end
165
+
166
+ it "set_ringtone(rt) should rt" do
167
+ pending "SET RINGTONE 1 call_in: => ERROR 111 SET File not found"
168
+ rt = Skype.getRingtone
169
+ Skype.setRingtone(rt).should rt
170
+ end
171
+
172
+ it "get_rigtone_status should be boolean" do
173
+ Skype.getRingtoneStatus.should be_boolean
174
+ end
175
+
176
+ it "set_rigtone_status(flag) should flag" do
177
+ flag = Skype.getRingtoneStatus
178
+ Skype.setRingtoneStatus(flag).should == flag
179
+ end
180
+
181
+ it "get_pc_bspeaker should be boolean" do
182
+ Skype.getPCSpeaker.should be_boolean
183
+ end
184
+
185
+ it "set_pc_speaker(flag) should flag" do
186
+ flag = Skype.getPCSpeaker
187
+ Skype.setPCSpeaker(flag).should == flag
188
+ end
189
+
190
+ it "get_agc should be boolean" do
191
+ Skype.getAGC.should be_boolean
192
+ end
193
+
194
+ it "set_agc(flag) should boolean" do
195
+ flag = Skype.getAGC
196
+ Skype.setAGC(flag).should == flag
197
+ end
198
+
199
+ it "get_aec should be boolean" do
200
+ Skype.getAEC.should be_boolean
201
+ end
202
+
203
+ it "set_aec(flag) should boolean" do
204
+ flag = Skype.getAEC
205
+ Skype.setAEC(flag).should == flag
206
+ end
207
+
208
+ it "reset_idle_timer.should be true" do
209
+ Skype.resetIdleTimer.should be_true
210
+ end
211
+
212
+ it "get_auto_away should be boolean" do
213
+ Skype.getAutoAway.should be_boolean
214
+ end
215
+
216
+ it "set_auto_away(flag) should flag" do
217
+ flag = Skype.getAutoAway
218
+ Skype.setAutoAway(flag).should == flag
219
+ end
220
+
221
+ it "get_video_in should be instance of String and not be empty" do
222
+ Skype.getVideoIn.should be_instance_of String
223
+ end
224
+
225
+ it "set_video_in(string) should string" do
226
+ string =Skype.getVideoIn
227
+ Skype.setVideoIn(string) == string
228
+ end
229
+ end
230
+
231
+ describe "UI methods" do
232
+ before{pending 'uzai'}
233
+
234
+ it "should focus" do
235
+ Skype.focus.should be_true
236
+ end
237
+
238
+ it "should minimize" do
239
+ Skype.minimize.should be_true
240
+ end
241
+
242
+ it "get_window_status should match /(NORMAL)|(MINIMIZED)|(MAXIMIZED)|(HIDDEN)/" do
243
+ Skype.getWindowState.should match /(NORMAL)|(MINIMIZED)|(MAXIMIZED)|(HIDDEN)/
244
+ end
245
+
246
+ it "set_window_status(string) should string" do
247
+ Skype.setWindowState('NORMAL').should == 'NORMAL'
248
+ end
249
+
250
+ it "should open_video_test" do
251
+ Skype.openVideoTest.should be_true
252
+ end
253
+
254
+ it "should open_video_mail" do
255
+ pending
256
+ #assert_equal Skype.openVoiceMail(1)
257
+ #IDが、、、後で調べる。
258
+ end
259
+
260
+ it "should open_add_friend(handle or user)" do
261
+ Skype.openAddAFriend('echo123').should be_true
262
+ Skype.openAddAFriend(Skype.user('echo123')).should be_true
263
+ end
264
+
265
+ it "should open_im(user, msg)" do
266
+ Skype.openIM('echo123','this is a test').should be_true
267
+ end
268
+
269
+ it "should open_chat(chat)" do
270
+ chat = Skype::Chat.create 'echo123'
271
+ Skype.openChat(chat).should be_true
272
+ end
273
+
274
+ it "should open_file_transfer(path,*user)" do
275
+ Skype.openFileTransfer(nil,Skype.user('kashi.9')).should be_true
276
+ end
277
+
278
+ it "should profile_live_tab" do
279
+ Skype.openLiveTab.should be_true
280
+ end
281
+
282
+ it "should open_profile" do
283
+ Skype.openProfile.should be_true
284
+ end
285
+
286
+ it "should open_user_info(user)" do
287
+ Skype.openUserInfo('echo123').should be_true
288
+ end
289
+
290
+ it "should open_conference" do
291
+ Skype.openConference.should be_true
292
+ end
293
+
294
+ it "should open_search" do
295
+ Skype.openSearch.should be_true
296
+ end
297
+
298
+ it "should open_options(nil|'general'|'privacy'|'notifications'|'soundalerts'|'sounddevices'|'hotkeys'|'connection'|'voicemail'|'callforward'|'video'|'advanced')" do
299
+ [nil,'general','privacy','notifications','soundalerts','sounddevices','hotkeys','connection','voicemail','callforward','video','advanced'].each do |page|
300
+ Skype.openOptions(page).should be_true
301
+ end
302
+ end
303
+
304
+ it "should open_call_history" do
305
+ Skype.openCallHistory.should be_true
306
+ end
307
+
308
+ it "should open_contancts" do
309
+ Skype.openContacts.should be_true
310
+ end
311
+
312
+ it "should open_dialpad" do
313
+ Skype.openDialPad.should be_true
314
+ end
315
+
316
+ it "should open_send_contancts" do
317
+ Skype.openSendContacts('hogehoge_001','hogehoge_002').should be_true
318
+ end
319
+
320
+ it "should open_blocked_users" do
321
+ Skype.openBlockedUsers.should be_true
322
+ end
323
+
324
+ it "should open_import_contancts" do
325
+ Skype.openImportContacts.should be_true
326
+ end
327
+
328
+ it "should open_getting_started" do
329
+ Skype.openGettingStarted.should be_true
330
+ end
331
+
332
+ it "should open_authorization" do
333
+ Skype.openAuthorization('hogehoge_1000'.should be_true)
334
+ end
335
+
336
+ it "should btn_pressed_released" do
337
+ 9.times do |i|
338
+ Skype.BTNPressed(i).should be_true
339
+ sleep 0.5
340
+ Skype.BTNReleased(i).should be_true
341
+ end
342
+ end
343
+
344
+ it "get_contacts_focused should be instance of Skype::User" do
345
+ Skype.getContactsFocused.should be_instance_of Skype::User
346
+ end
347
+
348
+ it "get_ui_langualge should be instance of String and sieze 2" do
349
+ Skype.getUILanguage.should be_instance_of String
350
+ Skype.getUILanguage.size.should == 2
351
+ end
352
+
353
+ it "set_ui_langualge(string) should string" do
354
+ uil = Skype.getUILanguage
355
+ Skype.setUILanguage(uil).should == uil
356
+ end
357
+
358
+ it "get_wall_paper should be instance of String" do
359
+ Skype.getWallPaper.should be_instance_of String
360
+ end
361
+
362
+ it "set_wall_paper(string) should string" do
363
+ string = Skype.getWallPaper
364
+ Skype.setWallPaper(string).should == string
365
+ end
366
+
367
+ it "get_silent_mode should be boolean" do
368
+ Skype.getSilentMode.should be_boolean
369
+ end
370
+
371
+ it "set_silent_mode(flag) should flag" do
372
+ silent_mode = Skype.getSilentMode
373
+ Skype.setSilentMode(silent_mode).should == silent_mode
374
+ end
375
+
376
+ end
377
+
378
+ describe "search methods" do
379
+
380
+ it "search_frinends each should be instance of Skype::User" do
381
+ Skype.searchFriends.each do |user|
382
+ user.should be_instance_of Skype::User
383
+ end
384
+ end
385
+
386
+ it "search_users(String) each should be instance of Skype::User" do
387
+ Skype.searchUsers('echo123').each do |user|
388
+ user.should be_instance_of Skype::User
389
+ end
390
+ end
391
+
392
+ it "search_calls(String or User?) each should be instance of Skype::Call" do
393
+ Skype.searchCalls('echo123').each do |call|
394
+ call.should be_instance_of Skype::Call
395
+ end
396
+ end
397
+
398
+ it "search_active_calls each should be instance of Skype::Call" do
399
+ Skype.searchActiveCalls.each do |call|
400
+ call.should be_instance_of Skype::Call
401
+ end
402
+ end
403
+
404
+ it "search_missed_calls each should be instance of Skype::Call" do
405
+ Skype.searchMissedCalls.each do |call|
406
+ call.should be_instance_of Skype::Call
407
+ end
408
+ end
409
+
410
+ it "search_smss should each should be instance of Skype::SMS" do
411
+ Skype.searchSMSs.each do |sms|
412
+ sms.should be_instance_of Skype::SMS
413
+ end
414
+ end
415
+
416
+ it "search_missed_smss should each should be instance of Skype::Call" do
417
+ Skype.searchMissedSMSs.each do |call|
418
+ call.should be_instance_of Skype::Call
419
+ end
420
+ end
421
+
422
+ it "search_voice_mail should each should be instance of Skype::Call" do
423
+ Skype.searchVoiceMails.each do |call|
424
+ call.should be_instance_of Skype::Call
425
+ end
426
+ end
427
+
428
+ it "search_missed_voice_mail should each should be instance of Skype::VoiceMail" do
429
+ Skype.searchMissedVoiceMails.each do |vm|
430
+ vm.should be_instance_of Skype::VoiceMail
431
+ end
432
+ end
433
+
434
+ #OBS
435
+ #it "search_messages should" do
436
+ # Skype.searchMessages('skypetester').each do |msg|
437
+ # assert_instance_of(Skype::Message, msg)
438
+ # end
439
+ #end
440
+
441
+ it "search_missed_messages should each should be instance of Skype::Message" do
442
+ Skype.searchMissedMessages.each do |msg|
443
+ msg.should be_instance_of Skype::Message
444
+ end
445
+ end
446
+
447
+ it "search_chats should each should be instance of Skype::Chat" do
448
+ Skype.searchChats().each do |chat|
449
+ chat.should be_instance_of Skype::Chat
450
+ end
451
+ end
452
+
453
+ it "search_active_chats should each should be instance of Skype::Chat" do
454
+ Skype.searchActiveChats().each do |chat|
455
+ chat.should be_instance_of Skype::Chat
456
+ end
457
+ end
458
+
459
+ it "search_missed_chats should each should be instance of Skype::Chat" do
460
+ Skype.searchMissedChats.each do |chat|
461
+ chat.should be_instance_of Skype::Chat
462
+ end
463
+ end
464
+
465
+ it "search_recent_chats should each should be instance of Skype::Chat" do
466
+ Skype.searchRecentChats().each do |chat|
467
+ chat.should be_instance_of Skype::Chat
468
+ end
469
+ end
470
+
471
+ it "search_bookmarked_chats should each should be instance of Skype::Chat" do
472
+ Skype.searchBookMarkedChats().each do |chat|
473
+ chat.should be_instance_of Skype::Chat
474
+ end
475
+ end
476
+
477
+ it "search_chat_messages should each should be instance of Skype::ChatMessage" do
478
+ Skype.searchChatMessages('echo123').each do |chat_message|
479
+ chat_message.should be_instance_of Skype::ChatMessage
480
+ end
481
+ end
482
+
483
+ it "search_missed_chat_messages should each should be instance of Skype::ChatMessage" do
484
+ Skype.searchMissedChatMessages().each do |chat_message|
485
+ chat_message.should be_instance_of Skype::ChatMessage
486
+ end
487
+ end
488
+
489
+ it "search_users_waiting_my_authorization should each should be instance of Skype::User" do
490
+ Skype.searchUsersWaitingMyAuthorization.each do |user|
491
+ user.should be_instance_of Skype::User
492
+ end
493
+ end
494
+
495
+ it "search_groups should each should be instance of Skype::Group" do
496
+ Skype.searchGroups('ALL').each do |group|
497
+ group.should be_instance_of Skype::Group
498
+ end
499
+ end
500
+
501
+ it "search_file_transfers should each should be instance of Skype::FileTransfer" do
502
+ Skype.searchFileTransfers().each do |file_transfer|
503
+ file_transfer.should be_instance_of Skype::FileTransfer
504
+ end
505
+ end
506
+
507
+ it "search_active_file_transfers should each should be instance of Skype::FileTransfer" do
508
+ Skype.searchActiveFileTransfers().each do |file_transfer|
509
+ file_transfer.should be_instance_of Skype::FileTransfer
510
+ end
511
+ end
512
+
513
+ end
514
+
515
+ describe 'clear history methods' do
516
+ before{pending "I do not want clear"}
517
+
518
+ it "clear_chat_history should be_true" do
519
+ Skype.clearChatHistory.should be_true
520
+ end
521
+
522
+ it "clear_voice_mail_history should be true" do
523
+ Skype.clearVoiceMailHistory.should be_true
524
+ end
525
+
526
+ it "clear_call_history('ALL') should be true" do
527
+ Skype.clearCallHistory('ALL').should be_true
528
+ end
529
+ end
530
+ end