Exemplo n.º 1
0
        private void ExecuteInternal()
        {
            try
            {
                WiFiDirectTestLogger.Log("Beginning Discover/Connect scenario");

                // Do all discovers
                foreach (var discoveryParams in discoveryConnectParameters.DiscoveryParameters)
                {
                    var discoveryScenario = new ServicesDiscoveryScenario(seekerTestController, advertiserTestController, discoveryParams);
                    ServicesDiscoveryScenarioResult discoveryResult = discoveryScenario.Execute();
                    discoveryResults.Add(discoveryResult);

                    if (!discoveryResult.ScenarioSucceeded)
                    {
                        throw new Exception("Discovery failed!");
                    }
                }

                // BUG: [TH2] Fix race on back-to-back discoveries
                Task.Delay(500).Wait();

                // Do all connects
                foreach (var connectPreParams in discoveryConnectParameters.ConnectParameters)
                {
                    // Need to translate indices to handles
                    if (connectPreParams.DiscoveryResultIndex > discoveryResults.Count ||
                        connectPreParams.DiscoveryResultIndex < 0 ||
                        connectPreParams.DiscoveredHandleIndex > discoveryResults[connectPreParams.DiscoveryResultIndex].DiscoveryHandles.Count ||
                        connectPreParams.DiscoveredHandleIndex < 0)
                    {
                        throw new Exception("Bad connect parameters! Index out of range for discovered device");
                    }
                    WFDSvcWrapperHandle discoveredDevice = discoveryResults[connectPreParams.DiscoveryResultIndex].DiscoveryHandles[connectPreParams.DiscoveredHandleIndex];

                    // Now run scenario

                    ServicesConnectParameters connectParams = new ServicesConnectParameters(
                        discoveredDevice,
                        connectPreParams.AdvertiserHandle,
                        connectPreParams.Options
                        );

                    var connectScenario = new ServicesConnectScenario(seekerTestController, advertiserTestController, connectParams);
                    ServicesConnectScenarioResult connectResult = connectScenario.Execute();
                    connectResults.Add(connectResult);

                    if (!connectResult.ScenarioSucceeded)
                    {
                        throw new Exception("Connect failed!");
                    }
                }

                succeeded = true;
            }
            catch (Exception e)
            {
                WiFiDirectTestLogger.Error("Caught exception while executing service discover/connect scenario: {0}", e);
            }
        }
Exemplo n.º 2
0
        private void ExecuteInternal()
        {
            try
            {
                WiFiDirectTestLogger.Log("Beginning Publish/Discover scenario");

                // Do all publications
                foreach (var publishParams in publishDiscoveryParameters.PublishParameters)
                {
                    var publishScenario = new ServicesPublishScenario(advertiserTestController, publishParams);
                    ServicesPublishScenarioResult publishResult = publishScenario.Execute();
                    publishResults.Add(publishResult);

                    if (!publishResult.ScenarioSucceeded)
                    {
                        throw new Exception("Publication failed!");
                    }
                }

                // Do all discoveries
                foreach (var discoveryPreParams in publishDiscoveryParameters.DiscoveryParameters)
                {
                    // Need to translate indices to handles
                    List <WFDSvcWrapperHandle> advertisersToMatch = new List <WFDSvcWrapperHandle>();
                    foreach (int i in discoveryPreParams.AdvertisersToMatchIndices)
                    {
                        if (i > publishResults.Count || i < 0)
                        {
                            throw new Exception("Bad discovery parameters! Index out of range");
                        }
                        advertisersToMatch.Add(publishResults[i].AdvertiserHandle);
                    }
                    ServicesDiscoveryParameters discoveryParams = new ServicesDiscoveryParameters(
                        discoveryPreParams.Parameters.Query,
                        discoveryPreParams.Parameters.ExpectedMatchCount,
                        advertisersToMatch,
                        discoveryPreParams.Parameters.Type,
                        discoveryPreParams.Parameters.ServiceInfoRequest,
                        discoveryPreParams.Parameters.AdvertiserServiceInfoMatch
                        );
                    var discoveryScenario = new ServicesDiscoveryScenario(discoveryTestController, advertiserTestController, discoveryParams);
                    ServicesDiscoveryScenarioResult discoveryResult = discoveryScenario.Execute();
                    discoveryResults.Add(discoveryResult);

                    if (!discoveryResult.ScenarioSucceeded)
                    {
                        throw new Exception("Discovery failed!");
                    }
                }

                succeeded = true;
            }
            catch (Exception e)
            {
                WiFiDirectTestLogger.Error("Caught exception while executing service publish/discovery scenario: {0}", e);
            }
        }
Exemplo n.º 3
0
        List <WFDSvcWrapperHandle> ExecuteDiscoveryScenario(ServicesDiscoveryParameters discoveryParams)
        {
            ServicesDiscoveryScenario       discoveryScenario       = new ServicesDiscoveryScenario(localWFDController, remoteWFDController, discoveryParams);
            ServicesDiscoveryScenarioResult discoveryScenarioResult = discoveryScenario.Execute();

            Verify.IsTrue(discoveryScenarioResult.ScenarioSucceeded);

            return(discoveryScenarioResult.DiscoveryHandles);
        }