Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void JavaSideContextConstructorForwardsArgument ()
new JValue (Application.Context))) {
Assert.AreEqual (1, ConstructorActivationContextView.ConstructorInvocations);
Assert.IsNotNull (instance.ContextValue);
Assert.AreEqual (Application.Context.Handle, instance.ContextValue.Handle);
AssertSameJavaObject (Application.Context, instance.ContextValue);
}
}

Expand All @@ -110,7 +110,7 @@ public void JavaSideContextAttributeSetConstructorForwardsArguments ()
JValue.Zero)) {
Assert.AreEqual (1, ConstructorActivationAttributeSetView.ConstructorInvocations);
Assert.IsNotNull (instance.ContextValue);
Assert.AreEqual (Application.Context.Handle, instance.ContextValue.Handle);
AssertSameJavaObject (Application.Context, instance.ContextValue);
Assert.IsNull (instance.AttributeSetValue);
}
}
Expand All @@ -127,7 +127,7 @@ public void JavaSideContextAttributeSetStyleConstructorForwardsArguments ()
new JValue (42))) {
Assert.AreEqual (1, ConstructorActivationStyledView.ConstructorInvocations);
Assert.IsNotNull (instance.ContextValue);
Assert.AreEqual (Application.Context.Handle, instance.ContextValue.Handle);
AssertSameJavaObject (Application.Context, instance.ContextValue);
Assert.IsNull (instance.AttributeSetValue);
Assert.AreEqual (42, instance.DefStyleAttrValue);
}
Expand Down Expand Up @@ -474,7 +474,7 @@ public void JavaSideObjectArrayConstructorForwardsValues ()
Assert.IsNotNull (instance.ObjectArrayValue);
Assert.AreEqual (2, instance.ObjectArrayValue.Length);
Assert.AreEqual ("object-array-value", instance.ObjectArrayValue [0].ToString ());
Assert.AreEqual (Application.Context.Handle, instance.ObjectArrayValue [1].Handle);
AssertSameJavaObject (Application.Context, instance.ObjectArrayValue [1]);
}
}

Expand Down Expand Up @@ -564,6 +564,15 @@ static void AssertRegisteredSame<T> (T instance)
registered.Dispose ();
}
}

static void AssertSameJavaObject (Java.Lang.Object expected, Java.Lang.Object actual)
{
Assert.IsNotNull (expected);
Assert.IsNotNull (actual);
Assert.IsTrue (
JniEnvironment.Types.IsSameObject (expected.PeerReference, actual.PeerReference),
$"Expected Java object identity to match. Expected handle: {expected.Handle}, actual handle: {actual.Handle}.");
}
}

[Register ("net/dot/android/test/ConstructorActivationThrowing")]
Expand Down