| 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_char_set.h" | 5 #include "ppapi/tests/test_char_set.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_char_set_dev.h" | 7 #include "ppapi/c/dev/ppb_char_set_dev.h" |
| 8 #include "ppapi/cpp/dev/memory_dev.h" | 8 #include "ppapi/cpp/dev/memory_dev.h" |
| 9 #include "ppapi/cpp/module.h" | 9 #include "ppapi/cpp/module.h" |
| 10 #include "ppapi/tests/testing_instance.h" | 10 #include "ppapi/tests/testing_instance.h" |
| 11 | 11 |
| 12 REGISTER_TEST_CASE(CharSet); | 12 REGISTER_TEST_CASE(CharSet); |
| 13 | 13 |
| 14 TestCharSet::TestCharSet(TestingInstance* instance) | 14 TestCharSet::TestCharSet(TestingInstance* instance) |
| 15 : TestCase(instance), | 15 : TestCase(instance), |
| 16 char_set_interface_(NULL) { | 16 char_set_interface_(NULL) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool TestCharSet::Init() { | 19 bool TestCharSet::Init() { |
| 20 char_set_interface_ = static_cast<PPB_CharSet_Dev const*>( | 20 char_set_interface_ = static_cast<PPB_CharSet_Dev const*>( |
| 21 pp::Module::Get()->GetBrowserInterface(PPB_CHAR_SET_DEV_INTERFACE)); | 21 pp::Module::Get()->GetBrowserInterface(PPB_CHAR_SET_DEV_INTERFACE)); |
| 22 return !!char_set_interface_; | 22 return !!char_set_interface_; |
| 23 } | 23 } |
| 24 | 24 |
| 25 void TestCharSet::RunTest() { | 25 void TestCharSet::RunTests(const std::string& filter) { |
| 26 RUN_TEST(UTF16ToCharSet); | 26 RUN_TEST(UTF16ToCharSet, filter); |
| 27 RUN_TEST(CharSetToUTF16); | 27 RUN_TEST(CharSetToUTF16, filter); |
| 28 RUN_TEST(GetDefaultCharSet); | 28 RUN_TEST(GetDefaultCharSet, filter); |
| 29 } | 29 } |
| 30 | 30 |
| 31 std::string TestCharSet::TestUTF16ToCharSet() { | 31 std::string TestCharSet::TestUTF16ToCharSet() { |
| 32 // Empty string. | 32 // Empty string. |
| 33 std::vector<uint16_t> utf16; | 33 std::vector<uint16_t> utf16; |
| 34 utf16.push_back(0); | 34 utf16.push_back(0); |
| 35 uint32_t utf8result_len = 0; | 35 uint32_t utf8result_len = 0; |
| 36 pp::Memory_Dev memory; | 36 pp::Memory_Dev memory; |
| 37 char* utf8result = char_set_interface_->UTF16ToCharSet( | 37 char* utf8result = char_set_interface_->UTF16ToCharSet( |
| 38 instance_->pp_instance(), &utf16[0], 0, "latin1", | 38 instance_->pp_instance(), &utf16[0], 0, "latin1", |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 std::vector<uint16_t> result_vector; | 182 std::vector<uint16_t> result_vector; |
| 183 if (!result) | 183 if (!result) |
| 184 return result_vector; | 184 return result_vector; |
| 185 | 185 |
| 186 result_vector.assign(result, &result[result_len]); | 186 result_vector.assign(result, &result[result_len]); |
| 187 pp::Memory_Dev memory; | 187 pp::Memory_Dev memory; |
| 188 memory.MemFree(result); | 188 memory.MemFree(result); |
| 189 return result_vector; | 189 return result_vector; |
| 190 } | 190 } |
| OLD | NEW |