[libcamera-devel,13/14] test: signal: Test connecting to non-void slots

Message ID 20200104050947.7673-14-laurent.pinchart@ideasonboard.com
State Accepted
Commit 94f62f6b590857e9bcee379aec8e818625aebdf8
Headers show
Series
  • object: Propagate return value of invoked method
Related show

Commit Message

Laurent Pinchart Jan. 4, 2020, 5:09 a.m. UTC
Test that a signal can be connected to non-void static and member slots.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 test/signal.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Niklas Söderlund Jan. 7, 2020, 7:22 p.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2020-01-04 07:09:46 +0200, Laurent Pinchart wrote:
> Test that a signal can be connected to non-void static and member slots.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  test/signal.cpp | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/test/signal.cpp b/test/signal.cpp
> index 9d8f985d15e5..0054ed5a380d 100644
> --- a/test/signal.cpp
> +++ b/test/signal.cpp
> @@ -23,6 +23,11 @@ static void slotStatic(int value)
>  	valueStatic_ = value;
>  }
>  
> +static int slotStaticReturn()
> +{
> +	return 0;
> +}
> +
>  class SlotObject : public Object
>  {
>  public:
> @@ -85,6 +90,11 @@ protected:
>  		name_ = name;
>  	}
>  
> +	int slotReturn()
> +	{
> +		return 0;
> +	}
> +
>  	int init()
>  	{
>  		return 0;
> @@ -174,6 +184,13 @@ protected:
>  			return TestFail;
>  		}
>  
> +		/*
> +		 * Test connecting to slots that return a value. This targets
> +		 * compilation, there's no need to check runtime results.
> +		 */
> +		signalVoid_.connect(slotStaticReturn);
> +		signalVoid_.connect(this, &SignalTest::slotReturn);
> +
>  		/* ----------------- Signal -> Object tests ----------------- */
>  
>  		/*
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/test/signal.cpp b/test/signal.cpp
index 9d8f985d15e5..0054ed5a380d 100644
--- a/test/signal.cpp
+++ b/test/signal.cpp
@@ -23,6 +23,11 @@  static void slotStatic(int value)
 	valueStatic_ = value;
 }
 
+static int slotStaticReturn()
+{
+	return 0;
+}
+
 class SlotObject : public Object
 {
 public:
@@ -85,6 +90,11 @@  protected:
 		name_ = name;
 	}
 
+	int slotReturn()
+	{
+		return 0;
+	}
+
 	int init()
 	{
 		return 0;
@@ -174,6 +184,13 @@  protected:
 			return TestFail;
 		}
 
+		/*
+		 * Test connecting to slots that return a value. This targets
+		 * compilation, there's no need to check runtime results.
+		 */
+		signalVoid_.connect(slotStaticReturn);
+		signalVoid_.connect(this, &SignalTest::slotReturn);
+
 		/* ----------------- Signal -> Object tests ----------------- */
 
 		/*