publicfinalclass UnoRuntime_Test {
@Test publicvoid test_generateOid() { // Test if UnoRuntime generates an OID for a simple class:
assertNotNull("Test1", UnoRuntime.generateOid(new Test1()));
// Test if UnoRuntime generates an OID for a class implementing // IQueryInterface and returning null from getOid:
assertNotNull("Test2", UnoRuntime.generateOid(new Test2()));
// Test if a delegator object has the same OID as its creator:
Test4 test4 = new Test4();
Ifc ifc = UnoRuntime.queryInterface(Ifc.class, test4);
assertEquals( "Test4", UnoRuntime.generateOid(ifc),
UnoRuntime.generateOid(test4));
}
@Test publicvoid test_queryInterface() { // Test if a query for an interface which is not supported returns null:
assertNull("Test1", UnoRuntime.queryInterface(Ifc.class, new Test1()));
// Test if a query for an interface which is supported through // IQueryInterface succeeds:
assertNotNull( "Test2", UnoRuntime.queryInterface(Ifc.class, new Test2()));
// Test if a query for an interface which is directly supported (through // inheritance) succeeds:
assertNotNull( "Test3", UnoRuntime.queryInterface(Ifc.class, new Test3()));
}
@Test publicvoid test_areSame() {
assertTrue(
UnoRuntime.areSame( new Any(Type.UNSIGNED_LONG, Integer.valueOf(3)), new Any(Type.UNSIGNED_LONG, Integer.valueOf(3))));
assertFalse(
UnoRuntime.areSame( new Any(Type.UNSIGNED_LONG, Integer.valueOf(3)), Integer.valueOf(3)));
assertFalse(UnoRuntime.areSame(newint[] { 1 }, newint[] { 1, 2 }));
assertTrue(
UnoRuntime.areSame(
TypeClass.UNSIGNED_LONG, new Any(new Type(TypeClass.class), TypeClass.UNSIGNED_LONG)));
assertTrue(
UnoRuntime.areSame( new Any( new Type("com.sun.star.beans.Optional<unsigned long>"), new Optional<Integer>()), new Any( new Type("com.sun.star.beans.Optional<unsigned long>"), new Optional<Integer>(false, Integer.valueOf(0)))));
assertFalse(UnoRuntime.areSame(new Test1(), new Test2()));
Test2 test2 = new Test2();
assertTrue( "Test2",
UnoRuntime.areSame(
UnoRuntime.queryInterface(Ifc.class, test2), test2));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.