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"
8 #include "impeller/renderer/backend/gles/test/mock_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 =
41  EXPECT_FALSE(handle.Get().IsDead());
42 }
43 
44 } // namespace testing
45 } // namespace impeller
constexpr bool IsDead() const
Determines if the handle is dead.
Definition: handle_gles.h:53
std::function< void *(const char *function_name)> Resolver
A unique handle to an OpenGL object. The collection of this handle scheduled the destruction of the a...
static UniqueHandleGLES MakeUntracked(std::shared_ptr< ReactorGLES > reactor, HandleType type)
const HandleGLES & Get() const
TEST(AllocationSizeTest, CanCreateTypedAllocations)