Add test for outre GrSurfaceProxy requests

This would've caught the N7 failure in https://skia-review.googlesource.com/c/7738/ (Make blur utils take GrTextureProxies)

Change-Id: I67b56c9d38c14829b2812253c2e3f3e54eb585a5
Reviewed-on: https://skia-review.googlesource.com/7751
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index a228e16..894c37e 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -115,14 +115,14 @@
     const GrGpuResource::UniqueID kInvalidResourceID = GrGpuResource::UniqueID::InvalidID();
 
     for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
-        for (auto widthHeight : { 100, 128 }) {
+        for (auto widthHeight : { 100, 128, 1048576 }) {
             for (auto config : { kAlpha_8_GrPixelConfig, kRGBA_8888_GrPixelConfig }) {
                 for (auto fit : { SkBackingFit::kExact, SkBackingFit::kApprox }) {
                     for (auto budgeted : { SkBudgeted::kYes, SkBudgeted::kNo }) {
                         for (auto numSamples : { 0, 4}) {
-                            bool renderable = ctxInfo.grContext()->caps()->isConfigRenderable(
-                                                                      config, numSamples > 0) &&
-                                  numSamples <= ctxInfo.grContext()->caps()->maxColorSampleCount();
+                            bool renderable = caps.isConfigRenderable(config, numSamples > 0) &&
+                                 numSamples <= caps.maxColorSampleCount();
+                            bool allocable = widthHeight <= caps.maxTextureSize();
 
                             GrSurfaceDesc desc;
                             desc.fFlags = kRenderTarget_GrSurfaceFlag;
@@ -134,21 +134,25 @@
 
                             if (renderable) {
                                 sk_sp<GrSurfaceProxy> sProxy(GrSurfaceProxy::MakeDeferred(
-                                                                                caps, desc, 
+                                                                                caps, desc,
                                                                                 fit, budgeted));
-                                // This forces the proxy to compute and cache its pre-instantiation

-                                // size guess. Later, when it is actually instantiated, it checks

-                                // that the instantiated size is <= to the pre-computation. 

-                                // If the proxy never computed its pre-instantiation size then the

-                                // check is skipped.

-                                sProxy->gpuMemorySize();
+                                REPORTER_ASSERT(reporter, allocable == SkToBool(sProxy));
+                                if (sProxy) {
+                                    REPORTER_ASSERT(reporter, sProxy->asRenderTargetProxy());
+                                    // This forces the proxy to compute and cache its
+                                    // pre-instantiation size guess. Later, when it is actually
+                                    // instantiated, it checks that the instantiated size is <= to
+                                    // the pre-computation. If the proxy never computed its
+                                    // pre-instantiation size then the check is skipped.
+                                    sProxy->gpuMemorySize();
 
-                                check_surface(reporter, sProxy.get(), origin,
-                                              widthHeight, widthHeight, config,
-                                              kInvalidResourceID, budgeted);
-                                check_rendertarget(reporter, caps, provider,
-                                                   sProxy->asRenderTargetProxy(), numSamples,
-                                                   fit, caps.maxWindowRectangles(), false);
+                                    check_surface(reporter, sProxy.get(), origin,
+                                                  widthHeight, widthHeight, config,
+                                                  kInvalidResourceID, budgeted);
+                                    check_rendertarget(reporter, caps, provider,
+                                                       sProxy->asRenderTargetProxy(), numSamples,
+                                                       fit, caps.maxWindowRectangles(), false);
+                                }
                             }
 
                             desc.fFlags = kNone_GrSurfaceFlags;
@@ -158,17 +162,21 @@
                                                                                       desc,
                                                                                       fit,
                                                                                       budgeted));
-                            // This forces the proxy to compute and cache its pre-instantiation

-                            // size guess. Later, when it is actually instantiated, it checks

-                            // that the instantiated size is <= to the pre-computation. 

-                            // If the proxy never computed its pre-instantiation size then the

-                            // check is skipped.
-                            sProxy->gpuMemorySize();
+                            REPORTER_ASSERT(reporter, allocable == SkToBool(sProxy));
+                            if (sProxy) {
+                                // This forces the proxy to compute and cache its pre-instantiation
+                                // size guess. Later, when it is actually instantiated, it checks
+                                // that the instantiated size is <= to the pre-computation.
+                                // If the proxy never computed its pre-instantiation size then the
+                                // check is skipped.
+                                sProxy->gpuMemorySize();
 
-                            check_surface(reporter, sProxy.get(), origin,
-                                          widthHeight, widthHeight, config,
-                                          kInvalidResourceID, budgeted);
-                            check_texture(reporter, provider, sProxy->asTextureProxy(), fit, false);
+                                check_surface(reporter, sProxy.get(), origin,
+                                              widthHeight, widthHeight, config,
+                                              kInvalidResourceID, budgeted);
+                                check_texture(reporter, provider, sProxy->asTextureProxy(),
+                                              fit, false);
+                            }
                         }
                     }
                 }