Fix crash in tests on valgrind bot

https://codereview.chromium.org/63543005/



git-svn-id: http://skia.googlecode.com/svn/trunk@12234 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 1d713e7..5e95017 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -243,12 +243,14 @@
     TestGetTexture(reporter, kPicture_SurfaceType, NULL);
     if (NULL != factory) {
         GrContext* context = factory->get(GrContextFactory::kNative_GLContextType);
-        Test_crbug263329(reporter, context);
-        TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
-        TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, context);
-        TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
-        TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
-        TestGetTexture(reporter, kGpu_SurfaceType, context);
+        if (NULL != context) {
+            Test_crbug263329(reporter, context);
+            TestSurfaceCopyOnWrite(reporter, kGpu_SurfaceType, context);
+            TestSurfaceWritableAfterSnapshotRelease(reporter, kGpu_SurfaceType, context);
+            TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
+            TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
+            TestGetTexture(reporter, kGpu_SurfaceType, context);
+        }
     }
 #endif
 }