Make certificate viewer a tab-modal dialog.
[chromium-blink-merge.git] / ppapi / tests / test_memory.cc
blobea612a4fd8496fea8529c665f9ffc3a221ac7573
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_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"
13 namespace {
15 size_t kTestBufferSize = 1000;
17 } // namespace
19 REGISTER_TEST_CASE(Memory);
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_ && CheckTestingInterface();
27 void TestMemory::RunTests(const std::string& filter) {
28 RUN_TEST(MemAlloc, filter);
29 RUN_TEST(NullMemFree, filter);
32 std::string TestMemory::TestMemAlloc() {
33 char* buffer = static_cast<char*>(
34 memory_dev_interface_->MemAlloc(kTestBufferSize));
35 // Touch a couple of locations. Failure will crash the test.
36 buffer[0] = '1';
37 buffer[kTestBufferSize - 1] = '1';
38 memory_dev_interface_->MemFree(buffer);
40 PASS();
43 std::string TestMemory::TestNullMemFree() {
44 // Failure crashes the test.
45 memory_dev_interface_->MemFree(NULL);
47 PASS();