Exemplo n.º 1
0
    def __init__(self):
        hildon.Program.__init__(self)
        self.window = hildon.Window()
        self.window.connect("destroy", self.quit)
        self.add_window(self.window)

        vbox = gtk.VBox()
        self.window.add(vbox)

        self.entry = gtk.Entry()
        vbox.add(self.entry)

        self.hscale = gtk.HScale(gtk.Adjustment(upper=10, step_incr=1))
        vbox.add(self.hscale)

        self.context = osso.Context("osso_test_statesaving", "0.0.1", False)
        self.stateSaving = osso.StateSaving(self.context)
        self.autosave = osso.Autosave(self.context)
        self.autosave.set_autosave_callback(self.save_state)

        self.connect("notify::is-topmost", self.topmost_change)

        self.state_read()

        #After the state_read call, set the callbacks for data change
        self.entry.connect("changed", self.entry_changed)
        self.hscale.connect("value-changed", self.hscale_changed)
        self.window.show_all()
    def test_autosaving(self):
        state_saving = osso.StateSaving(self.ctx)

        #callback for autosave
        def save_state(self, user_data=None):
            t = "Unit test for the state saving and autosave OSSO modules"
            n = 3.1415
            state_saving.state_write((t, n))

        autosave = osso.Autosave(self.ctx)
        autosave.set_autosave_callback(save_state)
        autosave.force_autosave()
        data = state_saving.state_read()
        saved_text = data[0]
        saved_number = data[1]
        self.assertEquals(
            saved_text,
            "Unit test for the state saving and autosave OSSO modules")
        self.assertEquals(saved_number, 3.1415)
Exemplo n.º 3
0
def handler_test_cp_plugin_handler(widget, plug, app):
    global count

    try:
        plugin = plugins.pop()
    except:
        return

    print "executing:", plugin
    plug.plugin_execute(plugin, True, app)
    print "saving..."
    plug.plugin_save_state(plugin)

c = osso.Context("test_client", "0.0.0", False)
as = osso.Autosave(c)
applic = osso.Application(c)
rpc = osso.Rpc(c)
print "as.get_name() ->", as.get_name()
print "as.get_version() ->", as.get_version()
print "rpc.get_rpc_timeout() ->", rpc.get_rpc_timeout()
print "rpc.set_rpc_timeout(15) ->", rpc.set_rpc_timeout(15)
print "rpc.get_rpc_timeout() ->", rpc.get_rpc_timeout()
timenot = osso.TimeNotification(c)
timenot.set_time_notification_callback(handler_test_time_notification, "Notification Callback!")
timenot.set_time(time.localtime())
plug = osso.Plugin(c)
ss = osso.StateSaving(c)

local = osso.Locale(c)
 def test_autosave_userdata_changed(self):
     autosave = osso.Autosave(self.ctx)
     autosave.userdata_changed()
 def test_autosave_get_version(self):
     autosave = osso.Autosave(self.ctx)
     autosave.get_version()
 def test_autosave_get_name(self):
     autosave = osso.Autosave(self.ctx)
     autosave.get_name()
 def test_constructor_autosave(self):
     autosave = osso.Autosave(self.ctx)
     self.assertTrue(isinstance(autosave, osso.Autosave))
     self.assertRaises(TypeError, osso.Autosave, None)