~airmind/conduit/gsoc08

« back to all changes in this revision

Viewing changes to test/python-tests/TestCoreUtilBluetooth.py

  • Committer: Alexandre Rosenfeld
  • Date: 2008-07-31 03:01:48 UTC
  • mfrom: (1460.1.60 devel)
  • Revision ID: airmind@gemini-20080731030148-tgepluy917epvo31
Merged back from SVN

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#common sets up the conduit environment
 
2
from common import *
 
3
 
 
4
import conduit.utils.Bluetooth as Bluetooth
 
5
 
 
6
#test the bluetooth searching singleton
 
7
def found_phone(address, name):
 
8
    pass
 
9
 
 
10
def found_pc(address, name):
 
11
    pass
 
12
 
 
13
a = Bluetooth.BluetoothSearcher()
 
14
b = Bluetooth.BluetoothSearcher()
 
15
 
 
16
ok("Bluetooth searcher is singleton", a != None and a == b)
 
17
 
 
18
a.watch_for_devices(found_phone)
 
19
b.watch_for_devices(found_phone)
 
20
ok("Registered found_phone function", len(a._cbs) == 1)
 
21
 
 
22
b.watch_for_devices(found_pc, class_check_func=Bluetooth.is_computer_class)
 
23
ok("Registered found_pc function", len(a._cbs) == 2)
 
24
 
 
25
wait_seconds(2)
 
26
ok("Bluetooth search thread started", a.isAlive())
 
27
 
 
28
try:
 
29
    a.cancel()
 
30
    a.join(a.SLEEP_TIME)
 
31
    ok("Cancelled scan (found %d devices)" % len(a.get_devices()), True)
 
32
except Exception:
 
33
    ok("Cancelled scan", False)
 
34
 
 
35
finished()