emmental/tests/test_buttons.py
Anna Schumaker 6ede296ba6 buttons: Create a PopoverButton
This is a MenuButton that already has a popover attached and a property
for setting the popover child directly.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2023-04-12 10:41:42 -04:00

35 lines
1.2 KiB
Python

# Copyright 2022 (c) Anna Schumaker.
"""Test our button helper classes."""
import unittest
import emmental.buttons
from gi.repository import Gtk
class TestPopoverButton(unittest.TestCase):
"""Test a Popover Button."""
def setUp(self):
"""Set up common variables."""
self.button = emmental.buttons.PopoverButton()
def test_button(self):
"""Test that the popover button is configured correctly."""
self.assertIsInstance(self.button, Gtk.MenuButton)
self.assertIsInstance(self.button.get_popover(), Gtk.Popover)
def test_popover_child(self):
"""Test setting a child widget to the popover button."""
self.assertIsNone(self.button.popover_child)
self.button.popover_child = Gtk.Label()
self.assertEqual(self.button.get_popover().get_child(),
self.button.popover_child)
button2 = emmental.buttons.PopoverButton(popover_child=Gtk.Label())
self.assertIsInstance(button2.popover_child, Gtk.Label)
self.assertEqual(button2.get_popover().get_child(),
button2.popover_child)
def test_popdown(self):
"""Test the popdown() function."""
self.button.popdown()