Flutter Engine
 
Loading...
Searching...
No Matches
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"
9
10namespace impeller {
11namespace testing {
12
13using ::testing::_;
14
15namespace {
16class TestWorker : public ReactorGLES::Worker {
17 public:
19 const ReactorGLES& reactor) const override {
20 return true;
21 }
22};
23} // namespace
24
25TEST(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));
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(
45 EXPECT_TRUE(device_buffer.GetHandle().has_value());
46}
47
48} // namespace testing
49} // namespace impeller
std::function< void *(const char *function_name)> Resolver
static std::shared_ptr< MockGLES > Init(std::unique_ptr< MockGLESImpl > impl, const std::optional< std::vector< const char * > > &extensions=std::nullopt)
Definition mock_gles.cc:260
bool CanReactorReactOnCurrentThreadNow(const ReactorGLES &reactor) const override
Determines the ability of the worker to service a reaction on the current thread. The OpenGL context ...
TEST(FrameTimingsRecorderTest, RecordVsync)
const ProcTableGLES::Resolver kMockResolverGLES
Definition mock_gles.cc:287