OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/c/trusted/ppb_char_set_trusted.h" | 8 #include "ppapi/c/trusted/ppb_char_set_trusted.h" |
9 #include "ppapi/cpp/dev/memory_dev.h" | 9 #include "ppapi/cpp/dev/memory_dev.h" |
10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 badutf8, 3, "poopiepants", PP_CHARSET_TRUSTED_CONVERSIONERROR_SUBSTITUTE, | 345 badutf8, 3, "poopiepants", PP_CHARSET_TRUSTED_CONVERSIONERROR_SUBSTITUTE, |
346 &output_buffer[0], &utf16result_len); | 346 &output_buffer[0], &utf16result_len); |
347 ASSERT_TRUE(!result); | 347 ASSERT_TRUE(!result); |
348 ASSERT_TRUE(utf16result_len == 0); | 348 ASSERT_TRUE(utf16result_len == 0); |
349 | 349 |
350 PASS(); | 350 PASS(); |
351 } | 351 } |
352 | 352 |
353 std::string TestCharSet::TestGetDefaultCharSet() { | 353 std::string TestCharSet::TestGetDefaultCharSet() { |
354 // Test invalid instance. | 354 // Test invalid instance. |
355 pp::Var result(pp::Var::PassRef(), char_set_interface_->GetDefaultCharSet(0)); | 355 pp::Var result(pp::PASS_REF, char_set_interface_->GetDefaultCharSet(0)); |
356 ASSERT_TRUE(result.is_undefined()); | 356 ASSERT_TRUE(result.is_undefined()); |
357 | 357 |
358 // Just make sure the default char set is a nonempty string. | 358 // Just make sure the default char set is a nonempty string. |
359 result = pp::Var(pp::Var::PassRef(), | 359 result = pp::Var(pp::PASS_REF, |
360 char_set_interface_->GetDefaultCharSet(instance_->pp_instance())); | 360 char_set_interface_->GetDefaultCharSet(instance_->pp_instance())); |
361 ASSERT_TRUE(result.is_string()); | 361 ASSERT_TRUE(result.is_string()); |
362 ASSERT_FALSE(result.AsString().empty()); | 362 ASSERT_FALSE(result.AsString().empty()); |
363 | 363 |
364 PASS(); | 364 PASS(); |
365 } | 365 } |
366 | 366 |
367 std::vector<uint16_t> TestCharSet::UTF8ToUTF16(const std::string& utf8) { | 367 std::vector<uint16_t> TestCharSet::UTF8ToUTF16(const std::string& utf8) { |
368 uint32_t result_len = 0; | 368 uint32_t result_len = 0; |
369 uint16_t* result = char_set_interface_->CharSetToUTF16( | 369 uint16_t* result = char_set_interface_->CharSetToUTF16( |
370 instance_->pp_instance(), utf8.c_str(), | 370 instance_->pp_instance(), utf8.c_str(), |
371 static_cast<uint32_t>(utf8.size()), | 371 static_cast<uint32_t>(utf8.size()), |
372 "utf-8", PP_CHARSET_CONVERSIONERROR_FAIL, &result_len); | 372 "utf-8", PP_CHARSET_CONVERSIONERROR_FAIL, &result_len); |
373 | 373 |
374 std::vector<uint16_t> result_vector; | 374 std::vector<uint16_t> result_vector; |
375 if (!result) | 375 if (!result) |
376 return result_vector; | 376 return result_vector; |
377 | 377 |
378 result_vector.assign(result, &result[result_len]); | 378 result_vector.assign(result, &result[result_len]); |
379 pp::Memory_Dev memory; | 379 pp::Memory_Dev memory; |
380 memory.MemFree(result); | 380 memory.MemFree(result); |
381 return result_vector; | 381 return result_vector; |
382 } | 382 } |
OLD | NEW |