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

Side by Side 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: Clean up thunk.h Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_memory.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/tests/test_memory.h"
6
7 #include "ppapi/c/dev/ppb_testing_dev.h"
8 #include "ppapi/c/dev/ppb_memory_dev.h"
9 #include "ppapi/cpp/instance.h"
10 #include "ppapi/cpp/module.h"
11 #include "ppapi/tests/testing_instance.h"
12
13 namespace {
14
15 size_t kTestBufferSize = 1000;
16
17 } // namespace
18
19 REGISTER_TEST_CASE(Memory);
20
21 bool TestMemory::Init() {
22 memory_dev_interface_ = static_cast<const PPB_Memory_Dev*>(
23 pp::Module::Get()->GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE));
24 return memory_dev_interface_ && InitTestingInterface();
25 }
26
27 void TestMemory::RunTest() {
28 RUN_TEST(MemAlloc);
29 RUN_TEST(NullMemFree);
30 }
31
32 std::string TestMemory::TestMemAlloc() {
33 uint32_t before_object = testing_interface_->GetLiveObjectsForInstance(
34 instance_->pp_instance());
35 {
36 char* buffer = static_cast<char*>(
37 memory_dev_interface_->MemAlloc(kTestBufferSize));
38 // Touch a couple of locations. Failure will crash the test.
39 buffer[0] = '1';
40 buffer[kTestBufferSize - 1] = '1';
41 memory_dev_interface_->MemFree(buffer);
42 }
43
44 // Make sure nothing leaked.
45 ASSERT_TRUE(testing_interface_->GetLiveObjectsForInstance(
46 instance_->pp_instance()) == before_object);
47
48 PASS();
49 }
50
51 std::string TestMemory::TestNullMemFree() {
52 // Failure crashes the test.
53 memory_dev_interface_->MemFree(NULL);
54
55 PASS();
56 }
57
OLDNEW
« 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