| Flutter Impeller |

device_buffer_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/device_buffer_gles.h"
8 #include "impeller/renderer/backend/gles/test/mock_gles.h"
9
10 namespace impeller {
11 namespace testing {
12
13 using ::testing::_;
14
15 namespace {
16 class TestWorker : public ReactorGLES::Worker {
17 public:
18 bool CanReactorReactOnCurrentThreadNow(
19 const ReactorGLES& reactor) const override {
20 return true;
21 }
22 };
23 } // namespace
24
25 TEST(DeviceBufferGLESTest, BindUniformData) {
26 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
27
28 EXPECT_CALL(*mock_gles_impl, GenBuffers(1, _)).Times(1);
29
30 std::shared_ptr<MockGLES> mock_gled =
31 MockGLES::Init(std::move(mock_gles_impl));
32 ProcTableGLES::Resolver resolver = kMockResolverGLES;
33 auto proc_table = std::make_unique<ProcTableGLES>(resolver);
34 auto worker = std::make_shared<TestWorker>();
35 auto reactor = std::make_shared<ReactorGLES>(std::move(proc_table));
36 reactor->AddWorker(worker);
37
38 std::shared_ptr<Allocation> backing_store = std::make_shared<Allocation>();
39 ASSERT_TRUE(backing_store->Truncate(Bytes{sizeof(float)}));
40 DeviceBufferGLES device_buffer(DeviceBufferDescriptor{.size = sizeof(float)},
41 reactor, backing_store);
42 EXPECT_FALSE(device_buffer.GetHandle().has_value());
43 EXPECT_TRUE(device_buffer.BindAndUploadDataIfNecessary(
44 DeviceBufferGLES::BindingType::kUniformBuffer));
45 EXPECT_TRUE(device_buffer.GetHandle().has_value());
46 }
47
48 } // namespace testing
49 } // namespace impeller
impeller::AllocationSize< 1u >
impeller::DeviceBufferGLES
Definition: device_buffer_gles.h:20
impeller::DeviceBufferGLES::BindingType::kUniformBuffer
@ kUniformBuffer
impeller::ProcTableGLES::Resolver
std::function< void *(const char *function_name)> Resolver
Definition: proc_table_gles.h:285
device_buffer_gles.h
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition: allocation_size_unittests.cc:10
impeller
Definition: allocation.cc:12
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
impeller::DeviceBufferDescriptor::size
size_t size
Definition: device_buffer_descriptor.h:16