tests/ceftests/values_unittest.cc
// Test association of a CefValue binary with a CefListValue.
Test association of a CefValue binary with a CefListValue.
Test association of a CefValue binary with a CefListValue .
TEST(ValuesTest, ValueBinaryToList) {
  CefRefPtr<CefBinaryValue> binary_value = CreateBinaryValue();
  CefRefPtr<CefValue> value = CefValue::Create();
  EXPECT_TRUE(value->SetBinary(binary_value));
  CefRefPtr<CefListValue> target_list = CefListValue::Create();
  EXPECT_TRUE(target_list->SetValue(0, value));
  EXPECT_FALSE(binary_value->IsValid());
  EXPECT_TRUE(value->IsValid());
  CefRefPtr<CefBinaryValue> binary_value2 = value->GetBinary();
  CefRefPtr<CefBinaryValue> binary_value3 = target_list->GetBinary(0);
  CefRefPtr<CefValue> value2 = target_list->GetValue(0);
  CefRefPtr<CefBinaryValue> binary_value4 = value2->GetBinary();
  EXPECT_TRUE(value->IsOwned());
  EXPECT_TRUE(value2->IsOwned());
  EXPECT_TRUE(binary_value2->IsOwned());
  EXPECT_TRUE(binary_value3->IsOwned());
  EXPECT_TRUE(binary_value4->IsOwned());
  EXPECT_TRUE(binary_value2->IsSame(binary_value3));
  TestBinaryEqual(binary_value2, binary_value3);
  EXPECT_TRUE(binary_value2->IsSame(binary_value4));
  TestBinaryEqual(binary_value2, binary_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(binary_value2->IsValid());
  EXPECT_FALSE(binary_value3->IsValid());
  EXPECT_FALSE(binary_value4->IsValid());
  binary_value = CreateBinaryValue();
  value = CefValue::Create();
  EXPECT_TRUE(value->SetBinary(binary_value));
  target_list->SetBinary(0, binary_value);
  EXPECT_FALSE(binary_value->IsValid());
  EXPECT_FALSE(value->IsValid());
}
TEST ( ValuesTest , ValueBinaryToList ) { CefRefPtr < CefBinaryValue > binary_value = CreateBinaryValue ( ) ; CefRefPtr < CefValue > value = CefValue :: Create ( ) ; EXPECT_TRUE ( value -> SetBinary ( binary_value ) ) ; CefRefPtr < CefListValue > target_list = CefListValue :: Create ( ) ; EXPECT_TRUE ( target_list -> SetValue ( 0 , value ) ) ; EXPECT_FALSE ( binary_value -> IsValid ( ) ) ; EXPECT_TRUE ( value -> IsValid ( ) ) ; CefRefPtr < CefBinaryValue > binary_value2 = value -> GetBinary ( ) ; CefRefPtr < CefBinaryValue > binary_value3 = target_list -> GetBinary ( 0 ) ; CefRefPtr < CefValue > value2 = target_list -> GetValue ( 0 ) ; CefRefPtr < CefBinaryValue > binary_value4 = value2 -> GetBinary ( ) ; EXPECT_TRUE ( value -> IsOwned ( ) ) ; EXPECT_TRUE ( value2 -> IsOwned ( ) ) ; EXPECT_TRUE ( binary_value2 -> IsOwned ( ) ) ; EXPECT_TRUE ( binary_value3 -> IsOwned ( ) ) ; EXPECT_TRUE ( binary_value4 -> IsOwned ( ) ) ; EXPECT_TRUE ( binary_value2 -> IsSame ( binary_value3 ) ) ; TestBinaryEqual ( binary_value2 , binary_value3 ) ; EXPECT_TRUE ( binary_value2 -> IsSame ( binary_value4 ) ) ; TestBinaryEqual ( binary_value2 , binary_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 ( binary_value2 -> IsValid ( ) ) ; EXPECT_FALSE ( binary_value3 -> IsValid ( ) ) ; EXPECT_FALSE ( binary_value4 -> IsValid ( ) ) ; binary_value = CreateBinaryValue ( ) ; value = CefValue :: Create ( ) ; EXPECT_TRUE ( value -> SetBinary ( binary_value ) ) ; target_list -> SetBinary ( 0 , binary_value ) ; EXPECT_FALSE ( binary_value -> IsValid ( ) ) ; EXPECT_FALSE ( value -> IsValid ( ) ) ; }
Test association of a CefValue binary with a CefListValue.
Test association of a CefValue binary with a CefListValue .
// Create the binary. // Add the binary to a value. // Add the value to the target list. // The binary 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 binary to a list directly invalidates both the binary // and the value that references it.