Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: tests/GrContextFactoryTest.cpp

Issue 1511773005: Make SkGLContext lifetime more well-defined (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix the test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/EGLImageTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GrContextFactoryTest.cpp
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 1b19ac68e39bf19793353506109f2383455f7ea3..7dc02a56e6b25e24035bebf5b185d529b013faa1 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -46,4 +46,30 @@ DEF_GPUTEST(GrContextFactory_NoPathRenderingUnlessNVPRRequested, reporter, /*fac
}
}
+DEF_GPUTEST(GrContextFactory_abandon, reporter, /*factory*/) {
+ GrContextFactory testFactory;
+ for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
+ GrContextFactory::ContextInfo info1 =
+ testFactory.getContextInfo(glCtxType);
+ if (!info1.fGrContext) {
+ continue;
+ }
+ REPORTER_ASSERT(reporter, info1.fGLContext);
+ // Ref for comparison. The API does not explicitly say that this stays alive.
+ info1.fGrContext->ref();
+ testFactory.abandonContexts();
+
+ // Test that we get different context after abandon.
+ GrContextFactory::ContextInfo info2 =
+ testFactory.getContextInfo(glCtxType);
+ REPORTER_ASSERT(reporter, info2.fGrContext);
+ REPORTER_ASSERT(reporter, info2.fGLContext);
+ REPORTER_ASSERT(reporter, info1.fGrContext != info2.fGrContext);
+ // fGLContext should also change, but it also could get the same address.
+
+ info1.fGrContext->unref();
+ }
+}
+
#endif
« no previous file with comments | « tests/EGLImageTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698