tests/ceftests/values_unittest.cc
// Test association of a CefValue list with a CefDictionaryValue.
Test association of a CefValue list with a CefDictionaryValue.
Test association of a CefValue list with a CefDictionaryValue .
TEST(ValuesTest, ValueListToDictionary) {
  const char* key = "key";
  CefRefPtr<CefListValue> list_value = CreateListValue();
  CefRefPtr<CefValue> value = CefValue::Create();
  EXPECT_TRUE(value->SetList(list_value));
  CefRefPtr<CefDictionaryValue> target_dict = CefDictionaryValue::Create();
  EXPECT_TRUE(target_dict->SetValue(key, value));
  EXPECT_FALSE(list_value->IsValid());
  EXPECT_TRUE(value->IsValid());
  CefRefPtr<CefListValue> list_value2 = value->GetList();
  CefRefPtr<CefListValue> list_value3 = target_dict->GetList(key);
  CefRefPtr<CefValue> value2 = target_dict->GetValue(key);
  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_dict->SetInt(key, kIntValue));
  EXPECT_EQ(VTYPE_INT, target_dict->GetType(key));
  EXPECT_EQ(kIntValue, target_dict->GetInt(key));
  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_dict->SetList(key, list_value);
  EXPECT_FALSE(list_value->IsValid());
  EXPECT_FALSE(value->IsValid());
}
TEST ( ValuesTest , ValueListToDictionary ) { const char * key = " " ; CefRefPtr < CefListValue > list_value = CreateListValue ( ) ; CefRefPtr < CefValue > value = CefValue :: Create ( ) ; EXPECT_TRUE ( value -> SetList ( list_value ) ) ; CefRefPtr < CefDictionaryValue > target_dict = CefDictionaryValue :: Create ( ) ; EXPECT_TRUE ( target_dict -> SetValue ( key , value ) ) ; EXPECT_FALSE ( list_value -> IsValid ( ) ) ; EXPECT_TRUE ( value -> IsValid ( ) ) ; CefRefPtr < CefListValue > list_value2 = value -> GetList ( ) ; CefRefPtr < CefListValue > list_value3 = target_dict -> GetList ( key ) ; CefRefPtr < CefValue > value2 = target_dict -> GetValue ( key ) ; 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_dict -> SetInt ( key , kIntValue ) ) ; EXPECT_EQ ( VTYPE_INT , target_dict -> GetType ( key ) ) ; EXPECT_EQ ( kIntValue , target_dict -> GetInt ( key ) ) ; 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_dict -> SetList ( key , list_value ) ; EXPECT_FALSE ( list_value -> IsValid ( ) ) ; EXPECT_FALSE ( value -> IsValid ( ) ) ; }
Test association of a CefValue list with a CefDictionaryValue.
Test association of a CefValue list with a CefDictionaryValue .
// Create the list. // Add the list to a value. // Add the value to the target dictionary. // The list value is now owned by the target dictionary. // The value is still valid and points to the new reference list. // All values are owned by the target dictionary. // All values are the same. // Change the value to something else. // Now the references are invalid. // Verify that adding a list to a dictionary directly invalidates both the // list and the value that references it.