示例#1
0
    def _filter_signals(self, signal, tab, *args):
        """Filter signals and trigger TabbedBrowser signals if needed.

        Triggers signal if the original signal was sent from the _current_ tab
        and not from any other one.

        The original signal does not matter, since we get the new signal and
        all args.

        Args:
            signal: The signal to emit if the sender was the current widget.
            tab: The WebView which the filter belongs to.
            *args: The args to pass to the signal.
        """
        log_signal = debug.signal_name(signal) not in self.BLACKLIST
        tabbed_browser = objreg.get('tabbed-browser', scope='window',
                                    window=self._win_id)
        try:
            tabidx = tabbed_browser.indexOf(tab)
        except RuntimeError:
            # The tab has been deleted already
            return
        if tabidx == tabbed_browser.currentIndex():
            if log_signal:
                log.signals.debug("emitting: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
            signal.emit(*args)
        else:
            if log_signal:
                log.signals.debug("ignoring: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
示例#2
0
    def _filter_signals(self, signal, tab, *args):
        """Filter signals and trigger TabbedBrowser signals if needed.

        Triggers signal if the original signal was sent from the _current_ tab
        and not from any other one.

        The original signal does not matter, since we get the new signal and
        all args.

        Args:
            signal: The signal to emit if the sender was the current widget.
            tab: The WebView which the filter belongs to.
            *args: The args to pass to the signal.
        """
        log_signal = debug.signal_name(signal) not in self.BLACKLIST
        tabbed_browser = objreg.get('tabbed-browser',
                                    scope='window',
                                    window=self._win_id)
        try:
            tabidx = tabbed_browser.indexOf(tab)
        except RuntimeError:
            # The tab has been deleted already
            return
        if tabidx == tabbed_browser.currentIndex():
            if log_signal:
                log.signals.debug("emitting: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
            signal.emit(*args)
        else:
            if log_signal:
                log.signals.debug("ignoring: {} (tab {})".format(
                    debug.dbg_signal(signal, args), tabidx))
示例#3
0
def test_dbg_signal(stubs, args, expected):
    assert debug.dbg_signal(stubs.FakeSignal(), args) == expected
示例#4
0
def test_dbg_signal(stubs, args, expected):
    assert debug.dbg_signal(stubs.FakeSignal(), args) == expected
示例#5
0
 def test_dbg_signal_newline(self):
     """Test dbg_signal() with a newline."""
     self.assertEqual(debug.dbg_signal(self.signal, ['foo\nbar']),
                      r"fake('foo\nbar')")
示例#6
0
 def test_dbg_signal_eliding(self):
     """Test eliding in dbg_signal()."""
     self.assertEqual(debug.dbg_signal(self.signal, ['x' * 201]),
                      "fake('{}\u2026)".format('x' * 198))
示例#7
0
 def test_dbg_signal(self):
     """Test dbg_signal()."""
     self.assertEqual(debug.dbg_signal(self.signal, [23, 42]),
                      'fake(23, 42)')
示例#8
0
 def test_dbg_signal_newline(self):
     """Test dbg_signal() with a newline."""
     self.assertEqual(debug.dbg_signal(self.signal, ['foo\nbar']),
                      r"fake('foo\nbar')")
示例#9
0
 def test_dbg_signal_eliding(self):
     """Test eliding in dbg_signal()."""
     self.assertEqual(debug.dbg_signal(self.signal,
                                       ['x' * 201]),
                      "fake('{}\u2026)".format('x' * 198))
示例#10
0
 def test_dbg_signal(self):
     """Test dbg_signal()."""
     self.assertEqual(debug.dbg_signal(self.signal, [23, 42]),
                      'fake(23, 42)')
示例#11
0
def test_dbg_signal_newline(signal):
    """Test dbg_signal() with a newline."""
    dbg_signal = debug.dbg_signal(signal, ['foo\nbar'])
    assert dbg_signal == r"fake('foo\nbar')"
示例#12
0
def test_dbg_signal_eliding(signal):
    """Test eliding in dbg_signal()."""
    dbg_signal = debug.dbg_signal(signal, ['x' * 201])
    assert dbg_signal == "fake('{}\u2026)".format('x' * 198)
示例#13
0
def test_dbg_signal(signal):
    """Test dbg_signal()."""
    assert debug.dbg_signal(signal, [23, 42]) == 'fake(23, 42)'
示例#14
0
def test_dbg_signal_newline(signal):
    """Test dbg_signal() with a newline."""
    dbg_signal = debug.dbg_signal(signal, ['foo\nbar'])
    assert dbg_signal == r"fake('foo\nbar')"
示例#15
0
def test_dbg_signal_eliding(signal):
    """Test eliding in dbg_signal()."""
    dbg_signal = debug.dbg_signal(signal, ['x' * 201])
    assert dbg_signal == "fake('{}\u2026)".format('x' * 198)
示例#16
0
def test_dbg_signal(signal):
    """Test dbg_signal()."""
    assert debug.dbg_signal(signal, [23, 42]) == 'fake(23, 42)'