Fix EGL negative api eglMakeCurrent test.
authorMika Isojärvi <misojarvi@google.com>
Fri, 20 Mar 2015 21:40:10 +0000 (14:40 -0700)
committerMika Isojärvi <misojarvi@google.com>
Mon, 23 Mar 2015 19:10:50 +0000 (12:10 -0700)
Use real EGLContext instead of using EGL_NO_CONTEXT when testing other
errors than EGL_BAD_CONTEXT.

Bug: 18290284
Change-Id: I97cdc8a668ce73d6db38f4289c6f9388340ebabc

modules/egl/teglNegativeApiTests.cpp

index 607fa7c..f15a906 100755 (executable)
@@ -862,31 +862,64 @@ void NegativeApiTests::init (void)
                                }
                        }
 
-                       log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
-
-                       expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, DE_NULL));
-                       expectError(EGL_BAD_SURFACE);
+                       // Create simple ES2 context
+                       EGLContext context = EGL_NO_CONTEXT;
+                       {
+                               EGLConfig config;
+                               if (getConfig(&config, FilterList() << renderable<EGL_OPENGL_ES2_BIT>))
+                               {
+                                       context = eglCreateContext(display, config, EGL_NO_CONTEXT, s_es2ContextAttribList);
+                                       expectError(EGL_SUCCESS);
+                               }
+                       }
 
-                       if (surface)
+                       if (surface != EGL_NO_SURFACE && context != EGL_NO_CONTEXT)
                        {
-                               expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, DE_NULL));
+                               log << TestLog::Section("Test2", "EGL_BAD_SURFACE is generated if surface is not an EGL surface");
+
+                               expectFalse(eglMakeCurrent(display, (EGLSurface)-1, (EGLSurface)-1, context));
                                expectError(EGL_BAD_SURFACE);
 
-                               expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, DE_NULL));
+                               expectFalse(eglMakeCurrent(display, surface, (EGLSurface)-1, context));
                                expectError(EGL_BAD_SURFACE);
-                       }
 
-                       log << TestLog::EndSection;
+                               expectFalse(eglMakeCurrent(display, (EGLSurface)-1, surface, context));
+                               expectError(EGL_BAD_SURFACE);
 
-                       log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
+                               log << TestLog::EndSection;
+                       }
 
                        if (surface)
                        {
+                               log << TestLog::Section("Test3", "EGL_BAD_CONTEXT is generated if context is not an EGL rendering context");
+
                                expectFalse(eglMakeCurrent(display, surface, surface, (EGLContext)-1));
                                expectError(EGL_BAD_CONTEXT);
+
+                               log << TestLog::EndSection;
                        }
 
-                       log << TestLog::EndSection;
+                       if (surface != EGL_NO_SURFACE)
+                       {
+                               log << TestLog::Section("Test4", "EGL_BAD_MATCH is generated if read or draw surface is not EGL_NO_SURFACE and context is EGL_NO_CONTEXT");
+
+                               expectFalse(eglMakeCurrent(display, surface, EGL_NO_SURFACE, EGL_NO_CONTEXT));
+                               expectError(EGL_BAD_MATCH);
+
+                               expectFalse(eglMakeCurrent(display, EGL_NO_SURFACE, surface, EGL_NO_CONTEXT));
+                               expectError(EGL_BAD_MATCH);
+
+                               expectFalse(eglMakeCurrent(display, surface, surface, EGL_NO_CONTEXT));
+                               expectError(EGL_BAD_MATCH);
+
+                               log << TestLog::EndSection;
+                       }
+
+                       if (context)
+                       {
+                               eglDestroyContext(display, context);
+                               expectError(EGL_SUCCESS);
+                       }
 
                        if (surface)
                        {