aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2016-03-10 11:31:27 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-10 11:31:27 -0800
commit977c07dad26fbb56f6d4b5fc1ac1a324d28bd693 (patch)
tree93016a3da1a43ada575ff1557716e97833f5a87d /tests
parent7e6fcf890a1a63249136b8e6d9f4d5a606ef7508 (diff)
Revert of Use std::unique_ptr. (patchset #7 id:120001 of https://codereview.chromium.org/1780933003/ )
Reason for revert: Now we remember! The problem was Clank: https://build.chromium.org/p/tryserver.chromium.android/builders/android_clang_dbg_recipe/builds/34329 Original issue's description: > Use std::unique_ptr. > > TBR=reed@google.com > > Committed: https://skia.googlesource.com/skia/+/20c1e3abfc681771f73eb19fde7284196e028940 TBR=bungeman@google.com,mtklein@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1782973002
Diffstat (limited to 'tests')
-rw-r--r--tests/CPlusPlusEleven.cpp69
-rw-r--r--tests/ClearTest.cpp2
-rw-r--r--tests/PictureTest.cpp2
-rw-r--r--tests/ResourceCacheTest.cpp16
4 files changed, 79 insertions, 10 deletions
diff --git a/tests/CPlusPlusEleven.cpp b/tests/CPlusPlusEleven.cpp
index 5fbd46429d..0cd2e937b2 100644
--- a/tests/CPlusPlusEleven.cpp
+++ b/tests/CPlusPlusEleven.cpp
@@ -28,3 +28,72 @@ DEF_TEST(CPlusPlusEleven_RvalueAndMove, r) {
Moveable src1; Moveable dst1(std::move(src1));
Moveable src2, dst2; dst2 = std::move(src2);
}
+
+#define TOO_BIG "The unique_ptr was bigger than expected."
+#define WEIRD_SIZE "The unique_ptr was a different size than expected."
+
+DEF_TEST(CPlusPlusEleven_UniquePtr, r) {
+ struct SmallUniquePtr {
+ Moveable* p;
+ };
+ struct BigUniquePtr {
+ void(*d)(Moveable*);
+ Moveable* p;
+ };
+
+ static_assert(sizeof(skstd::unique_ptr<Moveable>) == sizeof(SmallUniquePtr), TOO_BIG);
+ static_assert(sizeof(skstd::unique_ptr<Moveable[]>) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ using proc = void(*)(Moveable*);
+ static_assert(sizeof(skstd::unique_ptr<Moveable, proc>) == sizeof(BigUniquePtr), WEIRD_SIZE);
+ static_assert(sizeof(skstd::unique_ptr<Moveable[], proc>) == sizeof(BigUniquePtr), WEIRD_SIZE);
+
+ {
+ skstd::unique_ptr<Moveable, void(*)(Moveable*)> u(nullptr, deleter<Moveable>);
+ static_assert(sizeof(u) == sizeof(BigUniquePtr), WEIRD_SIZE);
+
+ auto u2 = std::move(u);
+ static_assert(sizeof(u2) == sizeof(BigUniquePtr), WEIRD_SIZE);
+ }
+
+ {
+ skstd::unique_ptr<Moveable, void(*)(Moveable*)> u(nullptr, [](Moveable* m){ deleter(m); });
+ static_assert(sizeof(u) == sizeof(BigUniquePtr), WEIRD_SIZE);
+
+ auto u2 = std::move(u);
+ static_assert(sizeof(u2) == sizeof(BigUniquePtr), WEIRD_SIZE);
+ }
+
+ {
+ auto d = [](Moveable* m){ deleter(m); };
+ skstd::unique_ptr<Moveable, decltype(d)> u(nullptr, d);
+ static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ auto u2 = std::move(u);
+ static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
+ }
+
+ {
+ skstd::unique_ptr<Moveable, Deleter<Moveable>> u(nullptr, Deleter<Moveable>());
+ static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ auto u2 = std::move(u);
+ static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
+ }
+
+ {
+ skstd::unique_ptr<Moveable, Deleter<Moveable>> u(new Moveable(), Deleter<Moveable>());
+ static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ auto u2 = std::move(u);
+ static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
+ }
+
+ {
+ skstd::unique_ptr<const void, Deleter<const void>> u(new Moveable(), Deleter<const void>());
+ static_assert(sizeof(u) == sizeof(SmallUniquePtr), TOO_BIG);
+
+ auto u2 = std::move(u);
+ static_assert(sizeof(u2) == sizeof(SmallUniquePtr), TOO_BIG);
+ }
+}
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 25fcf85849..df152089fb 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -62,7 +62,7 @@ static bool reset_dc(SkAutoTUnref<GrDrawContext>* dc, SkAutoTUnref<GrSurface>* r
GrRenderTarget* rt = (*rtKeepAlive)->asRenderTarget();
SkASSERT(rt->getUniqueID() != oldID);
dc->reset(context->drawContext(rt));
- return *dc != nullptr;
+ return SkToBool(*dc);
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ClearBatch, reporter, context) {
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index a33deeb218..448e079958 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -1409,7 +1409,7 @@ DEF_TEST(Picture_preserveCullRect, r) {
SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstream));
- REPORTER_ASSERT(r, deserializedPicture != nullptr);
+ REPORTER_ASSERT(r, SkToBool(deserializedPicture));
REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 784ae7e94d..c715b2efcc 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -136,7 +136,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheStencilBuffers, reporter, contex
resourceProvider->attachStencilAttachment(bigRT->asRenderTarget()));
if (context->caps()->maxSampleCount() >= 4) {
- // An RT with a different sample count should not share.
+ // An RT with a different sample count should not share.
GrSurfaceDesc smallMSAADesc = smallDesc;
smallMSAADesc.fSampleCnt = 4;
SkAutoTUnref<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc, SkBudgeted::kNo));
@@ -216,8 +216,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, cont
SkAutoTUnref<GrTexture> adopted(context->textureProvider()->wrapBackendTexture(
desc, kAdopt_GrWrapOwnership));
- REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
- if (!borrowed || !adopted) {
+ REPORTER_ASSERT(reporter, SkToBool(borrowed) && SkToBool(adopted));
+ if (!SkToBool(borrowed) || !SkToBool(adopted)) {
return;
}
@@ -242,7 +242,7 @@ class TestResource : public GrGpuResource {
enum ScratchConstructor { kScratchConstructor };
public:
static const size_t kDefaultSize = 100;
-
+
/** Property that distinctly categorizes the resource.
* For example, textures have width, height, ... */
enum SimulatedProperty { kA_SimulatedProperty, kB_SimulatedProperty };
@@ -590,7 +590,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
REPORTER_ASSERT(reporter, SkBudgeted::kYes == resource->resourcePriv().isBudgeted());
if (0 == i) {
- // If made unbudgeted, it should return to original state: ref'ed and unbudgeted. Try
+ // If made unbudgeted, it should return to original state: ref'ed and unbudgeted. Try
// the above tests again.
resource->resourcePriv().makeUnbudgeted();
} else {
@@ -784,11 +784,11 @@ static void test_duplicate_unique_key(skiatest::Reporter* reporter) {
GrUniqueKey key;
make_unique_key<0>(&key, 0);
-
+
// Create two resources that we will attempt to register with the same unique key.
TestResource* a = new TestResource(context->getGpu());
a->setSize(11);
-
+
// Set key on resource a.
a->resourcePriv().setUniqueKey(key);
REPORTER_ASSERT(reporter, a == cache->findAndRefUniqueResource(key));
@@ -882,7 +882,7 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
make_unique_key<0>(&key1, 1);
make_unique_key<0>(&key2, 2);
make_unique_key<0>(&key3, 3);
-
+
// Add three resources to the cache. Only c is usable as scratch.
TestResource* a = new TestResource(context->getGpu());
TestResource* b = new TestResource(context->getGpu());