Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
move_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2020 The PDFium Authors
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
<
utility
>
6
7
#
include
"fxjs/gc/heap.h"
8
#
include
"testing/fxgc_unittest.h"
9
#
include
"testing/gtest/include/gtest/gtest.h"
10
#
include
"v8/include/cppgc/member.h"
11
#
include
"v8/include/cppgc/persistent.h"
12
13
namespace
{
14
15
class
HeapObject :
public
cppgc::GarbageCollected<HeapObject> {
16
public
:
17
CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
;
18
19
void
Trace(cppgc::Visitor* visitor)
const
{
20
visitor->Trace(frick_);
21
visitor->Trace(frack_);
22
}
23
24
cppgc::Member<HeapObject> frick_;
25
cppgc::Member<HeapObject> frack_;
26
27
private
:
28
HeapObject() =
default
;
29
};
30
31
class
CppObject {
32
public
:
33
CppObject() =
default
;
34
35
cppgc::Persistent<HeapObject> click_;
36
cppgc::Persistent<HeapObject> clack_;
37
};
38
39
}
// namespace
40
41
class
MoveUnitTest
:
public
FXGCUnitTest
{};
42
43
TEST_F
(
MoveUnitTest
,
Member
) {
44
// Moving a Member<> leaves the moved-from object as null.
45
auto
* obj =
46
cppgc::MakeGarbageCollected<HeapObject>(heap()->GetAllocationHandle());
47
obj->frick_ = obj;
48
obj->frack_ =
std
::move(obj->frick_);
49
EXPECT_FALSE(obj->frick_);
50
EXPECT_EQ(obj, obj->frack_);
51
}
52
53
TEST_F
(
MoveUnitTest
,
Persistent
) {
54
// Moving a Persistent<> leaves the moved-from object as null.
55
auto
* obj =
56
cppgc::MakeGarbageCollected<HeapObject>(heap()->GetAllocationHandle());
57
CppObject outsider;
58
outsider.click_ = obj;
59
outsider.clack_ =
std
::move(outsider.click_);
60
EXPECT_FALSE(outsider.click_);
61
EXPECT_EQ(obj, outsider.clack_);
62
}
FXGCUnitTest
Definition
fxgc_unittest.h:11
MoveUnitTest
Definition
move_unittest.cpp:41
CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
Definition
heap.h:32
TEST_F
TEST_F(MoveUnitTest, Member)
Definition
move_unittest.cpp:43
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxjs
gc
move_unittest.cpp
Generated on
for Qt by
1.18.0