Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: tests/DiscardableMemoryTest.cpp

Issue 83563002: Implement SkAshmemDiscardableMemory (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: final rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | tools/LazyDecodeBitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DiscardableMemoryTest.cpp
diff --git a/tests/DiscardableMemoryTest.cpp b/tests/DiscardableMemoryTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1fbc28478f091d75f93e70e14ad44ea4f4f035eb
--- /dev/null
+++ b/tests/DiscardableMemoryTest.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkDiscardableMemory.h"
+
+#include "Test.h"
+#include "TestClassDef.h"
+
+DEF_TEST(DiscardableMemory, reporter) {
+ const char testString[] = "HELLO, WORLD!";
+ const size_t len = sizeof(testString);
+ SkAutoTDelete<SkDiscardableMemory> dm(SkDiscardableMemory::Create(len));
+ REPORTER_ASSERT(reporter, dm.get() != NULL);
+ if (NULL == dm.get()) {
+ return;
+ }
+ void* ptr = dm->data();
+ REPORTER_ASSERT(reporter, ptr != NULL);
+ memcpy(ptr, testString, sizeof(testString));
+ dm->unlock();
+ bool success = dm->lock();
+ REPORTER_ASSERT(reporter, success);
+ if (!success) {
+ return;
+ }
+ ptr = dm->data();
+ REPORTER_ASSERT(reporter, 0 == memcmp(ptr, testString, len));
+ dm->unlock();
+}
+
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | tools/LazyDecodeBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698