def test_set_max_width_chars(self): with visible(Entry()) as e: e.set_max_width_chars(4) nat1 = e.get_preferred_width()[1] e.set_max_width_chars(40) nat2 = e.get_preferred_width()[1] self.assertTrue(nat1 < nat2)
def test_visible_pre_setup_children(self): p = self.Kind() p.pack1(Gtk.Button()) p.pack2(Gtk.Button()) p.set_relative(0.75) self.failUnlessEqual(p.get_relative(), 0.75) with visible(p, width=200, height=200) as p: self.failUnlessAlmostEqual(p.get_relative(), 0.75, 2)
def test_create_drag_icon(self): model = self.c.get_model() all_paths = [row.path for row in model] self.assertFalse(self.c.create_multi_row_drag_icon(all_paths, 1)) with visible(self.c): self.assertTrue(self.c.create_multi_row_drag_icon(all_paths, 1)) self.assertFalse(self.c.create_multi_row_drag_icon([], 1)) self.assertTrue( self.c.create_multi_row_drag_icon([all_paths[0]], 10))
def test_popup(self): menu = Gtk.Menu() selection = self.c.get_selection() selection.set_mode(Gtk.SelectionMode.MULTIPLE) with visible(self.c): # the popup only shows if the underlying row is selected, # so select all first selection.select_all() self.assertTrue(self.c.popup_menu(menu, Gdk.BUTTON_SECONDARY, 0))
def _render_column(self, column, **kwargs): view = Gtk.TreeView() model = ObjectStore() view.set_model(model) song = AudioFile({"~filename": "/dev/null"}) song.update(kwargs) model.append(row=[song]) view.append_column(column) if column.get_resizable(): column.set_expand(True) with visible(view): view.columns_autosize()
def test_basic(self): self.failUnless(config.get("memory", "foobar", None) is None) p = x.ConfigRVPaned("memory", "foobar", 0.75) p.pack1(Gtk.Button()) p.pack2(Gtk.Button()) with visible(p, width=200, height=200) as p: self.failUnlessAlmostEqual(p.get_relative(), 0.75, 2) p.props.position = 20 self.failUnlessAlmostEqual(p.get_relative(), 0.10, 2) config_value = config.getfloat("memory", "foobar") self.failUnlessAlmostEqual(config_value, 0.10, 2)
def _render_column(self, column, **kwargs): view = Gtk.TreeView() model = PlaylistModel() view.set_model(model) song = AudioFile({"~filename": "/dev/null", "~#rating": 0.6666}) song.update(kwargs) model.append(row=[song]) view.append_column(column) if column.get_resizable(): column.set_expand(True) with visible(view): view.columns_autosize() text = column.get_cells()[0].get_property("text") self.assertIsNot(text, None) return text
def test_visible_pre_setup_empty(self): p = self.Kind() p.set_relative(0.75) self.failUnlessEqual(p.get_relative(), 0.75) with visible(p) as p: self.failUnlessEqual(p.get_relative(), 0.75)
def test_right_click(self): with visible(self.c): send_button_click(self.c, Gdk.BUTTON_SECONDARY) send_button_click(self.c, Gdk.BUTTON_SECONDARY, primary=True)
def test_click(self): with visible(self.c): send_button_click(self.c, Gdk.BUTTON_PRIMARY) send_button_click(self.c, Gdk.BUTTON_PRIMARY, primary=True)
def test_click(self): with visible(self.c): send_button_click(self.c, Gdk.BUTTON_PRIMARY) send_button_click(self.c, Gdk.BUTTON_PRIMARY, ctrl=True)
def test_right_click(self): with visible(self.c): send_button_click(self.c, Gdk.BUTTON_SECONDARY) send_button_click(self.c, Gdk.BUTTON_SECONDARY, ctrl=True)
def test_visible_no_setup(self): p = self.Kind() with visible(p): pass
def test_key_events(self): with visible(self.c): send_key_click(self.c, "<ctrl>Right") send_key_click(self.c, "<ctrl>Left")
def test_key_events(self): with visible(self.c): send_key_click(self.c, "<Primary>Right") send_key_click(self.c, "<Primary>Left")