Beispiel #1
0
void OpenHome::TestFramework::Runner::Main(TInt /*aArgc*/, TChar* /*aArgv*/[], Net::InitialisationParams* aInitParams)
{
    Debug::AddLevel(Debug::kAdapterChange);
    aInitParams->SetIncludeLoopbackNetworkAdapter();
    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    ASSERT(subnetList->size() > 1);
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::StartCombined(subnet);

    Semaphore* sem = new Semaphore("TEST", 0);
    DeviceBasic* dvDevice = new DeviceBasic(*gDvStack);
    CpDevices* cpDevice = new CpDevices(*gEnv, *sem, dvDevice->Udn());
    LogSubnet("Starting", subnet);
    cpDevice->Start();
    cpDevice->Test();
    subnet = (*subnetList)[1]->Subnet();
    LogSubnet("Switching", subnet);
    cpDevice->SetSubnet(subnet);
    cpDevice->Test();
    subnet = (*subnetList)[0]->Subnet();
    LogSubnet("Switching", subnet);
    cpDevice->SetSubnet(subnet);
    cpDevice->Test();
        
    delete sem;
    delete cpDevice;
    delete dvDevice;
    UpnpLibrary::DestroySubnetList(subnetList);

    UpnpLibrary::Close();
}
Beispiel #2
0
void TestDvSubscription()
{
    InitialisationParams& initParams = Stack::InitParams();
    TUint oldMsearchTime = initParams.MsearchTimeSecs();
    initParams.SetMsearchTime(1);
    Print("TestDvSubscription - starting\n");

    Semaphore* sem = new Semaphore("SEM1", 0);
    DeviceBasic* device = new DeviceBasic;
    CpDevices* deviceList = new CpDevices(*sem, device->Udn());
    FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &CpDevices::Added);
    FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &CpDevices::Removed);
    Brn domainName("openhome.org");
    Brn serviceType("TestBasic");
    TUint ver = 1;
    CpDeviceListUpnpServiceType* list =
                new CpDeviceListUpnpServiceType(domainName, serviceType, ver, added, removed);
    sem->Wait(30*1000); // allow up to 30 seconds to issue the msearch and receive a response
    delete sem;
    deviceList->Test();
    delete list;
    delete deviceList;
    delete device;

    Print("TestDvSubscription - completed\n");
    initParams.SetMsearchTime(oldMsearchTime);
}
Beispiel #3
0
void OpenHome::TestFramework::Runner::Main(TInt aArgc, TChar* aArgv[], InitialisationParams* aInitParams)
{
    OptionParser parser;
    OptionBool loopback("-l", "--loopback", "Use the loopback adapter only");
    parser.AddOption(&loopback);
    if (!parser.Parse(aArgc, aArgv) || parser.HelpDisplayed()) {
        return;
    }
    if (loopback.Value()) {
        aInitParams->SetUseLoopbackNetworkAdapter();
    }
    aInitParams->SetMsearchTime(1);
    aInitParams->SetDvUpnpServerPort(0);
    UpnpLibrary::Initialise(aInitParams);
    std::vector<NetworkAdapter*>* subnetList = UpnpLibrary::CreateSubnetList();
    TIpAddress subnet = (*subnetList)[0]->Subnet();
    UpnpLibrary::DestroySubnetList(subnetList);
    UpnpLibrary::StartCombined(subnet);
    //Debug::SetLevel(Debug::kEvent | Debug::kDvEvent);

    Print("TestDvDeviceStd - starting\n");

    Semaphore* sem = new Semaphore("SEM1", 0);
    DeviceBasic* device = new DeviceBasic(DeviceBasic::eProtocolUpnp);
    CpDevices* deviceList = new CpDevices(device->Device().Udn(), *sem);
    FunctorCpDeviceCpp added = MakeFunctorCpDeviceCpp(*deviceList, &CpDevices::Added);
    FunctorCpDeviceCpp removed = MakeFunctorCpDeviceCpp(*deviceList, &CpDevices::Removed);
    std::string domainName("openhome.org");
    std::string serviceType("TestBasic");
    TUint ver = 1;
    CpDeviceListCppUpnpServiceType* list =
                new CpDeviceListCppUpnpServiceType(domainName, serviceType, ver, added, removed);
    sem->Wait(30*1000); // allow up to 30s to find our one device
    try {
        deviceList->TestActions();
        Functor cb = MakeFunctor(sem, &DeviceDisabled);
        device->Device().SetDisabled(cb);
        sem->Wait();
        deviceList->TestThrows();
        device->Device().SetEnabled();
        deviceList->TestSubscriptions();
    }
    catch (Exception& e) {
        Print("Exception %s from %s:%u\n", e.Message(), e.File(), e.Line());
        ASSERTS();
    }
    delete sem;
    delete list;
    delete deviceList;
    delete device;

    Print("TestDvDeviceStd - completed\n");
    UpnpLibrary::Close();
}
Beispiel #4
0
void TestCpDeviceDv(CpStack& aCpStack, DvStack& aDvStack)
{
    Print("TestCpDeviceDv - starting\n");

    DeviceBasic* device = new DeviceBasic(aDvStack);
    CpDeviceDv* cpDevice = CpDeviceDv::New(aCpStack, device->Device());
    TestInvocation(*cpDevice);
    TestSubscription(*cpDevice);
    cpDevice->RemoveRef();
    delete device;

    Print("TestCpDeviceDv - completed\n");
}
Beispiel #5
0
void OpenHome::TestFramework::Runner::Main(TInt /*aArgc*/, TChar* /*aArgv*/[], InitialisationParams* aInitParams)
{
    aInitParams->SetUseLoopbackNetworkInterface();
    UpnpLibrary::Initialise(aInitParams);
    UpnpLibrary::StartCombined();

    Print("TestCpDeviceDv - starting\n");

    DeviceBasic* device = new DeviceBasic;
    CpDeviceDv* cpDevice = CpDeviceDv::New(device->Device());
    TestInvocation(*cpDevice);
    TestSubscription(*cpDevice);
    cpDevice->RemoveRef();
    delete device;

    Print("TestCpDeviceDv - completed\n");
    UpnpLibrary::Close();
}