Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
WSPProxyTest Class Reference

#include <wspproxytest.h>

Inheritance diagram for WSPProxyTest:
Inheritance graph
[legend]
Collaboration diagram for WSPProxyTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 WSPProxyTest ()
virtual ~WSPProxyTest ()
AString testComplexTypeWrapper ()
AString testPropertyBagWrapper ()
void testIsPrimeProxy (in nsIWSPProxyTestListener aListener)
void onLoad (in nsIWSDLPort port)
void onError (in nsresult status, in AString statusMessage)
void onError (in nsIException error, in nsIWebServiceCallContext cx)
void getStatisticsCallback (in statisticStruct retval, in nsIWebServiceCallContext cx)
void isPrimeNumberCallback (in boolean retval, in nsIWebServiceCallContext cx)
void crossSumCallback (in PRInt32 retval, in nsIWebServiceCallContext cx)

Protected Member Functions

nsresult CreateComplexTypeWrapper (nsIWebServiceComplexTypeWrapper **aWrapper, nsIInterfaceInfo **aInfo)
nsresult TestComplexTypeWrapperInstance (nsIPropertyBag *propBag, nsAString &aResult)

Protected Attributes

nsCOMPtr< nsIWSPProxyTestListenermListener
nsCOMPtr
< SpheonJSAOPStatisticsPortTypeAsync
mProxy

Detailed Description

Definition at line 47 of file wspproxytest.h.


Constructor & Destructor Documentation

Definition at line 67 of file wspproxytest.cpp.

{
}

Definition at line 71 of file wspproxytest.cpp.

{
}

Member Function Documentation

void nsIWebServiceErrorHandler::onError ( in nsresult  status,
in AString  statusMessage 
) [inherited]
AString nsIWSPProxyTest::testComplexTypeWrapper ( ) [inherited]
nsresult WSPProxyTest::TestComplexTypeWrapperInstance ( nsIPropertyBag propBag,
nsAString &  aResult 
) [protected]

Definition at line 144 of file wspproxytest.cpp.

{
  nsCOMPtr<nsISimpleEnumerator> enumerator;
  nsresult rv = propBag->GetEnumerator(getter_AddRefs(enumerator));
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Failed getting property bag enumerator");
    return rv;
  }

  nsCOMPtr<nsISupports> sup;
  nsCOMPtr<nsIProperty> prop;
  nsCOMPtr<nsIVariant> val;
  nsAutoString propName;

#define GET_AND_TEST_NAME(_name)                                          \
    rv = enumerator->GetNext(getter_AddRefs(sup));                        \
    if (NS_FAILED(rv)) {                                                  \
      aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting property ") + NS_LITERAL_STRING(#_name));    \
      return rv;                                                          \
    }                                                                     \
                                                                          \
    prop = do_QueryInterface(sup, &rv);                                   \
    if (NS_FAILED(rv)) {                                                  \
      return rv;                                                          \
    }                                                                     \
                                                                          \
    prop->GetName(propName);                                              \
    if (!propName.EqualsLiteral(#_name)) {                    \
      aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Name doesn't match for property ") + NS_LITERAL_STRING(#_name)); \
      return NS_ERROR_FAILURE;                                            \
    }                                                                     \
    prop->GetValue(getter_AddRefs(val));                                  \
    if (!val) {                                                           \
      return NS_ERROR_FAILURE;                                            \
    }                                                                     

