| Flutter Impeller |

unique_handle_gles_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/testing/testing.h" // IWYU pragma: keep
6 #include "gtest/gtest.h"
7 #include "impeller/renderer/backend/gles/reactor_gles.h"
8 #include "impeller/renderer/backend/gles/test/mock_gles.h"
9 #include "impeller/renderer/backend/gles/unique_handle_gles.h"
10
11 namespace impeller {
12 namespace testing {
13
14 using ::testing::_;
15
16 namespace {
17 class TestWorker : public ReactorGLES::Worker {
18 public:
19 bool CanReactorReactOnCurrentThreadNow(
20 const ReactorGLES& reactor) const override {
21 return true;
22 }
23 };
24 } // namespace
25
26 TEST(UniqueHandleGLES, MakeUntracked) {
27 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
28
29 EXPECT_CALL(*mock_gles_impl, GenTextures(1, _)).Times(1);
30
31 std::shared_ptr<MockGLES> mock_gled =
32 MockGLES::Init(std::move(mock_gles_impl));
33 ProcTableGLES::Resolver resolver = kMockResolverGLES;
34 auto proc_table = std::make_unique<ProcTableGLES>(resolver);
35 auto worker = std::make_shared<TestWorker>();
36 auto reactor = std::make_shared<ReactorGLES>(std::move(proc_table));
37 reactor->AddWorker(worker);
38
39 UniqueHandleGLES handle =
40 UniqueHandleGLES::MakeUntracked(reactor, HandleType::kTexture);
41 EXPECT_FALSE(handle.Get().IsDead());
42 }
43
44 } // namespace testing
45 } // namespace impeller
impeller::HandleType::kTexture
@ kTexture
impeller::UniqueHandleGLES::MakeUntracked
static UniqueHandleGLES MakeUntracked(std::shared_ptr< ReactorGLES > reactor, HandleType type)
Definition: unique_handle_gles.cc:20
impeller::ProcTableGLES::Resolver
std::function< void *(const char *function_name)> Resolver
Definition: proc_table_gles.h:279
impeller::UniqueHandleGLES::Get
const HandleGLES & Get() const
Definition: unique_handle_gles.cc:38
impeller::HandleGLES::IsDead
constexpr bool IsDead() const
Determines if the handle is dead.
Definition: handle_gles.h:53
reactor_gles.h
unique_handle_gles.h
impeller
Definition: allocation.cc:12
impeller::UniqueHandleGLES
A unique handle to an OpenGL object. The collection of this handle scheduled the destruction of the a...
Definition: unique_handle_gles.h:18
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition: allocation_size_unittests.cc:10