From e3cec790e72af21793fada09b1554f76c195121d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 30 Jan 2015 08:57:03 -0600 Subject: Track output mode --- src/service.vala | 8 ++++++++ src/volume-control.vala | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/service.vala b/src/service.vala index fb56215..ba77ae8 100644 --- a/src/service.vala +++ b/src/service.vala @@ -270,6 +270,7 @@ public class IndicatorSound.Service: Object { private bool check_sync_notification = false; private bool support_sync_notification = false; + private string last_output_notification = "multimedia"; void update_sync_notification () { if (!check_sync_notification) { @@ -283,6 +284,13 @@ public class IndicatorSound.Service: Object { if (!support_sync_notification) return; + /* Suppress notifications of volume changes if it is because the + output stream changed. */ + var oldoutput = this.last_output_notification; + this.last_output_notification = this.volume_control.stream; + if (oldoutput != this.last_output_notification) + return; + var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; if (shown_action != null && shown_action.get_state().get_boolean()) return; diff --git a/src/volume-control.vala b/src/volume-control.vala index bf97021..62cb2d0 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -54,6 +54,14 @@ public class VolumeControl : Object private bool _pulse_use_stream_restore = false; private uint32 _active_sink_input = -1; private string[] _valid_roles = {"multimedia", "alert", "alarm", "phone"}; + public string stream { + get { + if (_active_sink_input < 0 || _active_sink_input >= _valid_roles.length) + return "multimedia"; + else + return _valid_roles[_active_sink_input]; + } + } private string? _objp_role_multimedia = null; private string? _objp_role_alert = null; private string? _objp_role_alarm = null; -- cgit v1.2.3 From 6feea025512a572179b041bd5c02d44b1f57adce Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 2 Feb 2015 17:03:16 -0600 Subject: Watch for double updates from notifications. Supress them --- src/service.vala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/service.vala b/src/service.vala index ba77ae8..da6b824 100644 --- a/src/service.vala +++ b/src/service.vala @@ -271,6 +271,7 @@ public class IndicatorSound.Service: Object { private bool check_sync_notification = false; private bool support_sync_notification = false; private string last_output_notification = "multimedia"; + private string last_volume_notification = 0; void update_sync_notification () { if (!check_sync_notification) { @@ -291,6 +292,12 @@ public class IndicatorSound.Service: Object { if (oldoutput != this.last_output_notification) return; + /* Supress updates that don't change the value */ + var oldvolume = this.last_volume_notification; + this.last_volume_notification = volume_control.volume; + if (oldvolume == this.last_volume_notification) + return; + var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; if (shown_action != null && shown_action.get_state().get_boolean()) return; -- cgit v1.2.3 From 47e8a6dbd878ed69aebc7a268b9d74e9dde014f6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 3 Feb 2015 08:24:44 -0600 Subject: Incorrect type --- src/service.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service.vala b/src/service.vala index da6b824..22cb1c6 100644 --- a/src/service.vala +++ b/src/service.vala @@ -271,7 +271,7 @@ public class IndicatorSound.Service: Object { private bool check_sync_notification = false; private bool support_sync_notification = false; private string last_output_notification = "multimedia"; - private string last_volume_notification = 0; + private double last_volume_notification = 0; void update_sync_notification () { if (!check_sync_notification) { -- cgit v1.2.3 From 8838bd8e4e95f1da3bcc85324e924e782a434c4e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Feb 2015 08:29:43 -0600 Subject: Make the testing verbose --- debian/rules | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/rules b/debian/rules index 8fb0f91..8ef6c72 100755 --- a/debian/rules +++ b/debian/rules @@ -17,3 +17,5 @@ override_dh_install: install -m 644 debian/indicator-sound-crashdb.conf debian/indicator-sound/etc/apport/crashdb.conf.d/ dh_install --fail-missing +override_dh_auto_test: + ARGS=-V dh_auto_test -- cgit v1.2.3 From 363a5d1ae24d58d294d8806930cf788879a6f73a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Feb 2015 11:43:08 -0600 Subject: Compile GSettings schema and use the memory backend --- tests/CMakeLists.txt | 22 ++++++++++++++++++++++ tests/indicator-test.cc | 8 +++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc2df0d..d9bfe0b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,6 +10,28 @@ add_library (gtest STATIC ${GTEST_SOURCE_DIR}/gtest_main.cc) target_link_libraries(gtest ${GTEST_LIBS}) +########################### +# GSettings Schema +########################### + +# build the necessary schemas +set_directory_properties (PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES gschemas.compiled) +set_source_files_properties (gschemas.compiled GENERATED) + +# GSettings: +# compile the indicator-sound schema into a gschemas.compiled file in this directory, +# and help the tests to find that file by setting -DSCHEMA_DIR +set (SCHEMA_DIR ${CMAKE_CURRENT_BINARY_DIR}) +add_definitions(-DSCHEMA_DIR="${SCHEMA_DIR}") +execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas + OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE + OUTPUT_STRIP_TRAILING_WHITESPACE) +add_custom_command (OUTPUT gschemas.compiled + DEPENDS ${CMAKE_BINARY_DIR}/data/com.canonical.indicator.sound.gschema.xml + COMMAND cp -f ${CMAKE_BINARY_DIR}/data/*gschema.xml ${SCHEMA_DIR} + COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${SCHEMA_DIR}) + ########################### # Vala Mocks ########################### diff --git a/tests/indicator-test.cc b/tests/indicator-test.cc index 31494d4..636db1d 100644 --- a/tests/indicator-test.cc +++ b/tests/indicator-test.cc @@ -39,6 +39,9 @@ protected: //addMock(buildBustleMock("indicator-test-system.bustle", DBUS_TEST_SERVICE_BUS_SYSTEM)); g_setenv("LD_PRELOAD", PA_MOCK_LIB, TRUE); + g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE); + g_setenv("GSETTINGS_BACKEND", "memory", TRUE); + as = std::make_shared(); addMock(*as); @@ -81,8 +84,8 @@ TEST_F(IndicatorTest, DesktopMenu) { EXPECT_MENU_ATTRIB(std::vector({0, 0, 0}), "action", "indicator.mute"); EXPECT_MENU_ATTRIB(std::vector({0, 0, 0}), "label", "Mute"); - EXPECT_MENU_ATTRIB(std::vector({0, 2}), "action", "indicator.desktop-settings"); - EXPECT_MENU_ATTRIB(std::vector({0, 2}), "label", "Sound Settingsā€¦"); + EXPECT_MENU_ATTRIB(std::vector({0, 1}), "action", "indicator.desktop-settings"); + EXPECT_MENU_ATTRIB(std::vector({0, 1}), "label", "Sound Settingsā€¦"); } TEST_F(IndicatorTest, BaseActions) { @@ -99,7 +102,6 @@ TEST_F(IndicatorTest, BaseActions) { ASSERT_ACTION_EXISTS("mute"); ASSERT_ACTION_STATE_TYPE("mute", G_VARIANT_TYPE_BOOLEAN); - EXPECT_ACTION_STATE("mute", false); ASSERT_ACTION_EXISTS("mic-volume"); ASSERT_ACTION_STATE_TYPE("mic-volume", G_VARIANT_TYPE_DOUBLE); -- cgit v1.2.3 From 23bdec1dd9169e8dda04ec0587db909472acc6c1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Feb 2015 13:36:53 -0600 Subject: Set build dependencies to compile the schemas --- tests/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d9bfe0b..38a76ae 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,14 +22,15 @@ set_source_files_properties (gschemas.compiled GENERATED) # GSettings: # compile the indicator-sound schema into a gschemas.compiled file in this directory, # and help the tests to find that file by setting -DSCHEMA_DIR -set (SCHEMA_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set (SCHEMA_DIR "${CMAKE_CURRENT_BINARY_DIR}/gsettings-schemas") add_definitions(-DSCHEMA_DIR="${SCHEMA_DIR}") execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_command (OUTPUT gschemas.compiled - DEPENDS ${CMAKE_BINARY_DIR}/data/com.canonical.indicator.sound.gschema.xml - COMMAND cp -f ${CMAKE_BINARY_DIR}/data/*gschema.xml ${SCHEMA_DIR} + DEPENDS ${CMAKE_SOURCE_DIR}/data/com.canonical.indicator.sound.gschema.xml + COMMAND mkdir -p ${SCHEMA_DIR} + COMMAND cp -f ${CMAKE_SOURCE_DIR}/data/*gschema.xml ${SCHEMA_DIR} COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${SCHEMA_DIR}) ########################### @@ -239,7 +240,7 @@ add_definitions( -DINDICATOR_SOUND_SERVICE_BINARY="${CMAKE_BINARY_DIR}/src/indicator-sound-service" -DPA_MOCK_LIB="${CMAKE_CURRENT_BINARY_DIR}/libpulse-mock.so" ) -add_executable (indicator-test indicator-test.cc) +add_executable (indicator-test indicator-test.cc gschemas.compiled) target_link_libraries ( indicator-test gtest -- cgit v1.2.3 From 34f0c7f82246fb16be2e3de0e1bee68dd31c83a6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Feb 2015 14:25:00 -0600 Subject: Make sure that we have the com.ubuntu.sound settings --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 15b47f1..cdb1267 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 9.0), dh-translations, gir1.2-accountsservice-1.0, gnome-common, + gsettings-ubuntu-schemas, autotools-dev, valac (>= 0.20), libaccountsservice-dev, -- cgit v1.2.3 From ed66db9f090b5f98338e1a47103b0106cc02d980 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 4 Feb 2015 14:43:51 -0600 Subject: Stop overriding in the rules --- debian/rules | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index 8ef6c72..7e4e4ef 100755 --- a/debian/rules +++ b/debian/rules @@ -17,5 +17,6 @@ override_dh_install: install -m 644 debian/indicator-sound-crashdb.conf debian/indicator-sound/etc/apport/crashdb.conf.d/ dh_install --fail-missing -override_dh_auto_test: - ARGS=-V dh_auto_test +# For live test logs: +#override_dh_auto_test: +# ARGS=-V dh_auto_test -- cgit v1.2.3 From 85b5b397ae74fd08d66e89ee3ee132520ccb1d0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Feb 2015 08:50:31 -0600 Subject: Making sure to record the output and volume for each invocation --- src/service.vala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/service.vala b/src/service.vala index 22cb1c6..c942fc7 100644 --- a/src/service.vala +++ b/src/service.vala @@ -285,16 +285,18 @@ public class IndicatorSound.Service: Object { if (!support_sync_notification) return; - /* Suppress notifications of volume changes if it is because the - output stream changed. */ + /* Update our volume and output */ var oldoutput = this.last_output_notification; this.last_output_notification = this.volume_control.stream; - if (oldoutput != this.last_output_notification) - return; - /* Supress updates that don't change the value */ var oldvolume = this.last_volume_notification; this.last_volume_notification = volume_control.volume; + + /* Suppress notifications of volume changes if it is because the + output stream changed. */ + if (oldoutput != this.last_output_notification) + return; + /* Supress updates that don't change the value */ if (oldvolume == this.last_volume_notification) return; -- cgit v1.2.3 From c6002f571882de3b7bf3d3a6a2045272d818b4db Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 5 Feb 2015 08:52:58 -0600 Subject: Compare doubles with an accuracy range --- src/service.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service.vala b/src/service.vala index c942fc7..b07f267 100644 --- a/src/service.vala +++ b/src/service.vala @@ -297,7 +297,7 @@ public class IndicatorSound.Service: Object { if (oldoutput != this.last_output_notification) return; /* Supress updates that don't change the value */ - if (oldvolume == this.last_volume_notification) + if (GLib.Math.fabs(oldvolume - this.last_volume_notification) < 0.01) return; var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; -- cgit v1.2.3 From 1b0c78a1bd4237a920a569a64efe6bd006e4a9ca Mon Sep 17 00:00:00 2001 From: CI Train Bot Date: Thu, 5 Feb 2015 17:19:42 +0000 Subject: Releasing 12.10.2+15.04.20150205-0ubuntu1 --- debian/changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index aad0867..718e4e4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +indicator-sound (12.10.2+15.04.20150205-0ubuntu1) vivid; urgency=medium + + [ Ted Gould ] + * Don't show notification when output mode changes (LP: #1416233) + * Initial support for indicator service testing from the GMenu/GAction + interfaces + + -- Ubuntu daily release Thu, 05 Feb 2015 17:19:42 +0000 + indicator-sound (12.10.2+15.04.20150129.1-0ubuntu1) vivid; urgency=low [ Ted Gould ] -- cgit v1.2.3