Esempio n. 1
0
def test_undo_completion(tabbed_browser_stubs, info):
    """Test :undo completion."""
    entry1 = tabbedbrowser._UndoEntry(url=QUrl('https://example.org/'),
                                      history=None, index=None, pinned=None,
                                      created_at=datetime(2020, 1, 1))
    entry2 = tabbedbrowser._UndoEntry(url=QUrl('https://example.com/'),
                                      history=None, index=None, pinned=None,
                                      created_at=datetime(2020, 1, 2))
    entry3 = tabbedbrowser._UndoEntry(url=QUrl('https://example.net/'),
                                      history=None, index=None, pinned=None,
                                      created_at=datetime(2020, 1, 2))

    # Most recently closed is at the end
    tabbed_browser_stubs[0].undo_stack = [
        [entry1],
        [entry2, entry3],
    ]

    model = miscmodels.undo(info=info)
    model.set_pattern('')

    # Most recently closed is at the top, indices are used like "-x" for the
    # undo stack.
    _check_completions(model, {
        "Closed tabs": [
            ("1",
             "https://example.com/, https://example.net/",
             "2020-01-02 00:00"),
            ("2",
             "https://example.org/",
             "2020-01-01 00:00"),
        ],
    })
Esempio n. 2
0
def undo_completion_retains_sort_order(tabbed_browser_stubs, info):
    """Test :undo completion sort order with > 10 entries."""
    created_dt = datetime(2020, 1, 1)
    created_str = "2020-01-02 00:00"

    tabbed_browser_stubs[0].undo_stack = [
        tabbedbrowser._UndoEntry(
            url=QUrl(f'https://example.org/{idx}'),
            history=None, index=None, pinned=None,
            created_at=created_dt,
        )
        for idx in range(1, 11)
    ]

    model = miscmodels.undo(info=info)
    model.set_pattern('')

    expected = [
        (str(idx), f'https://example.org/{idx}', created_str)
        for idx in range(1, 11)
    ]
    _check_completions(model, {"Closed tabs": expected})