Index: /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard.h	(revision 37454)
+++ /trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard.h	(revision 37455)
@@ -74,4 +74,5 @@
 void vboxSvcClipboardCompleteReadData(VBOXCLIPBOARDCLIENTDATA *pClient, int rc, uint32_t cbActual);
 
+bool vboxSvcClipboardGetHeadless(void);
 
 /*
@@ -92,3 +93,8 @@
 int vboxClipboardSync (VBOXCLIPBOARDCLIENTDATA *pClient);
 
+/* Host unit testing interface */
+#ifdef UNIT_TEST
+uint32_t testClipSvcGetMode(void);
+#endif
+
 #endif /* __VBOXCLIPBOARD__H */
Index: /trunk/src/VBox/HostServices/SharedClipboard/service.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/service.cpp	(revision 37454)
+++ /trunk/src/VBox/HostServices/SharedClipboard/service.cpp	(revision 37455)
@@ -134,7 +134,24 @@
 static uint32_t g_u32DelayedFormats = 0;
 
+/** Is the clipboard running in headless mode? */
+static bool g_fHeadless = false;
+
 static uint32_t vboxSvcClipboardMode (void)
 {
     return g_u32Mode;
+}
+
+#ifdef UNIT_TEST
+/** Testing interface, getter for clipboard mode */
+uint32_t testClipSvcGetMode(void)
+{
+    return vboxSvcClipboardMode();
+}
+#endif
+
+/** Getter for headless setting */
+bool vboxSvcClipboardGetHeadless(void)
+{
+    return g_fHeadless;
 }
 
@@ -706,4 +723,16 @@
         } break;
 
+        case VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS:
+        {
+            uint32_t u32Headless = g_fHeadless;
+            LogRel2(("svcCall: VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE\n"));
+
+            rc = VERR_INVALID_PARAMETER;
+            if (cParms != 1)
+                break;
+            rc = VBoxHGCMParmUInt32Get (&paParms[0], &u32Headless);
+            g_fHeadless = RT_BOOL(u32Headless);
+        } break;
+
         default:
             break;
Index: /trunk/src/VBox/HostServices/SharedClipboard/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/testcase/Makefile.kmk	(revision 37454)
+++ /trunk/src/VBox/HostServices/SharedClipboard/testcase/Makefile.kmk	(revision 37455)
@@ -26,5 +26,5 @@
 
  tstClipboardServiceHost_TEMPLATE = VBOXR3TSTEXE
- tstClipboardServiceHost_DEFS     = VBOX_WITH_HGCM
+ tstClipboardServiceHost_DEFS     = VBOX_WITH_HGCM UNIT_TEST
  tstClipboardServiceHost_SOURCES  = \
 	../service.cpp \
Index: /trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp	(revision 37454)
+++ /trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp	(revision 37455)
@@ -36,36 +36,93 @@
 }
 
