Extend the enterprise policy for SSL overrides to the "danger" command
[chromium-blink-merge.git] / ppapi / tests / test_memory.cc
blobd4db7c204caf42dd132e45ca7c860e6695e596d2
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.
5 #include "ppapi/tests/test_memory.h"
7 #include "ppapi/c/dev/ppb_memory_dev.h"
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/tests/testing_instance.h"
12 namespace {
14 size_t kTestBufferSize = 1000;
16 } // namespace
18 REGISTER_TEST_CASE(Memory);
20 bool TestMemory::Init() {
21 memory_dev_interface_ = static_cast<const PPB_Memory_Dev*>(
22 pp::Module::Get()->GetBrowserInterface(PPB_MEMORY_DEV_INTERFACE));
23 return memory_dev_interface_ && CheckTestingInterface();
26 void TestMemory::RunTests(const std::string& filter) {
27 RUN_TEST(MemAlloc, filter);
28 RUN_TEST(NullMemFree, filter);
31 std::string TestMemory::TestMemAlloc() {
32 char* buffer = static_cast<char*>(
33 memory_dev_interface_->MemAlloc(static_cast<uint32_t>(kTestBufferSize)));
34 // Touch a couple of locations. Failure will crash the test.
35 buffer[0] = '1';
36 buffer[kTestBufferSize - 1] = '1';
37 memory_dev_interface_->MemFree(buffer);
39 PASS();
42 std::string TestMemory::TestNullMemFree() {
43 // Failure crashes the test.
44 memory_dev_interface_->MemFree(NULL);
46 PASS();