# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# Copyright 2016 Continuum Analytics, Inc.
#
# May be copied and distributed freely only as part of an Anaconda or
# Miniconda installation.
# -----------------------------------------------------------------------------
"""
Tests the about dialog.
"""

# Third party imports
from qtpy.QtCore import Qt  # analysis:ignore
import pytest
import pytestqt.qtbot as qtbot  # analysis:ignore

# Local imports
from anaconda_navigator.utils.fixtures import tmpconfig
from anaconda_navigator.widgets.dialogs.about import AboutDialog


@pytest.fixture()
def aboutdialog(qtbot):
    widget = AboutDialog()
    widget.show()
    qtbot.addWidget(widget)
    return qtbot, widget


class TestAboutDialog:
    def test_ok(self, aboutdialog):
        qtbot, widget = aboutdialog
        with qtbot.waitSignal(widget.accepted, 1000, True):
            qtbot.mouseClick(widget.button_ok, Qt.LeftButton)

    def test_url(self, aboutdialog):
        qtbot, widget = aboutdialog
        with qtbot.waitSignal(
            signal=widget.sig_url_clicked, timeout=1000, raising=True
        ):
            qtbot.mouseClick(widget.button_link, Qt.LeftButton)
