blob: 84d7b96316485731d98da70ffba9d8d046566111 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/layout/style_retain_scope.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/wtf/thread_specific.h"
namespace blink {
TEST(StyleRetainScopeTest, Current) {
EXPECT_EQ(StyleRetainScope::Current(), nullptr);
{
StyleRetainScope scope;
EXPECT_EQ(StyleRetainScope::Current(), &scope);
{
StyleRetainScope scope2;
EXPECT_EQ(StyleRetainScope::Current(), &scope2);
}
EXPECT_EQ(StyleRetainScope::Current(), &scope);
}
EXPECT_EQ(StyleRetainScope::Current(), nullptr);
}
TEST(StyleRetainScopeTest, Retain) {
scoped_refptr<const ComputedStyle> style =
ComputedStyle::CreateInitialStyleSingleton();
EXPECT_TRUE(style->HasOneRef());
{
StyleRetainScope scope;
scope.Retain(*style);
EXPECT_FALSE(style->HasOneRef());
EXPECT_TRUE(style->HasAtLeastOneRef());
}
EXPECT_TRUE(style->HasOneRef());
}
} // namespace blink
|