More robust fix for command buffer context crash.

There apparently were other tests that had similar issues and this fix
is much better and is more future proof.

Change-Id: I4835c7e5772b9e70249a69255aae8808be172eef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282681
Commit-Queue: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/dm/DMGpuTestProcs.cpp b/dm/DMGpuTestProcs.cpp
index 70c4799..736c472 100644
--- a/dm/DMGpuTestProcs.cpp
+++ b/dm/DMGpuTestProcs.cpp
@@ -64,6 +64,9 @@
         ReporterContext ctx(reporter, SkString(GrContextFactory::ContextTypeName(contextType)));
         if (ctxInfo.grContext()) {
             (*test)(reporter, ctxInfo);
+            // In case the test changed the current context make sure we move it back before
+            // calling flush.
+            ctxInfo.testContext()->makeCurrent();
             ctxInfo.grContext()->flush();
         }
     }