def test_action_group_change(self):
        """When the action group is changed activating the old ones should not
        affect this search bar (and the other way around)."""

        fw = util.find_child_widget(self.w, "forward")
        bw = util.find_child_widget(self.w, "backward")
        
        act_fw = self.ag.get_action(ACTION_FIND_FORWARD)
        act_bw = self.ag.get_action(ACTION_FIND_BACKWARD)
        
        assert self.bar.find_forward is act_fw
        assert self.bar.find_backward is act_bw
        assert fw in act_fw.get_proxies()
        assert bw in act_bw.get_proxies()
        
        self.bar.set_action_group(None)
        
        assert fw not in act_fw.get_proxies()
        assert bw not in act_bw.get_proxies()
        
        assert self.bar.find_forward is None
        assert self.bar.find_backward is None
        assert self.bar.find_forward_source is None
        assert self.bar.find_backward_source is None
        
        ag = self.createAg()
        self.bar.set_action_group(ag)
        act_fw = ag.get_action(ACTION_FIND_FORWARD)
        act_bw = ag.get_action(ACTION_FIND_BACKWARD)
        assert fw in act_fw.get_proxies()
        assert bw in act_bw.get_proxies()
示例#2
0
    def test_action_group_change(self):
        """When the action group is changed activating the old ones should not
        affect this search bar (and the other way around)."""

        fw = util.find_child_widget(self.w, "forward")
        bw = util.find_child_widget(self.w, "backward")

        act_fw = self.ag.get_action(ACTION_FIND_FORWARD)
        act_bw = self.ag.get_action(ACTION_FIND_BACKWARD)

        assert self.bar.find_forward is act_fw
        assert self.bar.find_backward is act_bw
        assert fw in act_fw.get_proxies()
        assert bw in act_bw.get_proxies()

        self.bar.set_action_group(None)

        assert fw not in act_fw.get_proxies()
        assert bw not in act_bw.get_proxies()

        assert self.bar.find_forward is None
        assert self.bar.find_backward is None
        assert self.bar.find_forward_source is None
        assert self.bar.find_backward_source is None

        ag = self.createAg()
        self.bar.set_action_group(ag)
        act_fw = ag.get_action(ACTION_FIND_FORWARD)
        act_bw = ag.get_action(ACTION_FIND_BACKWARD)
        assert fw in act_fw.get_proxies()
        assert bw in act_bw.get_proxies()
    def test_widgets(self):
        
        bar = self.bar
        w = bar.widget
        lbl = util.find_child_widget(w, "label")
        assert lbl is not None
        assert lbl.get_property("visible")
        
        assert self.entry is not None
        assert self.entry.get_property("visible")

        fw = util.find_child_widget(w, "forward")
        assert fw is not None
        bw = util.find_child_widget(w, "backward")
        assert bw is not None
示例#4
0
    def test_widgets(self):

        bar = self.bar
        w = bar.widget
        lbl = util.find_child_widget(w, "label")
        assert lbl is not None
        assert lbl.get_property("visible")

        assert self.entry is not None
        assert self.entry.get_property("visible")

        fw = util.find_child_widget(w, "forward")
        assert fw is not None
        bw = util.find_child_widget(w, "backward")
        assert bw is not None
    def test_focus(self):
        """When the text entry is selected its text should be selected."""
        # XXX: calling grab_focus does not give *real* focus to the widget
        return
        
        entry = self.entry
        entry.set_text("12345")
        entry.select_region(1,-1)
        self.assertEquals("2345", get_selected_text(entry))
        
        # When we show the object it should focus the entry
        self.w.show()

        entry = self.entry
        self.assertEquals("12345", get_selected_text(entry))
        assert entry.props.is_focus
        gtk.main_quit()

        lbl = util.find_child_widget(self.w, "label")
        lbl.grab_focus()
        assert lbl.props.is_focus
        assert not entry.props.is_focus
        
        # Deselect the text
        self.w.hide()
        entry.select_region(0, 0)
        self.assertEquals("", get_selected_text(entry))
        
        # Now show it again, the text should be selected again
        self.w.show()
        assert entry.props.is_focus
        self.assertEquals("12345", get_selected_text(entry))
