summaryrefslogtreecommitdiff
path: root/scripts/dbus_tests.py
blob: fe343da327a860d66ca85916ec7370b255ff4e20 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import glob
import dbus
from dbus import glib
import gobject
import sys
import os
import time
from subprocess import call
from junit_xml import TestSuite, TestCase


gobject.threads_init()

glib.init_threads()

bus = dbus.SessionBus()

navit_object = bus.get_object("org.navit_project.navit", # Connection name
                               "/org/navit_project/navit/default_navit" ) # Object's path

iface = dbus.Interface(navit_object, dbus_interface="org.navit_project.navit.navit")
junit_directory=sys.argv[1]
if not os.path.exists(junit_directory):
    os.makedirs(junit_directory)

tests=[]
start_time = time.time()
test_cases = TestCase("zoom (factor) expected 512", '', time.time() - start_time, '', '')
iface.zoom(-2)
zoom=iface.get_attr("zoom")[1]
if zoom !=512 :
   test_cases.add_failure_info('zoom level mismatch. Got '+str(zoom)+', expected 512')
tests.append(test_cases)

test_cases = TestCase("zoom (factor) expected 1024", '', time.time() - start_time, '', '')
iface.zoom(-2)
zoom=iface.get_attr("zoom")[1]
if zoom !=1024 :
   test_cases.add_failure_info('zoom level mismatch. Got '+str(zoom)+', expected 1024')
tests.append(test_cases)

test_cases = TestCase("zoom via set_attr expected 512", '', time.time() - start_time, '', '')
iface.set_attr("zoom", 512)
zoom=iface.get_attr("zoom")[1]
if zoom !=512 :
   test_cases.add_failure_info('zoom level mismatch. Got '+str(zoom)+', expected 512')
tests.append(test_cases)

ts = [TestSuite("Navit dbus tests", tests)]

with open(junit_directory+'dbus.xml', 'w+') as f:
    TestSuite.to_file(f, ts, prettyprint=False)