summaryrefslogtreecommitdiff
path: root/core/fxcrt/retain_ptr_unittest.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-30 22:40:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-30 22:40:07 +0000
commitd4e7ca034cbbe29911b08eb5c252aa0d05b6a429 (patch)
tree9620d3988a0d0aee8826c830adc1b8030bbf0b11 /core/fxcrt/retain_ptr_unittest.cpp
parent3b83e83fbfd24e521f7ecd7ce7f1019769bcaec7 (diff)
downloadpdfium-d4e7ca034cbbe29911b08eb5c252aa0d05b6a429.tar.xz
Add unit test for AutoRestorer<> on smart pointer types.
Test UnownedPtr<> and RetainPtr<>. We cannot operate against std::unique_ptr<> because we need a copyable type. Add test for self-reassignment on going out of scope. Move one test helper class to testing/ so it can be shared among unit tests. Allow it to recognize if it ever gets "destroyed", otherwise we can't be sure Retain/Release applied in the correct order. Change-Id: I13056094c70079f7283cbc7600948f81a64874b4 Reviewed-on: https://pdfium-review.googlesource.com/41690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/retain_ptr_unittest.cpp')
-rw-r--r--core/fxcrt/retain_ptr_unittest.cpp17
1 files changed, 1 insertions, 16 deletions
diff --git a/core/fxcrt/retain_ptr_unittest.cpp b/core/fxcrt/retain_ptr_unittest.cpp
index f4b2994eae..5548e9bfd7 100644
--- a/core/fxcrt/retain_ptr_unittest.cpp
+++ b/core/fxcrt/retain_ptr_unittest.cpp
@@ -8,24 +8,9 @@
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/pseudo_retainable.h"
namespace fxcrt {
-namespace {
-
-class PseudoRetainable {
- public:
- PseudoRetainable() : retain_count_(0), release_count_(0) {}
- void Retain() { ++retain_count_; }
- void Release() { ++release_count_; }
- int retain_count() const { return retain_count_; }
- int release_count() const { return release_count_; }
-
- private:
- int retain_count_;
- int release_count_;
-};
-
-} // namespace
TEST(RetainPtr, Null) {
RetainPtr<PseudoRetainable> ptr;