Index: ppapi/proxy/raw_var_data_unittest.cc |
diff --git a/ppapi/proxy/raw_var_data_unittest.cc b/ppapi/proxy/raw_var_data_unittest.cc |
index 2b134af1d840788038c6d2af9629d6125e2ff1c3..33e060bc9523b501237973ad044297b6b6d5b802 100644 |
--- a/ppapi/proxy/raw_var_data_unittest.cc |
+++ b/ppapi/proxy/raw_var_data_unittest.cc |
@@ -44,21 +44,28 @@ class RawVarDataTest : public testing::Test { |
TestGlobals globals_; |
}; |
-PP_Var WriteAndRead(const PP_Var& var) { |
+bool WriteAndRead(const PP_Var& var, PP_Var* result, bool allow_cycles) { |
PP_Instance dummy_instance = 1234; |
scoped_ptr<RawVarDataGraph> expected_data(RawVarDataGraph::Create( |
- var, dummy_instance)); |
+ var, dummy_instance, allow_cycles)); |
+ if (!expected_data) |
+ return false; |
IPC::Message m; |
expected_data->Write(&m); |
PickleIterator iter(m); |
scoped_ptr<RawVarDataGraph> actual_data(RawVarDataGraph::Read(&m, &iter)); |
- return actual_data->CreatePPVar(dummy_instance); |
+ *result = actual_data->CreatePPVar(dummy_instance); |
+ return true; |
} |
// Assumes a ref for var. |
bool WriteReadAndCompare(const PP_Var& var) { |
ScopedPPVar expected(ScopedPPVar::PassRef(), var); |
- ScopedPPVar actual(ScopedPPVar::PassRef(), WriteAndRead(expected.get())); |
+ PP_Var result; |
+ bool success = WriteAndRead(expected.get(), &result, false); |
+ if (!success) |
+ return false; |
+ ScopedPPVar actual(ScopedPPVar::PassRef(), result); |
return TestEqual(expected.get(), actual.get()); |
} |
@@ -160,24 +167,27 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) { |
// Array <-> dictionary cycle. |
dictionary->SetWithStringKey("10", release_array.get()); |
- ScopedPPVar result = ScopedPPVar(ScopedPPVar::PassRef(), |
- WriteAndRead(release_dictionary.get())); |
- EXPECT_TRUE(TestEqual(release_dictionary.get(), result.get())); |
+ PP_Var result; |
+ ASSERT_FALSE(WriteAndRead(release_dictionary.get(), &result, false)); |
+ ASSERT_TRUE(WriteAndRead(release_dictionary.get(), &result, true)); |
+ ScopedPPVar release_result = ScopedPPVar(ScopedPPVar::PassRef(), result); |
+ EXPECT_TRUE(TestEqual(release_dictionary.get(), result)); |
// Break the cycle. |
// TODO(raymes): We need some better machinery for releasing vars with |
// cycles. Remove the code below once we have that. |
dictionary->DeleteWithStringKey("10"); |
- DictionaryVar* result_dictionary = DictionaryVar::FromPPVar(result.get()); |
+ DictionaryVar* result_dictionary = DictionaryVar::FromPPVar(result); |
result_dictionary->DeleteWithStringKey("10"); |
// Array with self references. |
array->Set(index, release_array.get()); |
- result = ScopedPPVar(ScopedPPVar::PassRef(), |
- WriteAndRead(release_array.get())); |
- EXPECT_TRUE(TestEqual(release_array.get(), result.get())); |
+ ASSERT_FALSE(WriteAndRead(release_array.get(), &result, false)); |
+ ASSERT_TRUE(WriteAndRead(release_array.get(), &result, true)); |
+ release_result = ScopedPPVar(ScopedPPVar::PassRef(), result); |
+ EXPECT_TRUE(TestEqual(release_array.get(), result)); |
// Break the self reference. |
array->Set(index, PP_MakeUndefined()); |
- ArrayVar* result_array = ArrayVar::FromPPVar(result.get()); |
+ ArrayVar* result_array = ArrayVar::FromPPVar(result); |
result_array->Set(index, PP_MakeUndefined()); |
} |