Index: tests/SystemQueue-tests.cc
===================================================================
--- tests/SystemQueue-tests.cc	(revision 12762)
+++ tests/SystemQueue-tests.cc	(revision 12763)
@@ -92,10 +92,17 @@
     void Check()
     {
-        // XXX
         cout << "### Check ### "<< endl;
 
         checkmark = true;
     }
-    
+
+    void Cancel()
+    {
+        cout << "### Cancel ### "<< endl;
+
+        SystemQueue::instance().cancel();
+        checkmark = true;
+    }
+
     void LongRunner()
     {
@@ -163,4 +170,51 @@
 
 /**
+ *  Enqueues an event but then cancels the SystemQueue without running
+ */
+TEST_F(SystemQueueTest, EmptyAfterCancel)
+{
+    SystemQueue& sysq = SystemQueue::instance();
+
+    EXPECT_TRUE( sysq.isEmpty() );
+    
+    // enqueue event
+    sysq.scheduleCall(
+        boost::bind(&SystemQueueTest::Check, this)
+    );
+    
+    EXPECT_FALSE( sysq.isEmpty() );
+    
+    // cancel
+    sysq.cancel();
+    
+    EXPECT_TRUE( sysq.isEmpty() );
+}
+
+
+/**
+ *  cancels the SystemQueue from inside a scheduled event
+ */
+TEST_F(SystemQueueTest, CancelFromInsideEvent)
+{
+    SystemQueue& sysq = SystemQueue::instance();
+    checkmark = false;  // just to be sure..
+    
+    // start
+    sysq.run();
+    
+    // scheduleCall
+    sysq.scheduleCall(
+        boost::bind(&SystemQueueTest::Cancel, this)
+    );
+
+    // wait for the event to happen
+    wait_for_checkmark(MAX_WAIT);
+
+    EXPECT_FALSE( sysq.isRunning() ) << "SystemQueue has not stopped properly.";
+    EXPECT_TRUE( sysq.isEmpty() ) << "SystemQueue has not stopped properly.";
+}
+
+
+/**
  *  schedule a call and test whether it is actually performed by the SystemQueue
  */
