mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-10 02:45:32 +00:00
This change improves the way we detect if we're running a Gnome based UI that needs it's keyboards installed under `org.gnome.desktop.input-sources`. We use the environment variable `XDG_CURRENT_DESKTOP` and check if it contains the word `gnome`. Additionally this change renames `is_gnome_shell()` to `is_gnome_desktop()`. Fixes #11225.
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
#!/usr/bin/python3
|
|
import os
|
|
import unittest
|
|
from unittest import mock
|
|
from unittest.mock import patch
|
|
|
|
from keyman_config.gnome_keyboards_util import is_gnome_desktop, _reset_gnome_shell
|
|
|
|
|
|
class GnomeKeyboardsUtilTests(unittest.TestCase):
|
|
def setUp(self):
|
|
_reset_gnome_shell()
|
|
|
|
@patch('os.system')
|
|
@mock.patch.dict(os.environ, {'XDG_CURRENT_DESKTOP': 'ubuntu:GNOME'})
|
|
def test_IsGnomeDesktop_RunningGnomeShell(self, mockSystem):
|
|
# Setup
|
|
mockSystem.return_value = 0
|
|
# Execute/Verify
|
|
self.assertEqual(is_gnome_desktop(), True)
|
|
|
|
@patch('os.system')
|
|
@mock.patch.dict(os.environ, {'XDG_CURRENT_DESKTOP': 'X-Cinnamon'})
|
|
def test_IsGnomeDesktop_NotRunningGnomeShell(self, mockSystem):
|
|
# Setup
|
|
mockSystem.return_value = 1
|
|
# Execute/Verify
|
|
self.assertEqual(is_gnome_desktop(), False)
|
|
|
|
@patch('os.system')
|
|
@mock.patch.dict(os.environ, {'XDG_CURRENT_DESKTOP': 'budgie:GNOME'})
|
|
def test_IsGnomeDesktop_RunningBudgie(self, mockSystem):
|
|
# Setup
|
|
mockSystem.return_value = 1
|
|
# Execute/Verify
|
|
self.assertEqual(is_gnome_desktop(), True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|