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

Unified Diff: ppapi/tests/test_memory.cc

Issue 7300010: Add PPB_Memory_Dev. This is the first of a few CLs needed to pull MemAlloc and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing file. Created 9 years, 6 months 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 | « ppapi/tests/test_memory.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_memory.cc
diff --git a/ppapi/tests/test_memory.cc b/ppapi/tests/test_memory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..647af2a0333732c83ec224c3b30592cf422af1a4
--- /dev/null
+++ b/ppapi/tests/test_memory.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/tests/test_memory.h"
+
+#include "ppapi/c/dev/ppb_testing_dev.h"
+#include "ppapi/c/dev/ppb_memory.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/tests/testing_instance.h"
+
+namespace {
+
+size_t kTestBufferSize = 1000;
+
+} // namespace
+
+REGISTER_TEST_CASE(Memory);
+
+bool TestMemory::Init() {
+ memory_dev_interface_ = reinterpret_cast<const PPB_Memory_Dev*>(
dmichael (off chromium) 2011/07/01 21:42:10 nit: static_cast
der Springer 2011/07/05 19:28:27 Done.
+ pp::Module::Get()->GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE));
+ return memory_dev_interface_ && InitTestingInterface();
+}
+
+void TestMemory::RunTest() {
+ RUN_TEST(MemAlloc);
+ RUN_TEST(NullMemFree);
+}
+
+std::string TestMemory::TestMemAlloc() {
+ uint32_t before_object = testing_interface_->GetLiveObjectsForInstance(
+ instance_->pp_instance());
+ {
+ const char* buffer = memory_dev_interface_->MemAlloc(kTestBufferSize);
dmichael (off chromium) 2011/07/01 21:42:10 why const?
der Springer 2011/07/05 19:28:27 Done.
+ // Touch a couple of locations. Failure will crash the test.
+ buffer[0] = '1';
+ buffer[kTestBufferSize - 1] = '1';
+ memory_dev_interface_->MemFree(buffer);
+ }
+
+ // Make sure nothing leaked.
+ ASSERT_TRUE(testing_interface_->GetLiveObjectsForInstance(
+ instance_->pp_instance()) == before_object);
+
+ PASS();
+}
+
+std::string TestMemory::TestNullMemFree() {
+ // Failure crashes the test.
+ memory_dev_interface_->MemFree(NULL);
+
+ PASS();
+}
+
« no previous file with comments | « ppapi/tests/test_memory.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698