Use Ref<TextureBase> instead of TextureBase* in more places

To avoid accidental memory leaks on account of using raw pointers,
use Ref<TextureBase> as method return type except at Dawn interface
boundaries.

Change-Id: I6459062ee28984de2cb1d5a2059bc70cf82b2faf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19580
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
This commit is contained in:
Rafael Cintron
2020-04-23 19:47:12 +00:00
committed by Commit Bot service account
parent c9e28b1463
commit 0e9320b5b5
19 changed files with 114 additions and 60 deletions

View File

@@ -296,6 +296,42 @@ TEST(ResultRefT, ReturningSuccess) {
TestSuccess(&result, &success);
}
class OtherClass {
public:
int a = 0;
};
class Base : public RefCounted {};
class Child : public OtherClass, public Base {};
// Test constructing a Result<Ref<TChild>, E>
TEST(ResultRefT, ConversionFromChildConstructor) {
Child child;
Ref<Child> refChild(&child);
Result<Ref<Base>, int> result(std::move(refChild));
TestSuccess<Base>(&result, &child);
}
// Test copy constructing Result<Ref<TChild>, E>
TEST(ResultRefT, ConversionFromChildCopyConstructor) {
Child child;
Ref<Child> refChild(&child);
Result<Ref<Child>, int> resultChild(std::move(refChild));
Result<Ref<Base>, int> result(std::move(resultChild));
TestSuccess<Base>(&result, &child);
}
// Test assignment operator for Result<Ref<TChild>, E>
TEST(ResultRefT, ConversionFromChildAssignmentOperator) {
Child child;
Ref<Child> refChild(&child);
Result<Ref<Child>, int> resultChild(std::move(refChild));
Result<Ref<Base>, int> result = std::move(resultChild);
TestSuccess<Base>(&result, &child);
}
// Result<T, E>
// Test constructing an error Result<T, E>