Add unit test for pinned SkImages

Change-Id: I2e14353bc865b5994cc90ad643a6a58604955957
Reviewed-on: https://skia-review.googlesource.com/53500
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index fd39bbf..20acf54 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -196,12 +196,15 @@
 
     this->processFreedGpuResources();
 
+    // We must remove the uniqueKeys from the proxies here. While they possess a uniqueKey
+    // they also have a raw pointer back to this class (which is presumably going away)!
     UniquelyKeyedProxyHash::Iter iter(&fUniquelyKeyedProxies);
-    for (UniquelyKeyedProxyHash::Iter iter(&fUniquelyKeyedProxies) ; !iter.done(); ++iter) {
+    for (UniquelyKeyedProxyHash::Iter iter(&fUniquelyKeyedProxies); !iter.done(); ++iter) {
         GrTextureProxy& tmp = *iter;
 
         this->processInvalidProxyUniqueKey(tmp.getUniqueKey(), &tmp, false);
     }
+    SkASSERT(!fUniquelyKeyedProxies.count());
 
     while(fNonpurgeableResources.count()) {
         GrGpuResource* back = *(fNonpurgeableResources.end() - 1);