Use smart Refs for IOKit and CoreFoundation objects.

Bug: dawn:89
Change-Id: Idea634bcc65ab4ec017f4e4c2431e95915f533df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32661
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez
2020-11-17 11:35:11 +00:00
committed by Commit Bot service account
parent f2bc3b3edd
commit d98e8b70bb
7 changed files with 132 additions and 18 deletions

View File

@@ -402,3 +402,17 @@ TEST(Ref, MoveAssignmentDerived) {
destination = nullptr;
EXPECT_TRUE(deleted);
}
// Test Ref's InitializeInto.
TEST(Ref, InitializeInto) {
bool deleted = false;
RCTest* original = new RCTest(&deleted);
// InitializeInto acquires the ref.
Ref<RCTest> ref;
*ref.InitializeInto() = original;
EXPECT_EQ(original->GetRefCountForTesting(), 1u);
ref = nullptr;
EXPECT_TRUE(deleted);
}