tests/ceftests/values_unittest.cc
// Test association of a CefValue list with a CefListValue.
Test association of a CefValue list with a CefListValue.
Test association of a CefValue list with a CefListValue .
TEST(ValuesTest, ValueListToList) {
  CefRefPtr<CefListValue> list_value = CreateListValue();
  CefRefPtr<CefValue> value = CefValue::Create();
  EXPECT_TRUE(value->SetList(list_value));
  CefRefPtr<CefListValue> target_list = CefListValue::Create();
  EXPECT_TRUE(target_list->SetValue(0, value));
  EXPECT_FALSE(list_value->IsValid());
  EXPECT_TRUE(value->IsValid());
  CefRefPtr<CefListValue> list_value2 = value->GetList();
  CefRefPtr<CefListValue> list_value3 = target_list->GetList(0);
  CefRefPtr<CefValue> value2 = target_list->GetValue(0);
  CefRefPtr<CefListValue> list_value4 = value2->GetList();
  EXPECT_TRUE(value->IsOwned());
  EXPECT_TRUE(value2->IsOwned());
  EXPECT_TRUE(list_value2->IsOwned());
  EXPECT_TRUE(list_value3->IsOwned());
  EXPECT_TRUE(list_value4->IsOwned());
  EXPECT_TRUE(list_value2->IsSame(list_value3));
  TestListEqual(list_value2, list_value3);
  EXPECT_TRUE(list_value2->IsSame(list_value4));
  TestListEqual(list_value2, list_value4);
  EXPECT_TRUE(target_list->SetInt(0, kIntValue));
  EXPECT_EQ(VTYPE_INT, target_list->GetType(0));
  EXPECT_EQ(kIntValue, target_list->GetInt(0));
  EXPECT_FALSE(value->IsValid());
  EXPECT_FALSE(value2->IsValid());
  EXPECT_FALSE(list_value2->IsValid());
  EXPECT_FALSE(list_value3->IsValid());
  EXPECT_FALSE(list_value4->IsValid());
  list_value = CreateListValue();
  value = CefValue::Create();
  EXPECT_TRUE(value->SetList(list_value));
  target_list->SetList(0, list_value);
  EXPECT_FALSE(list_value->IsValid());
  EXPECT_FALSE(value->IsValid());
}
TEST ( ValuesTest , ValueListToList ) { CefRefPtr < CefListValue > list_value = CreateListValue ( ) ; CefRefPtr < CefValue > value = CefValue :: Create ( ) ; EXPECT_TRUE ( value -> SetList ( list_value ) ) ; CefRefPtr < CefListValue > target_list = CefListValue :: Create ( ) ; EXPECT_TRUE ( target_list -> SetValue ( 0 , value ) ) ; EXPECT_FALSE ( list_value -> IsValid ( ) ) ; EXPECT_TRUE ( value -> IsValid ( ) ) ; CefRefPtr < CefListValue > list_value2 = value -> GetList ( ) ; CefRefPtr < CefListValue > list_value3 = target_list -> GetList ( 0 ) ; CefRefPtr < CefValue > value2 = target_list -> GetValue ( 0 ) ; CefRefPtr < CefListValue > list_value4 = value2 -> GetList ( ) ; EXPECT_TRUE ( value -> IsOwned ( ) ) ; EXPECT_TRUE ( value2 -> IsOwned ( ) ) ; EXPECT_TRUE ( list_value2 -> IsOwned ( ) ) ; EXPECT_TRUE ( list_value3 -> IsOwned ( ) ) ; EXPECT_TRUE ( list_value4 -> IsOwned ( ) ) ; EXPECT_TRUE ( list_value2 -> IsSame ( list_value3 ) ) ; TestListEqual ( list_value2 , list_value3 ) ; EXPECT_TRUE ( list_value2 -> IsSame ( list_value4 ) ) ; TestListEqual ( list_value2 , list_value4 ) ; EXPECT_TRUE ( target_list -> SetInt ( 0 , kIntValue ) ) ; EXPECT_EQ ( VTYPE_INT , target_list -> GetType ( 0 ) ) ; EXPECT_EQ ( kIntValue , target_list -> GetInt ( 0 ) ) ; EXPECT_FALSE ( value -> IsValid ( ) ) ; EXPECT_FALSE ( value2 -> IsValid ( ) ) ; EXPECT_FALSE ( list_value2 -> IsValid ( ) ) ; EXPECT_FALSE ( list_value3 -> IsValid ( ) ) ; EXPECT_FALSE ( list_value4 -> IsValid ( ) ) ; list_value = CreateListValue ( ) ; value = CefValue :: Create ( ) ; EXPECT_TRUE ( value -> SetList ( list_value ) ) ; target_list -> SetList ( 0 , list_value ) ; EXPECT_FALSE ( list_value -> IsValid ( ) ) ; EXPECT_FALSE ( value -> IsValid ( ) ) ; }
Test association of a CefValue list with a CefListValue.
Test association of a CefValue list with a CefListValue .
// Create the list. // Add the list to a value. // Add the value to the target list. // The list value is now owned by the target list. // The value is still valid and points to the new reference list. // All values are owned by the target list. // All values are the same. // Change the value to something else. // Now the references are invalid. // Verify that adding a list to a list directly invalidates both the list // and the value that references it.