summaryrefslogtreecommitdiffstats
path: root/ppapi/tests
diff options
context:
space:
mode:
authordspringer@chromium.org <dspringer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-05 21:37:00 +0000
committerdspringer@chromium.org <dspringer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-05 21:37:00 +0000
commit14710e220b1e6fb4db5661b0569f978d850a7be6 (patch)
tree16fbd38c33750147601521ad7199e3821f01f32c /ppapi/tests
parentabbd2f4b36da8c89e6f3002eb84f60064a6ff067 (diff)
downloadchromium_src-14710e220b1e6fb4db5661b0569f978d850a7be6.zip
chromium_src-14710e220b1e6fb4db5661b0569f978d850a7be6.tar.gz
chromium_src-14710e220b1e6fb4db5661b0569f978d850a7be6.tar.bz2
Add PPB_Memory_Dev. This is the first of a few CLs needed to pull MemAlloc and
MemFree from PPB_Core. BUG=80610 TEST=ui_tests Review URL: http://codereview.chromium.org/7300010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests')
-rw-r--r--ppapi/tests/all_c_includes.h1
-rw-r--r--ppapi/tests/all_cpp_includes.h1
-rw-r--r--ppapi/tests/test_memory.cc57
-rw-r--r--ppapi/tests/test_memory.h31
4 files changed, 90 insertions, 0 deletions
diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h
index d4f510d..3100deb 100644
--- a/ppapi/tests/all_c_includes.h
+++ b/ppapi/tests/all_c_includes.h
@@ -31,6 +31,7 @@
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
#include "ppapi/c/dev/ppb_layer_compositor_dev.h"
+#include "ppapi/c/dev/ppb_memory_dev.h"
#include "ppapi/c/dev/ppb_opengles_dev.h"
#include "ppapi/c/dev/ppb_scrollbar_dev.h"
#include "ppapi/c/dev/ppb_surface_3d_dev.h"
diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h
index f815986..5c4b21d 100644
--- a/ppapi/tests/all_cpp_includes.h
+++ b/ppapi/tests/all_cpp_includes.h
@@ -26,6 +26,7 @@
#include "ppapi/cpp/dev/fullscreen_dev.h"
#include "ppapi/cpp/dev/graphics_3d_client_dev.h"
#include "ppapi/cpp/dev/graphics_3d_dev.h"
+#include "ppapi/cpp/dev/memory_dev.h"
#include "ppapi/cpp/dev/printing_dev.h"
#include "ppapi/cpp/dev/scriptable_object_deprecated.h"
#include "ppapi/cpp/dev/scrollbar_dev.h"
diff --git a/ppapi/tests/test_memory.cc b/ppapi/tests/test_memory.cc
new file mode 100644
index 0000000..1d44db4
--- /dev/null
+++ b/ppapi/tests/test_memory.cc
@@ -0,0 +1,57 @@
+// 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_dev.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_ = static_cast<const PPB_Memory_Dev*>(
+ 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());
+ {
+ char* buffer = static_cast<char*>(
+ memory_dev_interface_->MemAlloc(kTestBufferSize));
+ // 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();
+}
+
diff --git a/ppapi/tests/test_memory.h b/ppapi/tests/test_memory.h
new file mode 100644
index 0000000..4215ba0
--- /dev/null
+++ b/ppapi/tests/test_memory.h
@@ -0,0 +1,31 @@
+// 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.
+
+#ifndef PPAPI_TEST_TEST_MEMORY_H_
+#define PPAPI_TEST_TEST_MEMORY_H_
+
+#include <string>
+
+#include "ppapi/tests/test_case.h"
+
+struct PPB_Memory_Dev;
+
+class TestMemory : public TestCase {
+ public:
+ explicit TestMemory(TestingInstance* instance) : TestCase(instance) {}
+
+ private:
+ // TestCase implementation.
+ virtual bool Init();
+ virtual void RunTest();
+
+ std::string TestMemAlloc();
+ std::string TestNullMemFree();
+
+ // Used by the tests that access the C API directly.
+ const PPB_Memory_Dev* memory_dev_interface_;
+};
+
+#endif // PPAPI_TEST_TEST_VAR_H_
+