tests: Checked VALIDATION_APK for create surface

In not VALIDATION_APK situation, it cannot get Android window
successfully, so it cannot create Android VkSurface. In this
case, skip VkAcquireNextImageInfoKHR test.

Change-Id: I1d10bd80276716985c21373e9864c242739c2846
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 9fb6996..4c185d2 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -14515,46 +14515,46 @@
     TEST_DESCRIPTION("Invalid deviceMask.");
     SetTargetApiVersion(VK_API_VERSION_1_1);
 
-    if (InstanceExtensionSupported(VK_KHR_SURFACE_EXTENSION_NAME)) {
-        m_instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
-    } else {
-        printf("%s KHR surface extension not supported, skipping test\n", kSkipPrefix);
-        return;
-    }
     bool support_surface = false;
 #ifdef VK_USE_PLATFORM_WIN32_KHR
     if (InstanceExtensionSupported(VK_KHR_WIN32_SURFACE_EXTENSION_NAME)) {
         m_instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
+        support_surface = true;
     } else {
-        printf("%s KHR win32 surface extension not supported, skipping test\n", kSkipPrefix);
-        return;
+        printf("%s VK_KHR_WIN32_SURFACE_EXTENSION_NAME extension not supported, skipping VkAcquireNextImageInfoKHR test\n",
+               kSkipPrefix);
     }
-    support_surface = true;
 #elif VK_USE_PLATFORM_XLIB_KHR
     if (InstanceExtensionSupported(VK_KHR_XLIB_SURFACE_EXTENSION_NAME)) {
         m_instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
+        support_surface = true;
     } else {
-        printf("%s KHR xlib surface extension not supported, skipping test\n", kSkipPrefix);
-        return;
+        printf("%s VK_KHR_XLIB_SURFACE_EXTENSION_NAME extension not supported, skipping VkAcquireNextImageInfoKHR test\n",
+               kSkipPrefix);
     }
-    support_surface = true;
-#elif VK_USE_PLATFORM_ANDROID_KHR
+#elif defined(VK_USE_PLATFORM_ANDROID_KHR) && defined(VALIDATION_APK)
     if (InstanceExtensionSupported(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME)) {
         m_instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
+        support_surface = true;
     } else {
-        printf("%s KHR xlib surface extension not supported, skipping test\n", kSkipPrefix);
-        return;
+        printf("%s VK_KHR_ANDROID_SURFACE_EXTENSION_NAME extension not supported, skipping VkAcquireNextImageInfoKHR test\n",
+               kSkipPrefix);
     }
-    support_surface = true;
+#else
+    printf("%s VkSurface not supported, skipping VkAcquireNextImageInfoKHR test\n", kSkipPrefix);
 #endif
+
+    if (support_surface) {
+        if (InstanceExtensionSupported(VK_KHR_SURFACE_EXTENSION_NAME)) {
+            m_instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
+        } else {
+            printf("%s VK_KHR_SURFACE_EXTENSION_NAM extension not supported, skipping VkAcquireNextImageInfoKHR test\n",
+                   kSkipPrefix);
+            support_surface = false;
+        }
+    }
     ASSERT_NO_FATAL_FAILURE(InitFramework(myDbgFunc, m_errorMonitor));
 
-    if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SWAPCHAIN_EXTENSION_NAME)) {
-        m_device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
-    } else {
-        printf("%s KHR swapchain extension not supported, skipping test\n", kSkipPrefix);
-        return;
-    }
     if (DeviceValidationVersion() < VK_API_VERSION_1_1) {
         printf("%s Device Groups requires Vulkan 1.1+, skipping test\n", kSkipPrefix);
         return;
@@ -14567,6 +14567,16 @@
         return;
     }
 
+    if (support_surface) {
+        if (DeviceExtensionSupported(gpu(), nullptr, VK_KHR_SWAPCHAIN_EXTENSION_NAME)) {
+            m_device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
+        } else {
+            printf("%s VK_KHR_SWAPCHAIN_EXTENSION_NAME extension not supported, skipping VkAcquireNextImageInfoKHR test\n",
+                   kSkipPrefix);
+            support_surface = false;
+        }
+    }
+
     std::vector<VkPhysicalDeviceGroupProperties> physical_device_group(physical_device_group_count,
                                                                        {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES});
     vkEnumeratePhysicalDeviceGroups(instance(), &physical_device_group_count, physical_device_group.data());
diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp
index 5ceb192..5724308 100644
--- a/tests/vkrenderframework.cpp
+++ b/tests/vkrenderframework.cpp
@@ -472,7 +472,7 @@
 
 void VkRenderFramework::InitViewport() { InitViewport(m_width, m_height); }
 
-bool VkRenderFramework::InitSwapchain() { return InitSwapchain(m_width, m_height); }
+void VkRenderFramework::InitSwapchain() { InitSwapchain(m_width, m_height); }
 
 #ifdef VK_USE_PLATFORM_WIN32_KHR
 LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
@@ -480,7 +480,9 @@
 }
 #endif  // VK_USE_PLATFORM_WIN32_KHR
 
-bool VkRenderFramework::InitSwapchain(float width, float height) {
+void VkRenderFramework::InitSwapchain(float width, float height) {
+    VkResult err = VK_SUCCESS;
+
 #ifdef VK_USE_PLATFORM_WIN32_KHR
     HINSTANCE window_instance = GetModuleHandle(nullptr);
     const char class_name[] = "test";
@@ -496,7 +498,9 @@
     surface_create_info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
     surface_create_info.hinstance = window_instance;
     surface_create_info.hwnd = window;
-    vkCreateWin32SurfaceKHR(instance(), &surface_create_info, nullptr, &m_surface);
+    err = vkCreateWin32SurfaceKHR(instance(), &surface_create_info, nullptr, &m_surface);
+    ASSERT_VK_SUCCESS(err);
+
 #elif VK_USE_PLATFORM_XLIB_KHR
     Display *d = XOpenDisplay(NULL);
     int s = DefaultScreen(d);
@@ -505,15 +509,20 @@
     surface_create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
     surface_create_info.dpy = d;
     surface_create_info.window = w;
-    vkCreateXlibSurfaceKHR(instance(), &surface_create_info, nullptr, &m_surface);
-#elif VK_USE_PLATFORM_ANDROID_KHR
+    err = vkCreateXlibSurfaceKHR(instance(), &surface_create_info, nullptr, &m_surface);
+    ASSERT_VK_SUCCESS(err);
+
+#elif defined(VK_USE_PLATFORM_ANDROID_KHR) && defined(VALIDATION_APK)
     VkAndroidSurfaceCreateInfoKHR surface_create_info = {};
     surface_create_info.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
     surface_create_info.window = VkTestFramework::window;
-    vkCreateAndroidSurfaceKHR(instance(), &surface_create_info, nullptr, &m_surface);
+    err = vkCreateAndroidSurfaceKHR(instance(), &surface_create_info, nullptr, &m_surface);
+    ASSERT_VK_SUCCESS(err);
+
 #else
-    return false;
+    return;
 #endif
+
     for (size_t i = 0; i < m_device->queue_props.size(); ++i) {
         VkBool32 presentSupport = false;
         vkGetPhysicalDeviceSurfaceSupportKHR(m_device->phy().handle(), i, m_surface, &presentSupport);
@@ -558,7 +567,8 @@
     swapchain_create_info.presentMode = present_modes[0];
     swapchain_create_info.clipped = VK_FALSE;
     swapchain_create_info.oldSwapchain = 0;
-    return (vkCreateSwapchainKHR(device(), &swapchain_create_info, nullptr, &m_swapchain) == VK_SUCCESS);
+    err = vkCreateSwapchainKHR(device(), &swapchain_create_info, nullptr, &m_swapchain);
+    ASSERT_VK_SUCCESS(err);
 }
 
 void VkRenderFramework::DestroySwapchain() {
diff --git a/tests/vkrenderframework.h b/tests/vkrenderframework.h
index c6b5947..b06b387 100644
--- a/tests/vkrenderframework.h
+++ b/tests/vkrenderframework.h
@@ -89,8 +89,8 @@
     VkFramebuffer framebuffer() { return m_framebuffer; }
     void InitViewport(float width, float height);
     void InitViewport();
-    bool InitSwapchain(float width, float height);
-    bool InitSwapchain();
+    void InitSwapchain(float width, float height);
+    void InitSwapchain();
     void DestroySwapchain();
     void InitRenderTarget();
     void InitRenderTarget(uint32_t targets);