Commit 9c46c02b authored by Guido Gunther's avatar Guido Gunther
Browse files

Merge branch 'test-shell' into 'master'

Add initial test for the shell object

See merge request Librem5/phosh!805
parents cf35b4da 7b158cae
......@@ -7,7 +7,7 @@ stages:
- package
variables:
DEPS: build-essential git wget lcov
DEPS: build-essential git wget gcovr
EXP_DEPS: libhandy-1-dev/experimental libhandy-1-0/experimental gir1.2-handy-1/experimental
WANT_BUILD_DEPS: "true"
XVFB_RUN: xvfb-run -a -s -noreset
......@@ -59,6 +59,9 @@ before_script:
- eatmydata apt-get -y install $EXP_DEPS
- '[ "$WANT_BUILD_DEPS" != "true" ] || eatmydata apt-get -y build-dep .'
- eatmydata apt-get -y install $DEPS
# Forecully drop lcov so gcovr is used
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=987818
- eatmydata dpkg --force-depends --remove lcov
- ulimit -c unlimited
.tags: &tags
......@@ -94,7 +97,7 @@ build:cross-debian-bullseye:i386:
- dpkg --add-architecture i386
- eatmydata apt-get -y update
- eatmydata apt-get -y -o APT::Immediate-Configure=false install $EXP_DEPS
- eatmydata apt-get -y -a i386 -o APT::Immediate-Configure=false build-dep .
- DEB_BUILD_PROFILES=nodoc,nocheck eatmydata apt-get -y -a i386 -o APT::Immediate-Configure=false build-dep .
- eatmydata apt-get -y install $DEPS crossbuild-essential-i386
script:
- git submodule update --recursive
......@@ -117,7 +120,7 @@ unit-test:native-debian-bullseye:
- build:native-debian-bullseye
<<: *bullseye_vars
<<: *test_step
coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
coverage: '/^lines:\s+([\d.]+\%)\s+/'
artifacts:
when: always
paths:
......@@ -218,28 +221,6 @@ unit-test:native-alpinelinux-edge:
variables:
- $PKG_ONLY == "1"
test:smoke:one-output:
<<: *tags
stage: test+docs
image: debian:bullseye
variables: *smoketest_vars
needs:
- build:native-debian-bullseye
script:
- export OUTDIR=output
- export G_DEBUG=fatal-criticals
- export WLR_X11_OUTPUTS=1
- 'echo "SMOKE_PARAMS: $SMOKE_PARAMS"'
- tests/smoke $SMOKE_PARAMS
artifacts:
paths:
- output/*.log
- output/*.png
when: always
except:
variables:
- $PKG_ONLY == "1"
test:smoke:two-outputs:
<<: *tags
stage: test+docs
......
......@@ -23,11 +23,15 @@ Build-Depends:
meson,
pandoc <!nodoc>,
# to run the tests
at-spi2-core,
gnome-themes-extra-data,
phoc,
xvfb,
xauth,
at-spi2-core <!nocheck>,
dbus-x11 <!nocheck>,
gnome-settings-daemon-common <!nocheck>,
gnome-shell-common <!nocheck>,
gnome-themes-extra-data <!nocheck>,
gsettings-desktop-schemas <!nocheck>,
phoc <!nocheck>,
xvfb <!nocheck>,
xauth <!nocheck>,
Standards-Version: 4.1.3
Homepage: https://source.puri.sm/Librem5/phosh
Rules-Requires-Root: no
......
exclude = src/dbus/
exclude = src/libphosh-tool.a.p/
exclude = src/libphosh.so.p/
exclude = tools/
......@@ -389,8 +389,8 @@ phosh_idle_manager_dispose (GObject *object)
{
PhoshIdleManager *self = PHOSH_IDLE_MANAGER (object);
g_hash_table_destroy (self->watches);
g_object_unref (self->manager);
g_clear_pointer (&self->watches, g_hash_table_destroy);
g_clear_object (&self->manager);
G_OBJECT_CLASS (phosh_idle_manager_parent_class)->dispose (object);
}
......
......@@ -13,7 +13,7 @@ phosh_resources = gnome.compile_resources(
c_name: 'phosh',
)
phosh_enum_headers = [
phosh_enum_headers = files(
'app-grid-button.h',
'gnome-shell-manager.h',
'home.h',
......@@ -25,7 +25,7 @@ phosh_enum_headers = [
'phosh-wayland.h',
'rotation-manager.h',
'shell.h',
] + schema_enum_headers
) + schema_enum_headers
phosh_enums = gnome.mkenums('phosh-enums',
h_template: 'phosh-enums.h.in',
......@@ -33,8 +33,8 @@ phosh_enums = gnome.mkenums('phosh-enums',
sources: phosh_enum_headers,
)
phosh_settings_sources = [
'settings.c',
phosh_settings_sources = files(
'settings.c') + [
phosh_settings_widgets_sources,
]
......@@ -45,7 +45,7 @@ libphosh_generated_sources = [
generated_dbus_sources,
]
libphosh_tool_sources = [
libphosh_tool_sources = files(
'activity.c',
'activity.h',
'animation.c',
......@@ -110,13 +110,14 @@ libphosh_tool_sources = [
'util.h',
'wl-buffer.c',
'wl-buffer.h',
) + [
libphosh_generated_sources,
phosh_gtk_list_models_sources,
phosh_monitor_sources,
phosh_notifications_sources,
libphosh_generated_sources,
]
libphosh_sources = [
libphosh_sources = files(
'app-auth-prompt.c',
'app-auth-prompt.h',
'arrow.c',
......@@ -201,9 +202,10 @@ libphosh_sources = [
'wifimanager.h',
'wwaninfo.c',
'wwaninfo.h',
) + [
phosh_osk_sources,
phosh_settings_sources,
phosh_wwan_sources,
phosh_osk_sources,
]
phosh_deps = [
......@@ -243,16 +245,23 @@ phosh_tool_dep = declare_dependency(sources: libphosh_generated_sources,
link_with: phosh_tool_lib,
dependencies: phosh_deps)
if get_option('gtk_doc')
# We only build the shared lib for gtk-doc:
phosh_doc_lib = library('phosh-doc', [libphosh_sources, libphosh_tool_sources], dependencies: phosh_deps)
phosh_lib = both_libraries('phosh',
libphosh_sources,
dependencies: [phosh_tool_dep, phosh_deps])
# Shared lib used by docs
phosh_doc_dep = declare_dependency(sources: libphosh_generated_sources,
include_directories: [root_inc, phosh_inc],
link_with: phosh_doc_lib,
link_with: phosh_lib,
dependencies: phosh_deps)
endif
phosh = executable('phosh', ['main.c', libphosh_sources],
dependencies: phosh_tool_dep,
# Static library used by shell and integration tests
phosh_dep = declare_dependency(
include_directories: [root_inc, phosh_inc],
link_with: phosh_lib.get_static_lib(),
dependencies: [phosh_deps, phosh_tool_dep])
phosh = executable('phosh', 'main.c',
dependencies: phosh_dep,
install: true,
install_dir: libexecdir)
......@@ -4,7 +4,8 @@ generated_osk_sources = gnome.gdbus_codegen(iface,
namespace: 'PhoshOsk0',
object_manager: true)
phosh_osk_sources = [
'osk/osk-button.c',
phosh_osk_sources = files(
'osk-button.c',
) + [
generated_osk_sources,
]
......@@ -64,27 +64,27 @@ static void auth_request_complete (AuthRequest *request, gboolean dismissed);
static gboolean
agent_register (PhoshPolkitAuthAgent *self)
{
GError *err = NULL;
g_autoptr(PolkitSubject) subject;
g_autoptr (GError) err = NULL;
g_autoptr (PolkitSubject) subject;
subject = polkit_unix_session_new_for_process_sync (getpid (),
NULL, /* GCancellable* */
&err);
if (subject == NULL) {
g_warning("PolKit failed to properly get our session");
g_warning ("PolKit failed to properly get our session");
return FALSE;
}
/* FIXME: this blocks so we should do it async */
self->handle = polkit_agent_listener_register (POLKIT_AGENT_LISTENER (self),
POLKIT_AGENT_REGISTER_FLAGS_NONE,
subject,
NULL, /* use default object path */
NULL, /* GCancellable */
&err);
POLKIT_AGENT_REGISTER_FLAGS_NONE,
subject,
NULL, /* use default object path */
NULL, /* GCancellable */
&err);
if (!self->handle) {
g_warning("Auth agent failed to register: %s", err->message);
g_warning ("Auth agent failed to register: %s", err->message);
return FALSE;
}
......@@ -188,8 +188,8 @@ static void
maybe_process_next_request (PhoshPolkitAuthAgent *self)
{
auth_debug ("cur=%p len(scheduled)=%d",
self->current_request,
g_list_length (self->scheduled_requests));
self->current_request,
g_list_length (self->scheduled_requests));
if (self->current_request == NULL && self->scheduled_requests != NULL) {
AuthRequest *request;
......@@ -212,7 +212,7 @@ auth_request_complete (AuthRequest *request, gboolean dismissed)
gboolean is_current = self->current_request == request;
auth_debug ("completing %s %s cookie %s", is_current ? "current" : "scheduled",
request->action_id, request->cookie);
request->action_id, request->cookie);
if (!is_current)
self->scheduled_requests = g_list_remove (self->scheduled_requests, request);
......
phosh_settings_widgets_sources = [
'settings/brightness.c',
'settings/gvc-channel-bar.c',
]
phosh_settings_widgets_sources = files(
'brightness.c',
'gvc-channel-bar.c',
)
......@@ -75,6 +75,7 @@ on_name_lost (GDBusConnection *connection,
if (connection == NULL) {
g_warning ("couldn't connect to session bus");
phosh_system_prompter_unregister ();
registered_prompter = FALSE;
}
}
......@@ -113,8 +114,11 @@ void
phosh_system_prompter_unregister(void)
{
if (_prompter) {
gcr_system_prompter_unregister (_prompter, TRUE);
_prompter = NULL;
if (registered_prompter) {
gcr_system_prompter_unregister (_prompter, TRUE);
registered_prompter = FALSE;
}
g_clear_object (&_prompter);
}
if (acquired_prompter) {
......
......@@ -17,12 +17,13 @@ generated_wwan_sources = [
)
]
phosh_wwan_sources = [
'wwan/phosh-wwan-ofono.c',
'wwan/phosh-wwan-ofono.h',
'wwan/phosh-wwan-mm.c',
'wwan/phosh-wwan-mm.h',
'wwan/phosh-wwan-iface.c',
'wwan/phosh-wwan-iface.h',
phosh_wwan_sources = files(
'phosh-wwan-ofono.c',
'phosh-wwan-ofono.h',
'phosh-wwan-mm.c',
'phosh-wwan-mm.h',
'phosh-wwan-iface.c',
'phosh-wwan-iface.h',
) + [
generated_wwan_sources,
]
......@@ -100,7 +100,7 @@ if run_phoc_tests
# Make sure this is valid when running the compositor
test_env_phoc.set('XDG_RUNTIME_DIR', meson.current_build_dir())
# Unit tests
# Unit tests
foreach test : tests_phoc
t = executable('test-@0@'.format(test),
test_stub_deps + ['test-@0@.c'.format(test)],
......@@ -110,9 +110,19 @@ if run_phoc_tests
dependencies: testlib_dep)
test(test, t, env: test_env_phoc)
endforeach
# Integration tests using the full libphosh
t = executable('test-shell',
'test-shell.c',
c_args: test_cflags,
pie: true,
link_args: test_link_args,
dependencies: [phosh_tool_dep, phosh_dep, testlib_dep])
test('shell', t, env: test_env_phoc)
endif
# Integration tests
# Integration tests that aren't yet run by default:
t = executable('test-idle-manager',
['test-idle-manager.c', generated_dbus_sources],
c_args: test_cflags,
......
......@@ -131,9 +131,6 @@ test_phosh_app_grid_button_set_invalid_mode (void)
NULL);
GtkWidget *btn = phosh_app_grid_button_new (info);
g_test_expect_message ("phosh-app-grid-button",
G_LOG_LEVEL_CRITICAL,
"Invalid mode*");
/* Boom */
phosh_app_grid_button_set_mode (PHOSH_APP_GRID_BUTTON (btn),
G_MAXINT);
......
/*
* Copyright (C) 2021 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Author: Guido Günther <agx@sigxcpu.org>
*/
#include "testlib.h"
#include "log.h"
#include "shell.h"
#include "phosh-wayland.h"
#include <glib.h>
#include <handy.h>
typedef struct _Fixture {
PhoshTestCompositorState *state;
} Fixture;
static void
compositor_setup (Fixture *fixture, gconstpointer unused)
{
fixture->state = phosh_test_compositor_new ();
g_assert_nonnull (fixture->state);
}
static void
compositor_teardown (Fixture *fixture, gconstpointer unused)
{
phosh_test_compositor_free (fixture->state);
}
static gboolean
on_idle (gpointer data)
{
gtk_main_quit ();
*(gboolean*)data = TRUE;
return G_SOURCE_REMOVE;
}
static void
test_shell_new (Fixture *fixture, gconstpointer unused)
{
PhoshShell *shell = NULL;
GLogLevelFlags flags;
gboolean success;
gtk_init (NULL, NULL);
hdy_init ();
phosh_log_set_log_domains ("all");
/* Drop warnings from the fatal log mask since there's plenty
* when running without recommended DBus services */
flags = g_log_set_always_fatal (0);
g_log_set_always_fatal(flags & ~G_LOG_LEVEL_WARNING);
shell = phosh_shell_get_default ();
g_assert_true (PHOSH_IS_SHELL (shell));
g_assert_false (phosh_shell_get_locked (shell));
g_assert_false (phosh_shell_is_startup_finished (shell));
g_assert_true (PHOSH_IS_MONITOR (phosh_shell_get_primary_monitor (shell)));
g_idle_add (on_idle, &success);
gtk_main ();
g_log_set_always_fatal (flags);
g_assert_true (success);
g_object_unref (shell);
}
int
main (int argc,
char *argv[])
{
g_test_init (&argc, &argv, NULL);
g_test_add ("/phosh/shell/new", Fixture, NULL,
compositor_setup, test_shell_new, compositor_teardown);
return g_test_run ();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment