def test_multi_axis_7(self): """Test along the class axis.""" register_callback("PRE_ENTRY", self.inc_cb) Entry().get({}, "") Entry().put_media({}, "") Service().get({}, "") self.assertEqual(self.count, 2)
def test_multi_axis_6(self): """Test that manually added PRE/POST works for ANY""" register_callback("POST_ANY", self.inc_cb) Entry().get({}, "") Entry().put_media({}, "") Service().get({}, "") self.assertEqual(self.count, 3)
def test_multi_axis_5(self): """Test that PRE is not added to ANY""" register_callback("ANY", self.inc_cb) Entry().get({}, "") Entry().put_media({}, "") Service().get({}, "") self.assertEqual(self.count, 6)
def test_any(self): """Make sure the right callback is called on ANY""" self.assertFalse(self.any_called) Entry().get({}, "") self.assertFalse(self.any_called) register_callback("ANY", self.any) Entry().get({}, "") self.assertTrue(self.any_called)
def test_pre(self): """Confirm that data is passed through to the callback""" register_callback("PRE", self.pre_cb) Entry().get({"status": "200"}, "<feed/>") self.assertTrue(self.pre_called) self.assertEqual(self.pre_headers["status"], "200") self.assertEqual(self.pre_body, "<feed/>") self.assertTrue("PRE" in self.pre_attribs) self.assertTrue("ANY" not in self.pre_attribs)
def test_post(self): """Confirm that data is passed through to the callback""" register_callback("POST", self.post_cb) headers, body = Entry().put_media({"content-length": "7"}, "<feed/>") self.assertTrue(self.post_called) self.assertEqual(self.post_headers["status"], "200") self.assertEqual(headers["status"], "200") self.assertEqual(self.post_body, "bar") self.assertEqual(body, "bar") self.assertTrue("POST" in self.post_attribs) self.assertTrue("ANY" not in self.post_attribs)
def test_multi_axis_4(self): """Test along multiple axes at the same time.""" register_callback("PRE_ANY", self.inc_cb) register_callback("POST_GET", self.inc_cb) register_callback("PRE_ENTRY", self.inc_cb) Entry().get({}, "") self.assertEqual(self.count, 3)
def __init__(self, _): _FrameWindow.__init__(self) self._imgs = dict([(st, None) for st in self.frame.allowed_states]) self._fwidth = 0 self._fheight = 0 self.pos = {'x': self.frame.pos['title']['x'], 'y': self.frame.pos['title']['y'], 'width': self.frame.pos['title']['width'], 'height': self.frame.pos['title']['height']} self.configure(x=self.pos['x'], y=self.pos['y'], height=self.pos['height']) events.register_callback(xcb.xproto.PropertyNotifyEvent, self.cb_PropertyNotifyEvent, self.frame.client.win.id) mousebind.register('title', self, self.id) self.set_text(self.frame.client.win.wmname) self.map()
def __init__(self, *_): _FrameWindow.__init__(self) self._imgs = {st: {'normal': None, 'hover': None, 'click': None} for st in self.frame.allowed_states} self._secondary = set() self.pos = {'x': self.frame.pos[self.ident]['x'], 'y': self.frame.pos[self.ident]['y'], 'width': self.frame.pos[self.ident]['width'], 'height': self.frame.pos[self.ident]['height']} self.configure(y=self.pos['y'], width=self.pos['width'], height=self.pos['height']) events.register_callback(xcb.xproto.EnterNotifyEvent, self.cb_enter, self.id) events.register_callback(xcb.xproto.LeaveNotifyEvent, self.cb_leave, self.id) mousebind.register('button', self, self.id) self.setup() self.map()
aid = partial(util.get_atom, state.conn) util.build_atom_cache(state.conn, icccm) util.build_atom_cache(state.conn, ewmh) command.init() masks = [ xproto.EventMask.SubstructureNotify | xproto.EventMask.SubstructureRedirect | xproto.EventMask.PropertyChange # | xproto.EventMask.FocusChange ] state.core.ChangeWindowAttributesChecked(state.root, xproto.CW.EventMask, masks).check() events.register_callback(xproto.ClientMessageEvent, root.cb_ClientMessage, state.root) events.register_callback(xproto.MappingNotifyEvent, root.cb_MappingNotifyEvent, state.root) events.register_callback(xproto.MapRequestEvent, client.cb_MapRequestEvent, state.root) events.register_callback(xproto.FocusInEvent, client.cb_FocusInEvent, state.root) events.register_callback(xproto.FocusOutEvent, client.cb_FocusOutEvent, state.root) events.register_callback(xproto.ConfigureRequestEvent, window.cb_ConfigureRequestEvent, state.root) events.register_callback(xproto.MotionNotifyEvent, grab.drag_do, state.pyndow, None, None, None) events.register_callback(xproto.ButtonReleaseEvent, grab.drag_end, state.pyndow, None, None, None)
def __init__(self, wid): self.win = window.Window(wid) self.workspace = None self.mapped = False self.initial_map = False self.__unmap_ignore = 0 self.strut = self.strut_partial = None state.conn.core.ChangeWindowAttributes( self.win.id, xcb.xproto.CW.EventMask, [ xcb.xproto.EventMask.StructureNotify | xcb.xproto.EventMask.PropertyChange ]) events.register_callback(xcb.xproto.ConfigureRequestEvent, self.cb_ConfigureRequestEvent, self.win.id) events.register_callback(xcb.xproto.MapRequestEvent, self.cb_MapRequestEvent, self.win.id) events.register_callback(xcb.xproto.DestroyNotifyEvent, self.cb_DestroyNotifyEvent, self.win.id) events.register_callback(xcb.xproto.UnmapNotifyEvent, self.cb_UnmapNotifyEvent, self.win.id) events.register_callback(xcb.xproto.PropertyNotifyEvent, self.cb_PropertyNotifyEvent, self.win.id) events.register_callback(xcb.xproto.ClientMessageEvent, self.cb_ClientMessageEvent, self.win.id) self.win.configure(border_width=0)