Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
pool_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 "gtest/gtest.h"
6
8
9namespace impeller {
10namespace testing {
11
12namespace {
13class Foobar {
14 public:
15 static std::shared_ptr<Foobar> Create() { return std::make_shared<Foobar>(); }
16
17 size_t GetSize() const { return size_; }
18
19 void SetSize(size_t size) { size_ = size; }
20
21 void Reset() { is_reset_ = true; }
22
23 bool GetIsReset() const { return is_reset_; }
24
25 void SetIsReset(bool is_reset) { is_reset_ = is_reset; }
26
27 private:
28 size_t size_;
29 bool is_reset_ = false;
30};
31} // namespace
32
33TEST(PoolTest, Simple) {
34 Pool<Foobar> pool(1'000);
35 {
36 auto grabbed = pool.Grab();
37 grabbed->SetSize(123);
38 pool.Recycle(grabbed);
39 EXPECT_EQ(pool.GetSize(), 123u);
40 }
41 auto grabbed = pool.Grab();
42 EXPECT_EQ(grabbed->GetSize(), 123u);
43 EXPECT_TRUE(grabbed->GetIsReset());
44 EXPECT_EQ(pool.GetSize(), 0u);
45}
46
47TEST(PoolTest, Overload) {
48 Pool<Foobar> pool(1'000);
49 {
50 std::vector<std::shared_ptr<Foobar>> values;
51 values.reserve(20);
52 for (int i = 0; i < 20; i++) {
53 values.push_back(pool.Grab());
54 }
55 for (const auto& value : values) {
56 value->SetSize(100);
57 pool.Recycle(value);
58 }
59 }
60 EXPECT_EQ(pool.GetSize(), 1'000u);
61}
62
63} // namespace testing
64} // namespace impeller
AutoreleasePool pool
#define TEST(S, s, D, expected)
static sk_sp< Effect > Create()
A thread-safe pool with a limited byte size.
Definition pool.h:17
uint8_t value
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
void Reset(SkPath *path)
Definition path_ops.cc:40
#define EXPECT_TRUE(handle)
Definition unit_test.h:685