-static struct
+static void testSetMode(void)
 {
-    uint32_t cParms;
-    uint32_t type1;
-    uint32_t val1;
-    int rcExp;
-} s_testHostFnSetMode[] =
+    struct VBOXHGCMSVCPARM parms[2];
+    VBOXHGCMSVCFNTABLE table;
+    uint32_t u32Mode;
+    int rc;
+    
+    RTTestISub("Testing HOST_FN_SET_MODE");
+    rc = setupTable(&table);
+    RTTESTI_CHECK_MSG_RETV(RT_SUCCESS(rc), ("rc=%Rrc\n", rc));
+    /* Reset global variable which doesn't reset itself. */
+    parms[0].setUInt32(VBOX_SHARED_CLIPBOARD_MODE_OFF);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE,
+                           1, parms);
+    RTTESTI_CHECK_RC_OK(rc);
+    u32Mode = testClipSvcGetMode();
+    RTTESTI_CHECK_MSG(u32Mode == VBOX_SHARED_CLIPBOARD_MODE_OFF,
+                      ("u32Mode=%u\n", (unsigned) u32Mode));
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE,
+                           0, parms);
+    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE,
+                           2, parms);
+    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
+    parms[0].setUInt64(99);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE,
+                           1, parms);
+    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
+    parms[0].setUInt32(VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE,
+                           1, parms);
+    RTTESTI_CHECK_RC_OK(rc);
+    u32Mode = testClipSvcGetMode();
+    RTTESTI_CHECK_MSG(u32Mode == VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST,
+                      ("u32Mode=%u\n", (unsigned) u32Mode));
+    parms[0].setUInt32(99);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE,
+                           1, parms);
+    RTTESTI_CHECK_RC_OK(rc);
+    u32Mode = testClipSvcGetMode();
+    RTTESTI_CHECK_MSG(u32Mode == VBOX_SHARED_CLIPBOARD_MODE_OFF,
+                      ("u32Mode=%u\n", (unsigned) u32Mode));
+}
+
+static void testSetHeadless(void)
 {
-    { 0, VBOX_HGCM_SVC_PARM_32BIT, 99, VERR_INVALID_PARAMETER },
-    { 2, VBOX_HGCM_SVC_PARM_32BIT, 99, VERR_INVALID_PARAMETER },
-    { 1, VBOX_HGCM_SVC_PARM_64BIT, 99, VERR_INVALID_PARAMETER },
-    { 1, VBOX_HGCM_SVC_PARM_32BIT, 99, VINF_SUCCESS }
-};
+    struct VBOXHGCMSVCPARM parms[2];
+    VBOXHGCMSVCFNTABLE table;
+    bool fHeadless;
+    int rc;
+    
+    RTTestISub("Testing HOST_FN_SET_HEADLESS");
+    rc = setupTable(&table);
+    RTTESTI_CHECK_MSG_RETV(RT_SUCCESS(rc), ("rc=%Rrc\n", rc));
+    /* Reset global variable which doesn't reset itself. */
+    parms[0].setUInt32(false);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS,
+                           1, parms);
+    RTTESTI_CHECK_RC_OK(rc);
+    fHeadless = vboxSvcClipboardGetHeadless();
+    RTTESTI_CHECK_MSG(fHeadless == false, ("fHeadless=%RTbool\n", fHeadless));
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS,
+                           0, parms);
+    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS,
+                           2, parms);
+    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
+    parms[0].setUInt64(99);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS,
+                           1, parms);
+    RTTESTI_CHECK_RC(rc, VERR_INVALID_PARAMETER);
+    parms[0].setUInt32(true);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS,
+                           1, parms);
+    RTTESTI_CHECK_RC_OK(rc);
+    fHeadless = vboxSvcClipboardGetHeadless();
+    RTTESTI_CHECK_MSG(fHeadless == true, ("fHeadless=%RTbool\n", fHeadless));
+    parms[0].setUInt32(99);
+    rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_HEADLESS,
+                           1, parms);
+    RTTESTI_CHECK_RC_OK(rc);
+    fHeadless = vboxSvcClipboardGetHeadless();
+    RTTESTI_CHECK_MSG(fHeadless == true, ("fHeadless=%RTbool\n", fHeadless));
+}
 
-static void testHostCall(RTTEST hTest)
+static void testHostCall(void)
 {
-    VBOXHGCMSVCFNTABLE table;
-
-    RTTestSub(hTest, "Testing HOST_FN_SET_MODE");
-    for (unsigned i = 0; i < RT_ELEMENTS(s_testHostFnSetMode); ++i)
-    {
-        struct VBOXHGCMSVCPARM parms[2];
-
-        int rc = setupTable(&table);
-        RTTESTI_CHECK_MSG_RETV(RT_SUCCESS(rc), ("i=%u, rc=%Rrc\n", i, rc));
-        parms[0].type = s_testHostFnSetMode[i].type1;
-        parms[0].u.uint32 = s_testHostFnSetMode[i].val1;
-        rc = table.pfnHostCall(NULL, VBOX_SHARED_CLIPBOARD_HOST_FN_SET_MODE,
-                               s_testHostFnSetMode[i].cParms, parms);
-        RTTESTI_CHECK_MSG(rc == s_testHostFnSetMode[i].rcExp,
-                          ("i=%u, rc=%Rrc\n", i, rc));
-    }
+    testSetMode();
+    testSetHeadless();
 }
 
@@ -89,5 +146,5 @@
      * Run the tests.
      */
-    testHostCall(hTest);
+    testHostCall();
 
     /*
