blob: ecc6347d3e4cec5e8f2d4ce986abd2ed12562d81 [file] [log] [blame]
bsalomon6e2aad42016-04-01 11:54:31 -07001/*
2 * Copyright 2016 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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/core/SkTypes.h"
bsalomon6e2aad42016-04-01 11:54:31 -07009
Robert Phillips6d344c32020-07-06 10:56:46 -040010#include "include/gpu/GrDirectContext.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "tests/Test.h"
12#include "tools/gpu/GrContextFactory.h"
bsalomon6e2aad42016-04-01 11:54:31 -070013
bsalomonf2f1c172016-04-05 12:59:06 -070014using namespace sk_gpu_test;
bsalomon6e2aad42016-04-01 11:54:31 -070015
Brian Salomondcfca432017-11-15 15:48:03 -050016DEF_GPUTEST(GrContext_abandonContext, reporter, options) {
bsalomon6e2aad42016-04-01 11:54:31 -070017 for (int testType = 0; testType < 6; ++testType) {
bsalomon85b4b532016-04-05 11:06:27 -070018 for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
Brian Salomondcfca432017-11-15 15:48:03 -050019 GrContextFactory testFactory(options);
bsalomon85b4b532016-04-05 11:06:27 -070020 GrContextFactory::ContextType ctxType = (GrContextFactory::ContextType) i;
bsalomonf2f1c172016-04-05 12:59:06 -070021 ContextInfo info = testFactory.getContextInfo(ctxType);
Robert Phillips6d344c32020-07-06 10:56:46 -040022 if (auto context = info.directContext()) {
bsalomon6e2aad42016-04-01 11:54:31 -070023 switch (testType) {
24 case 0:
25 context->abandonContext();
26 break;
27 case 1:
28 context->releaseResourcesAndAbandonContext();
29 break;
30 case 2:
31 context->abandonContext();
32 context->abandonContext();
33 break;
34 case 3:
35 context->abandonContext();
36 context->releaseResourcesAndAbandonContext();
37 break;
38 case 4:
39 context->releaseResourcesAndAbandonContext();
40 context->abandonContext();
41 break;
42 case 5:
43 context->releaseResourcesAndAbandonContext();
44 context->releaseResourcesAndAbandonContext();
45 break;
46 }
47 }
48 }
49 }
50}