keyar@chromium.org | 5bdef29 | 2012-08-14 22:02:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "Test.h" |
| 9 | |
| 10 | // This is a GPU-backend specific test |
| 11 | #if SK_SUPPORT_GPU |
| 12 | #include "GrContextFactory.h" |
| 13 | |
commit-bot@chromium.org | 197845a | 2013-04-19 13:24:28 +0000 | [diff] [blame] | 14 | static void test_context_factory(skiatest::Reporter* reporter, |
| 15 | GrContextFactory* contextFactory) { |
| 16 | // Reset in case some other test has been using it first. |
| 17 | contextFactory->destroyContexts(); |
keyar@chromium.org | 5bdef29 | 2012-08-14 22:02:48 +0000 | [diff] [blame] | 18 | |
| 19 | // Before we ask for a context, we expect the GL context to not be there. |
| 20 | REPORTER_ASSERT(reporter, |
commit-bot@chromium.org | 197845a | 2013-04-19 13:24:28 +0000 | [diff] [blame] | 21 | NULL == contextFactory->getGLContext(GrContextFactory::kNative_GLContextType)); |
keyar@chromium.org | 5bdef29 | 2012-08-14 22:02:48 +0000 | [diff] [blame] | 22 | |
| 23 | // After we ask for a context, we expect that the GL context to be there. |
commit-bot@chromium.org | 197845a | 2013-04-19 13:24:28 +0000 | [diff] [blame] | 24 | contextFactory->get(GrContextFactory::kNative_GLContextType); |
keyar@chromium.org | 5bdef29 | 2012-08-14 22:02:48 +0000 | [diff] [blame] | 25 | REPORTER_ASSERT(reporter, |
commit-bot@chromium.org | 197845a | 2013-04-19 13:24:28 +0000 | [diff] [blame] | 26 | contextFactory->getGLContext(GrContextFactory::kNative_GLContextType) != NULL); |
keyar@chromium.org | 5bdef29 | 2012-08-14 22:02:48 +0000 | [diff] [blame] | 27 | |
| 28 | // If we did not ask for a context with the particular GL context, we would |
| 29 | // expect the particular GL context to not be there. |
| 30 | REPORTER_ASSERT(reporter, |
commit-bot@chromium.org | 197845a | 2013-04-19 13:24:28 +0000 | [diff] [blame] | 31 | NULL == contextFactory->getGLContext(GrContextFactory::kNull_GLContextType)); |
keyar@chromium.org | 5bdef29 | 2012-08-14 22:02:48 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | |
| 35 | #include "TestClassDef.h" |
commit-bot@chromium.org | 197845a | 2013-04-19 13:24:28 +0000 | [diff] [blame] | 36 | DEFINE_GPUTESTCLASS("GrContextFactory", GrContextFactoryClass, test_context_factory); |
keyar@chromium.org | 5bdef29 | 2012-08-14 22:02:48 +0000 | [diff] [blame] | 37 | |
| 38 | #endif |