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

Side by Side Diff: tests/DiscardableMemoryTest.cpp

Issue 83563002: Implement SkAshmemDiscardableMemory (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: bugfix 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkDiscardableMemory.h"
9
10 #include "Test.h"
11 #include "TestClassDef.h"
12
13 DEF_TEST(DiscardableMemory, reporter) {
14 static const char testString[] = "HELLO, WORLD!";
15 SkDiscardableMemory* dm = SkDiscardableMemory::Create(sizeof(testString));
16 REPORTER_ASSERT(reporter, dm != NULL);
17 if (NULL == dm)
scroggo 2013/11/22 14:34:14 Our style guide suggests using braces like so: if
hal.canary 2013/11/22 15:17:54 Done.
18 return;
19 void* ptr = dm->data();
20 REPORTER_ASSERT(reporter, ptr != NULL);
21 memcpy(ptr, testString, sizeof(testString));
22 dm->unlock();
23 bool success = dm->lock();
24 REPORTER_ASSERT(reporter, success);
25 if (!success)
scroggo 2013/11/22 14:34:14 braces
hal.canary 2013/11/22 15:17:54 Done.
26 return;
scroggo 2013/11/22 14:34:14 dm is leaked here. Maybe wrap it in an SkAutoTDele
hal.canary 2013/11/22 15:17:54 Done.
27 ptr = dm->data();
28 REPORTER_ASSERT(reporter, 0 == memcmp(ptr, testString, sizeof(testString)));
29 dm->unlock();
30 SkDELETE(dm);
31 }
32
OLDNEW
« src/ports/SkDiscardableMemory_ashmem.cpp ('K') | « src/utils/android/ashmem.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698