示例#6
0
    def test_focus(self):
        """When the text entry is selected its text should be selected."""
        # XXX: calling grab_focus does not give *real* focus to the widget
        return

        entry = self.entry
        entry.set_text("12345")
        entry.select_region(1, -1)
        self.assertEquals("2345", get_selected_text(entry))

        # When we show the object it should focus the entry
        self.w.show()

        entry = self.entry
        self.assertEquals("12345", get_selected_text(entry))
        assert entry.props.is_focus
        gtk.main_quit()

        lbl = util.find_child_widget(self.w, "label")
        lbl.grab_focus()
        assert lbl.props.is_focus
        assert not entry.props.is_focus

        # Deselect the text
        self.w.hide()
        entry.select_region(0, 0)
        self.assertEquals("", get_selected_text(entry))

        # Now show it again, the text should be selected again
        self.w.show()
        assert entry.props.is_focus
        self.assertEquals("12345", get_selected_text(entry))
    def test_sync(self):
        bar = self.bar
        w = bar.widget
        entry = util.find_child_widget(w, "entry")
        fw = util.find_child_widget(w, "forward")

        self.assertEquals("", entry.get_text())
        self.assertEquals("", self.search.get_text())
        
        entry.set_text("foo")
        self.assertEquals("foo", self.search.get_text())
    
        self.search.set_text("bar")
        self.assertEquals("bar", entry.get_text())
        
        # Check if the event listeners' decrease
        # TODO: test the events
        '''
示例#8
0
    def test_sync(self):
        bar = self.bar
        w = bar.widget
        entry = util.find_child_widget(w, "entry")
        fw = util.find_child_widget(w, "forward")

        self.assertEquals("", entry.get_text())
        self.assertEquals("", self.search.get_text())

        entry.set_text("foo")
        self.assertEquals("foo", self.search.get_text())

        self.search.set_text("bar")
        self.assertEquals("bar", entry.get_text())

        # Check if the event listeners' decrease
        # TODO: test the events
        '''
    def setUp(self):
        self.ag = self.createAg()
        self.act_fw = self.ag.get_action(ACTION_FIND_FORWARD)
        self.act_bw = self.ag.get_action(ACTION_FIND_BACKWARD)

        self.provider = provider = core.ServiceProvider()
        edit.register_services(provider)
        
        self.highlight = provider.get_service(interfaces.IHighlightSearch)
        self.search = provider.get_service(interfaces.ISearch)
#        self.view = MockTextView()
#        self.view.buffer = self.buff
        provider.register_factory(interfaces.ISearchBar, SearchBar)
        self.bar = provider.get_service(interfaces.ISearchBar)
        self.bar.set_action_group(self.ag)
        
        self.w = self.bar.widget
        self.entry = self.bar.entry#util.find_child_widget(self.w, "entry")
        self.bw = util.find_child_widget(self.w, "backward")
        self.fw = util.find_child_widget(self.w, "forward")
        assert self.entry is not None
示例#10
0
    def setUp(self):
        self.ag = self.createAg()
        self.act_fw = self.ag.get_action(ACTION_FIND_FORWARD)
        self.act_bw = self.ag.get_action(ACTION_FIND_BACKWARD)

        self.provider = provider = core.ServiceProvider()
        edit.register_services(provider)

        self.highlight = provider.get_service(interfaces.IHighlightSearch)
        self.search = provider.get_service(interfaces.ISearch)
        #        self.view = MockTextView()
        #        self.view.buffer = self.buff
        provider.register_factory(interfaces.ISearchBar, SearchBar)
        self.bar = provider.get_service(interfaces.ISearchBar)
        self.bar.set_action_group(self.ag)

        self.w = self.bar.widget
        self.entry = self.bar.entry  #util.find_child_widget(self.w, "entry")
        self.bw = util.find_child_widget(self.w, "backward")
        self.fw = util.find_child_widget(self.w, "forward")
        assert self.entry is not None