Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: ppapi/tests/test_char_set.cc

Issue 9381010: Convert resources to take an instance key instead of an Instance*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: USELESS PATCH TITLE Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_case.cc ('k') | ppapi/tests/test_flash.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_case.cc ('k') | ppapi/tests/test_flash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698