| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/tests/test_buffer.h" | 5 #include "ppapi/tests/test_buffer.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_buffer_dev.h" | 7 #include "ppapi/c/dev/ppb_buffer_dev.h" |
| 8 #include "ppapi/cpp/dev/buffer_dev.h" | 8 #include "ppapi/cpp/dev/buffer_dev.h" |
| 9 #include "ppapi/cpp/graphics_2d.h" | 9 #include "ppapi/cpp/graphics_2d.h" |
| 10 #include "ppapi/cpp/instance.h" | 10 #include "ppapi/cpp/instance.h" |
| 11 #include "ppapi/cpp/module.h" | 11 #include "ppapi/cpp/module.h" |
| 12 #include "ppapi/tests/testing_instance.h" | 12 #include "ppapi/tests/testing_instance.h" |
| 13 | 13 |
| 14 REGISTER_TEST_CASE(Buffer); | 14 REGISTER_TEST_CASE(Buffer); |
| 15 | 15 |
| 16 bool TestBuffer::Init() { | 16 bool TestBuffer::Init() { |
| 17 buffer_interface_ = static_cast<const PPB_Buffer_Dev*>( | 17 buffer_interface_ = static_cast<const PPB_Buffer_Dev*>( |
| 18 pp::Module::Get()->GetBrowserInterface(PPB_BUFFER_DEV_INTERFACE)); | 18 pp::Module::Get()->GetBrowserInterface(PPB_BUFFER_DEV_INTERFACE)); |
| 19 return !!buffer_interface_; | 19 return !!buffer_interface_; |
| 20 } | 20 } |
| 21 | 21 |
| 22 void TestBuffer::RunTests(const std::string& filter) { | 22 void TestBuffer::RunTests(const std::string& filter) { |
| 23 instance_->LogTest("InvalidSize", TestInvalidSize()); | 23 RUN_TEST(InvalidSize, filter); |
| 24 instance_->LogTest("InitToZero", TestInitToZero()); | 24 RUN_TEST(InitToZero, filter); |
| 25 instance_->LogTest("IsBuffer", TestIsBuffer()); | 25 RUN_TEST(IsBuffer, filter); |
| 26 instance_->LogTest("BasicLifecyle", TestBasicLifeCycle()); | 26 RUN_TEST(BasicLifeCycle, filter); |
| 27 } | 27 } |
| 28 | 28 |
| 29 std::string TestBuffer::TestInvalidSize() { | 29 std::string TestBuffer::TestInvalidSize() { |
| 30 pp::Buffer_Dev zero_size(instance_, 0); | 30 pp::Buffer_Dev zero_size(instance_, 0); |
| 31 if (!zero_size.is_null()) | 31 if (!zero_size.is_null()) |
| 32 return "Zero size accepted"; | 32 return "Zero size accepted"; |
| 33 | 33 |
| 34 PASS(); | 34 PASS(); |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 // Test that we can still write to copy's copy of the data. | 106 // Test that we can still write to copy's copy of the data. |
| 107 char* copy_data = static_cast<char*>(copy->data()); | 107 char* copy_data = static_cast<char*>(copy->data()); |
| 108 for (int i = 0; i < kBufferSize; ++i) | 108 for (int i = 0; i < kBufferSize; ++i) |
| 109 copy_data[i] = 'Y'; | 109 copy_data[i] = 'Y'; |
| 110 | 110 |
| 111 delete copy; | 111 delete copy; |
| 112 | 112 |
| 113 PASS(); | 113 PASS(); |
| 114 } | 114 } |
| OLD | NEW |