Flutter Engine
The Flutter Engine
sequential_id_generator_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/shell/platform/windows/sequential_id_generator.h"
6
7#include "gtest/gtest.h"
8
9namespace flutter {
10namespace testing {
11
12TEST(SequentialIdGeneratorTest, RemoveMultipleNumbers) {
13 const uint32_t kMinId = 4;
14 const uint32_t kMaxId = 128;
15
16 SequentialIdGenerator generator(kMinId, kMaxId);
17
18 EXPECT_EQ(4U, generator.GetGeneratedId(45));
19 EXPECT_EQ(5U, generator.GetGeneratedId(55));
20 EXPECT_EQ(6U, generator.GetGeneratedId(15));
21
22 generator.ReleaseNumber(45);
23 EXPECT_FALSE(generator.HasGeneratedIdFor(45));
24 generator.ReleaseNumber(15);
25 EXPECT_FALSE(generator.HasGeneratedIdFor(15));
26
27 EXPECT_EQ(5U, generator.GetGeneratedId(55));
28 EXPECT_EQ(4U, generator.GetGeneratedId(12));
29
30 generator.ReleaseNumber(12);
31 generator.ReleaseNumber(55);
32 EXPECT_EQ(4U, generator.GetGeneratedId(0));
33}
34
35TEST(SequentialIdGeneratorTest, MaybeRemoveNumbers) {
36 const uint32_t kMinId = 0;
37 const uint32_t kMaxId = 128;
38
39 SequentialIdGenerator generator(kMinId, kMaxId);
40
41 EXPECT_EQ(0U, generator.GetGeneratedId(42));
42
43 generator.ReleaseNumber(42);
44 EXPECT_FALSE(generator.HasGeneratedIdFor(42));
45 generator.ReleaseNumber(42);
46}
47
48} // namespace testing
49} // namespace flutter
bool HasGeneratedIdFor(uint32_t number) const
uint32_t GetGeneratedId(uint32_t number)
TEST(DisplayListComplexity, EmptyDisplayList)
static const int32_t kMaxId