From 5bc16fda30ee05142cc86b0ab8d71b185ed8afed Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 21 Mar 2018 14:16:58 +0100 Subject: tests: Use Mutter's new D-Bus interface to reset idletime Rather than poke through using XTest, use Mutter's new D-Bus API to do as if the user pressed a key on a keyboard. See https://bugzilla.gnome.org/show_bug.cgi?id=705942 https://bugzilla.gnome.org/show_bug.cgi?id=794563 --- meson.build | 1 - tests/gsdtestcase.py | 6 +++++- tests/meson.build | 11 ---------- tests/shiftkey.c | 57 ---------------------------------------------------- 4 files changed, 5 insertions(+), 70 deletions(-) delete mode 100644 tests/meson.build delete mode 100644 tests/shiftkey.c diff --git a/meson.build b/meson.build index a6e676f5..aa57f833 100644 --- a/meson.build +++ b/meson.build @@ -201,7 +201,6 @@ po_dir = join_paths(meson.source_root(), 'po') top_inc = include_directories('.') -subdir('tests') subdir('gnome-settings-daemon') subdir('data') subdir('plugins') diff --git a/tests/gsdtestcase.py b/tests/gsdtestcase.py index ffb4a2b4..fb821d38 100644 --- a/tests/gsdtestcase.py +++ b/tests/gsdtestcase.py @@ -184,6 +184,7 @@ class GSDTestCase(X11SessionTestCase): def start_mutter(klass): ''' start mutter ''' + os.environ['MUTTER_DEBUG_RESET_IDLETIME']='1' klass.mutter_log = open(os.path.join(klass.workdir, 'mutter.log'), 'wb', buffering=0) # See https://gitlab.gnome.org/GNOME/mutter/merge_requests/15 klass.mutter = subprocess.Popen(['mutter', '--x11'], @@ -204,4 +205,7 @@ class GSDTestCase(X11SessionTestCase): def reset_idle_timer(klass): '''trigger activity to reset idle timer''' - subprocess.check_call([os.path.join(top_builddir, 'tests', 'shiftkey')]) + obj_mutter_idlemonitor = klass.session_bus_con.get_object( + 'org.gnome.Mutter.IdleMonitor', '/org/gnome/Mutter/IdleMonitor/Core') + + obj_mutter_idlemonitor.ResetIdletime(dbus_interface='org.gnome.Mutter.IdleMonitor') diff --git a/tests/meson.build b/tests/meson.build deleted file mode 100644 index 1c29c48e..00000000 --- a/tests/meson.build +++ /dev/null @@ -1,11 +0,0 @@ -deps = [ - x11_dep, - xtst_dep -] - -exe = executable( - 'shiftkey', - 'shiftkey.c', - include_directories: top_inc, - dependencies: deps -) diff --git a/tests/shiftkey.c b/tests/shiftkey.c deleted file mode 100644 index cd5a1c8e..00000000 --- a/tests/shiftkey.c +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Test helper program to send a "left shift key" event via XTest, to reset the - * idle timer. - * - * Copyright (C) 2013 Canonical Ltd. - * Author: Martin Pitt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - * - */ - -#include "config.h" - -#include - -#include -#include - -int -main() -{ - Display *display = NULL; - int event_base, error_base, major_version, minor_version; - KeyCode keycode; - - display = XOpenDisplay (NULL); - - if (display == NULL) { - fputs ("Error: Cannot open display\n", stderr); - return 1; - } - - if (!XTestQueryExtension (display, &event_base, &error_base, &major_version, &minor_version)) { - fputs ("Error: No XTest extension\n", stderr); - return 1; - } - - /* send a left shift key; first press, then release */ - keycode = XKeysymToKeycode (display, XK_Shift_L); - XTestFakeKeyEvent (display, keycode, True, 0); - XTestFakeKeyEvent (display, keycode, False, 0); - - XCloseDisplay (display); - return 0; -} -- cgit v1.2.1