diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-15 03:44:13 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-15 03:44:13 +0000 |
commit | 859a7f3a9264b3a2174e9625d6cfa20412ac6081 (patch) | |
tree | b9911798925fbff065346fa6c085b254d7fb2e55 /ppapi/tests | |
parent | f615770cd0412b2524b8b4451e6518608af9abed (diff) | |
download | chromium_src-859a7f3a9264b3a2174e9625d6cfa20412ac6081.zip chromium_src-859a7f3a9264b3a2174e9625d6cfa20412ac6081.tar.gz chromium_src-859a7f3a9264b3a2174e9625d6cfa20412ac6081.tar.bz2 |
Make PP_Resources associated with the Instance rather than the module. This
adds PP_Instance to the necessary places in the API to make this possible.
String and Object vars used to be PP_Resources. But it is not practical to
assocaited strings with an instance since then we can't have implicit var
constructors and have to litter every string with an instance. So this changes
vars to use their own tracking system associated with the module (i.e. keeping
the current semantics) and making it no longer a resource. I made the internal
Var IDs 32 bits since Neb is about to land his 64->32 change.
Now it force-deletes resources associated with an instance when that instance
goes away. I added some additional code and tracking in ResourceTracker to do
this. I could then remove the Instance::Observer class since the resource can
use the (now renamed) StoppedTracking to know that it's being deleted in
response to the instance being destroyed.
TEST=ppapi ui tests
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests')
-rw-r--r-- | ppapi/tests/test_buffer.cc | 6 | ||||
-rw-r--r-- | ppapi/tests/test_char_set.cc | 47 |
2 files changed, 29 insertions, 24 deletions
diff --git a/ppapi/tests/test_buffer.cc b/ppapi/tests/test_buffer.cc index 3cb8030..fddc573 100644 --- a/ppapi/tests/test_buffer.cc +++ b/ppapi/tests/test_buffer.cc @@ -26,7 +26,7 @@ void TestBuffer::RunTest() { } std::string TestBuffer::TestInvalidSize() { - pp::Buffer_Dev zero_size(0); + pp::Buffer_Dev zero_size(instance_, 0); if (!zero_size.is_null()) return "Zero size accepted"; @@ -34,7 +34,7 @@ std::string TestBuffer::TestInvalidSize() { } std::string TestBuffer::TestInitToZero() { - pp::Buffer_Dev buffer(100); + pp::Buffer_Dev buffer(instance_, 100); if (buffer.is_null()) return "Could not create buffer"; @@ -66,7 +66,7 @@ std::string TestBuffer::TestIsBuffer() { return "Device context was reported as a buffer"; // Make a valid buffer. - pp::Buffer_Dev buffer(100); + pp::Buffer_Dev buffer(instance_, 100); if (buffer.is_null()) return "Couldn't create buffer"; if (!buffer_interface_->IsBuffer(buffer.pp_resource())) diff --git a/ppapi/tests/test_char_set.cc b/ppapi/tests/test_char_set.cc index c760a01..acc381f 100644 --- a/ppapi/tests/test_char_set.cc +++ b/ppapi/tests/test_char_set.cc @@ -32,7 +32,7 @@ std::string TestCharSet::TestUTF16ToCharSet() { utf16.push_back(0); uint32_t utf8result_len = 0; char* utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], 0, "latin1", + instance_->pp_instance(), &utf16[0], 0, "latin1", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(utf8result); ASSERT_TRUE(utf8result[0] == 0); @@ -43,8 +43,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { std::string utf8source("Hello, world. \xe4\xbd\xa0\xe5\xa5\xbd"); utf16 = UTF8ToUTF16(utf8source); utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "Utf-8", - PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "Utf-8", PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); ASSERT_TRUE(utf8source == std::string(utf8result, utf8result_len)); pp::Module::Get()->core()->MemFree(utf8result); @@ -54,15 +54,15 @@ std::string TestCharSet::TestUTF16ToCharSet() { // Fail mode. utf8result_len = 1234; // Test that this gets 0'ed on failure. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_FAIL, &utf8result_len); ASSERT_TRUE(utf8result_len == 0); ASSERT_TRUE(utf8result == NULL); // Skip mode. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_SKIP, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_SKIP, &utf8result_len); ASSERT_TRUE(utf8result_len == 2); ASSERT_TRUE(utf8result[0] == 'h' && utf8result[1] == 'i' && utf8result[2] == 0); @@ -70,8 +70,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { // Substitute mode. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(utf8result_len == 3); ASSERT_TRUE(utf8result[0] == 'h' && utf8result[1] == '?' && utf8result[2] == 'i' && utf8result[3] == 0); @@ -82,8 +82,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { utf16.push_back(0xD800); // High surrogate. utf16.push_back('A'); // Not a low surrogate. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "latin1", - PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "latin1", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(utf8result_len == 2); ASSERT_TRUE(utf8result[0] == '?' && utf8result[1] == 'A' && utf8result[2] == 0); @@ -91,8 +91,8 @@ std::string TestCharSet::TestUTF16ToCharSet() { // Invalid encoding name. utf8result = char_set_interface_->UTF16ToCharSet( - &utf16[0], static_cast<uint32_t>(utf16.size()), "poopiepants", - PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); + instance_->pp_instance(), &utf16[0], static_cast<uint32_t>(utf16.size()), + "poopiepants", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf8result_len); ASSERT_TRUE(!utf8result); ASSERT_TRUE(utf8result_len == 0); @@ -103,7 +103,8 @@ std::string TestCharSet::TestCharSetToUTF16() { // Empty string. uint32_t utf16result_len; uint16_t* utf16result = char_set_interface_->CharSetToUTF16( - "", 0, "latin1", PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); + instance_->pp_instance(), "", 0, "latin1", + PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 0); ASSERT_TRUE(utf16result[0] == 0); @@ -111,7 +112,8 @@ std::string TestCharSet::TestCharSetToUTF16() { // Basic Latin1. char latin1[] = "H\xef"; utf16result = char_set_interface_->CharSetToUTF16( - latin1, 2, "latin1", PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); + instance_->pp_instance(), latin1, 2, "latin1", + PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 2); ASSERT_TRUE(utf16result[0] == 'H' && utf16result[1] == 0xef && @@ -120,13 +122,15 @@ std::string TestCharSet::TestCharSetToUTF16() { // Invalid input encoding with FAIL. char badutf8[] = "A\xe4Z"; utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "utf8", PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); + instance_->pp_instance(), badutf8, 3, "utf8", + PP_CHARSET_CONVERSIONERROR_FAIL, &utf16result_len); ASSERT_TRUE(!utf16result); ASSERT_TRUE(utf16result_len == 0); // Invalid input with SKIP. utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "utf8", PP_CHARSET_CONVERSIONERROR_SKIP, &utf16result_len); + instance_->pp_instance(), badutf8, 3, "utf8", + PP_CHARSET_CONVERSIONERROR_SKIP, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 2); ASSERT_TRUE(utf16result[0] == 'A' && utf16result[1] == 'Z' && @@ -134,8 +138,8 @@ std::string TestCharSet::TestCharSetToUTF16() { // Invalid input with SUBSTITUTE. utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "utf8", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, - &utf16result_len); + instance_->pp_instance(), badutf8, 3, "utf8", + PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf16result_len); ASSERT_TRUE(utf16result); ASSERT_TRUE(utf16result_len == 3); ASSERT_TRUE(utf16result[0] == 'A' && utf16result[1] == 0xFFFD && @@ -143,7 +147,7 @@ std::string TestCharSet::TestCharSetToUTF16() { // Invalid encoding name. utf16result = char_set_interface_->CharSetToUTF16( - badutf8, 3, "poopiepants", + instance_->pp_instance(), badutf8, 3, "poopiepants", PP_CHARSET_CONVERSIONERROR_SUBSTITUTE, &utf16result_len); ASSERT_TRUE(!utf16result); ASSERT_TRUE(utf16result_len == 0); @@ -154,7 +158,8 @@ std::string TestCharSet::TestCharSetToUTF16() { std::vector<uint16_t> TestCharSet::UTF8ToUTF16(const std::string& utf8) { uint32_t result_len = 0; uint16_t* result = char_set_interface_->CharSetToUTF16( - utf8.c_str(), static_cast<uint32_t>(utf8.size()), + instance_->pp_instance(), utf8.c_str(), + static_cast<uint32_t>(utf8.size()), "utf-8", PP_CHARSET_CONVERSIONERROR_FAIL, &result_len); std::vector<uint16_t> result_vector; |