1 
2 /*
3  * Copyright 2017 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 #ifndef GLTestContext_DEFINED
9 #define GLTestContext_DEFINED
10 
11 #include "MockTestContext.h"
12 
13 #include "GrContext.h"
14 
15 namespace {
16 
17 class MockTestContext : public sk_gpu_test::TestContext {
18 public:
MockTestContext()19     MockTestContext() {}
~MockTestContext()20     ~MockTestContext() override {}
21 
backend()22     virtual GrBackend backend() override { return kMock_GrBackend; }
backendContext()23     virtual GrBackendContext backendContext() override {
24         return reinterpret_cast<GrBackendContext>(nullptr);
25     }
testAbandon()26     void testAbandon() override {}
submit()27     void submit() override {}
finish()28     void finish() override {}
29 
makeGrContext(const GrContextOptions & options)30     sk_sp<GrContext> makeGrContext(const GrContextOptions& options) override {
31         return GrContext::MakeMock(nullptr, options);
32     }
33 
34 protected:
teardown()35     void teardown() override {}
onPlatformMakeCurrent() const36     void onPlatformMakeCurrent() const override {}
onPlatformGetAutoContextRestore() const37     std::function<void()> onPlatformGetAutoContextRestore() const override { return nullptr; }
onPlatformSwapBuffers() const38     void onPlatformSwapBuffers() const override {}
39 
40 private:
41     typedef sk_gpu_test::TestContext INHERITED;
42 };
43 
44 } // anonymous namespace
45 
46 namespace sk_gpu_test {
47 
CreateMockTestContext(TestContext *)48 TestContext* CreateMockTestContext(TestContext*) { return new MockTestContext(); }
49 
50 }  // namespace sk_gpu_test
51 #endif
52