#define GET_AND_TEST(_t, _n, _name, _val)                                   \
    GET_AND_TEST_NAME(_name)                                                \
    _t _name;                                                               \
    rv = val->GetAs##_n(&_name);                                            \
    if (NS_FAILED(rv)) {                                                    \
      aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Failed getting value for property ") + NS_LITERAL_STRING(#_name)); \
      return rv;                                                            \
    }                                                                       \
    if (_name != _val) {                                                    \
      aResult.Assign(NS_LITERAL_STRING("WSPProxyTest: Value doesn't match for property ") + NS_LITERAL_STRING(#_name)); \
      return NS_ERROR_FAILURE;                                              \
    }                                                                       
                                                                             
  GET_AND_TEST(PRUint8, Int8, i8, sInt8Val)
  GET_AND_TEST(PRInt16, Int16, i16, sInt16Val)
  GET_AND_TEST(PRInt32, Int32, i32, sInt32Val)
  GET_AND_TEST(PRInt64, Int64, i64, sInt64Val)
  GET_AND_TEST(PRUint8, Uint8, u8, sUint8Val)
  GET_AND_TEST(PRUint16, Uint16, u16, sUint16Val)
  GET_AND_TEST(PRUint32, Uint32, u32, sUint32Val)
  GET_AND_TEST(PRUint64, Uint64, u64, sUint64Val)
  GET_AND_TEST(PRBool, Bool, b, sBoolVal)
  GET_AND_TEST(float, Float, f, sFloatVal)
  GET_AND_TEST(double, Double, d, sDoubleVal)
  GET_AND_TEST(char, Char, c, sCharVal)
  GET_AND_TEST(PRUnichar, WChar, wc, sWcharVal)

  GET_AND_TEST_NAME(s);
  nsAutoString str;
  rv = val->GetAsAString(str);
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Failed getting value for property s");
    return rv;
  }

  if (!str.EqualsLiteral(STRING_VAL)) {
    aResult.AssignLiteral("WSPProxyTest: Value doesn't match for property s");
    return NS_ERROR_FAILURE;
  }

  GET_AND_TEST_NAME(p)
  nsCOMPtr<nsISupports> supVal;  
  rv = val->GetAsISupports(getter_AddRefs(supVal));  
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Failed getting value for property p");
    return rv;
  }
  nsCOMPtr<nsIPropertyBag> propBagVal = do_QueryInterface(supVal, &rv);
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Value doesn't match for property p");
    return rv;
  }

  GET_AND_TEST_NAME(p2)
  PRUint16 dataType;
  val->GetDataType(&dataType);
  if (dataType != nsIDataType::VTYPE_EMPTY) {
    aResult.AssignLiteral("WSPProxyTest: Value doesn't match for property p");
    return NS_ERROR_FAILURE;
  }

  PRUint16 type;
  PRUint32 index, count;
  PRUint32* arrayVal1;

  GET_AND_TEST_NAME(array1)
  nsIID iid;
  rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal1);
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Failed getting value for property array1");
    return rv;
  }
  for (index = 0; index < count; index++) {
    if (arrayVal1[index] != sArray1[index]) {
      aResult.AssignLiteral("WSPProxyTest: Value doesn't match for element of property array1");
      return rv;      
    }
  }
  nsMemory::Free(arrayVal1);

  double* arrayVal2;
  GET_AND_TEST_NAME(array2)
  rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal2);
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Failed getting value for property array2");
    return rv;
  }
  for (index = 0; index < count; index++) {
    if (arrayVal2[index] != sArray2[index]) {
      aResult.AssignLiteral("WSPProxyTest: Value doesn't match for element of property array2");
      return rv;      
    }
  }
  nsMemory::Free(arrayVal2);

  nsISupports** arrayVal3;
  GET_AND_TEST_NAME(array3)
  rv = val->GetAsArray(&type, &iid, &count, (void**)&arrayVal3);
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Failed getting value for property array3");
    return rv;
  }
  propBagVal = do_QueryInterface(arrayVal3[0], &rv);
  if (NS_FAILED(rv)) {
    aResult.AssignLiteral("WSPProxyTest: Value doesn't match for element of property array3");
    return rv;
  }
  if (arrayVal3[1] != nsnull) {
    aResult.AssignLiteral("WSPProxyTest: Value doesn't match for element of  property array3");
    return NS_ERROR_FAILURE;
  }
  NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, arrayVal3);

#undef GET_AND_TEST
#undef GET_AND_TEST_NAME

  aResult.AssignLiteral("WSPProxyTest: Test Succeeded!");
  return NS_OK;
}

Here is the call graph for this function:

AString nsIWSPProxyTest::testPropertyBagWrapper ( ) [inherited]

Member Data Documentation

Definition at line 66 of file wspproxytest.h.

Definition at line 67 of file wspproxytest.h.


The documentation for this class was generated from the following files: