Beispiel #1
0
        public void PrefixServiceNameMatchExactAndPrefix()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                // Publish 2 services on remote with same prefix
                string prefix         = remoteWFDController.GenerateUniqueServiceName();
                var    publishParams1 = new ServicesPublishParameters(
                    prefix + ".foo",
                    prefixList: new List <String> {
                    prefix
                }
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);
                var publishParams2 = new ServicesPublishParameters(
                    prefix
                    );
                WFDSvcWrapperHandle advertiser2 = ExecutePublishScenario(publishParams2);

                // Discover both services using common prefix
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    prefix + "*",
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser1, advertiser2
                },
                    expectedMatchCount: 2,
                    type: ServicesDiscoveryType.Watcher
                    );
                ExecuteDiscoveryScenario(discoveryParams1);
            }
        }
Beispiel #2
0
        public void PublishServicesLongName()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                // Publish multiple services with long names and prefixes
                string prefix1        = remoteWFDController.GenerateUniqueServiceName("com.microsoft.longnameservice.1.2.3.4.5.6.7.8.9.0.");
                var    publishParams1 = new ServicesPublishParameters(
                    prefix1 + ".foo"
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);
                var publishParams2 = new ServicesPublishParameters(
                    prefix1 + ".bar"
                    );
                WFDSvcWrapperHandle advertiser2 = ExecutePublishScenario(publishParams2);
                var publishParams3 = new ServicesPublishParameters(
                    prefix1 + ".baz"
                    );
                WFDSvcWrapperHandle advertiser3 = ExecutePublishScenario(publishParams3);
                var publishParams4 = new ServicesPublishParameters(
                    prefix1 + ".bat"
                    );
                WFDSvcWrapperHandle advertiser4 = ExecutePublishScenario(publishParams4);

                // Discover all services, NOT USING PREFIX
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    prefix1 + ".foo",
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser1
                },
                    type: ServicesDiscoveryType.Watcher
                    );
                ExecuteDiscoveryScenario(discoveryParams1);
                var discoveryParams2 = new ServicesDiscoveryParameters(
                    prefix1 + ".bar",
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser2
                },
                    type: ServicesDiscoveryType.Watcher
                    );
                ExecuteDiscoveryScenario(discoveryParams2);
                var discoveryParams3 = new ServicesDiscoveryParameters(
                    prefix1 + ".baz",
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser3
                },
                    type: ServicesDiscoveryType.Watcher
                    );
                ExecuteDiscoveryScenario(discoveryParams3);
                var discoveryParams4 = new ServicesDiscoveryParameters(
                    prefix1 + ".bat",
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser4
                },
                    type: ServicesDiscoveryType.Watcher
                    );
                ExecuteDiscoveryScenario(discoveryParams4);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
0
        List <WFDSvcWrapperHandle> ExecuteDiscoveryScenario(ServicesDiscoveryParameters discoveryParams)
        {
            ServicesDiscoveryScenario       discoveryScenario       = new ServicesDiscoveryScenario(localWFDController, remoteWFDController, discoveryParams);
            ServicesDiscoveryScenarioResult discoveryScenarioResult = discoveryScenario.Execute();

            Verify.IsTrue(discoveryScenarioResult.ScenarioSucceeded);

            return(discoveryScenarioResult.DiscoveryHandles);
        }
 public ServicesDiscoveryScenario(
     WiFiDirectTestController discoveryTestController,
     WiFiDirectTestController advertiserTestController,
     ServicesDiscoveryParameters discoveryParameters
     )
 {
     this.discoveryTestController  = discoveryTestController;
     this.advertiserTestController = advertiserTestController;
     this.discoveryParameters      = discoveryParameters;
 }
Beispiel #6
0
 public ServicesDiscoveryPrePublishParameters(
     string query,
     uint expectedMatchCount = 1,
     List <int> advertisersToMatchIndices   = null,
     ServicesDiscoveryType type             = ServicesDiscoveryType.FindAllAsync,
     string serviceInfoRequest              = "",
     List <bool> advertiserServiceInfoMatch = null
     )
 {
     Parameters = new ServicesDiscoveryParameters(query, expectedMatchCount, null, type, serviceInfoRequest, advertiserServiceInfoMatch);
     AdvertisersToMatchIndices = advertisersToMatchIndices;
 }
Beispiel #7
0
 public void NoMatchDiscovery()
 {
     using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
     {
         // Discover service from local side, using name remote side could publish
         var discoveryParams = new ServicesDiscoveryParameters(
             remoteWFDController.GenerateUniqueServiceName(),
             0
             );
         ExecuteDiscoveryScenario(discoveryParams);
     }
 }
Beispiel #8
0
        public void MultipleDiscoveries()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                // Publish 2 services on remote
                var publishParams1 = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName()
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);
                var publishParams2 = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName()
                    );
                WFDSvcWrapperHandle advertiser2 = ExecutePublishScenario(publishParams2);

                // Quick sanity check that the service names are different
                Verify.AreNotEqual(publishParams1.ServiceName, publishParams2.ServiceName);

                // Discover same services from local
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    publishParams1.ServiceName,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser1
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams1);

                var discoveryParams2 = new ServicesDiscoveryParameters(
                    publishParams2.ServiceName,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser2
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams2);

                // Publish 3rd service on remote
                var publishParams3 = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName()
                    );
                WFDSvcWrapperHandle advertiser3 = ExecutePublishScenario(publishParams3);

                Verify.AreNotEqual(publishParams3.ServiceName, publishParams1.ServiceName);
                Verify.AreNotEqual(publishParams3.ServiceName, publishParams2.ServiceName);

                // Discover 3rd service from local
                var discoveryParams3 = new ServicesDiscoveryParameters(
                    publishParams3.ServiceName,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser3
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams3);
            }
        }
Beispiel #9
0
        public void ServiceInfoMaxSize()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                string       serviceInfo = "";
                Random       rng         = new Random();
                const string s_chars     = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()_-+={}][|;:'<>,./?~` ";

                StringBuilder builder = new StringBuilder();
                // make a string of 65000 ASCII characters
                // First write 10000 random characters
                // Next write 7 characters to match
                // Then write 54993 random characters
                for (int i = 0; i < 10000; i++)
                {
                    builder.Append(s_chars[rng.Next(s_chars.Length)]);
                }
                builder.Append("foo_bar");
                for (int i = 0; i < 54993; i++)
                {
                    builder.Append(s_chars[rng.Next(s_chars.Length)]);
                }
                serviceInfo = builder.ToString();

                var publishParams1 = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName(),
                    serviceInfo: serviceInfo
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);

                // Discover service with info
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    publishParams1.ServiceName,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser1
                },
                    type: ServicesDiscoveryType.Watcher,
                    serviceInfoRequest: "foo_bar",
                    advertiserServiceInfoMatch: new List <bool> {
                    true
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams1);
            }
        }
Beispiel #10
0
        public void ServiceInfoMultipleMatchSameServicePrefix()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                string prefix         = remoteWFDController.GenerateUniqueServiceName();
                var    publishParams1 = new ServicesPublishParameters(
                    prefix + ".foo",
                    prefixList: new List <String> {
                    prefix
                },
                    serviceInfo: "this is some example service info. It will match the requested info"
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);
                var publishParams2 = new ServicesPublishParameters(
                    prefix,
                    serviceInfo: "Here is another set of service info. It also has the word example"
                    );
                WFDSvcWrapperHandle advertiser2 = ExecutePublishScenario(publishParams2);
                var publishParams3 = new ServicesPublishParameters(
                    prefix + ".bar",
                    prefixList: new List <String> {
                    prefix
                },
                    serviceInfo: "This service will match without service info. Not expected to find this"
                    );
                WFDSvcWrapperHandle advertiser3 = ExecutePublishScenario(publishParams3);

                // Discover all services using same name
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    prefix + "*",
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser1, advertiser2, advertiser3
                },
                    expectedMatchCount: 3,
                    type: ServicesDiscoveryType.Watcher,
                    serviceInfoRequest: "example",
                    advertiserServiceInfoMatch: new List <bool> {
                    true, true, false
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams1);
            }
        }
Beispiel #11
0
        public void PrefixServiceNameMatchingSpecific()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                // Publish 2 services on remote with same prefix, 3rd service with different prefix
                string prefix         = remoteWFDController.GenerateUniqueServiceName();
                var    publishParams1 = new ServicesPublishParameters(
                    prefix + ".1.foo",
                    prefixList: new List <String> {
                    prefix, prefix + ".1"
                }
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);
                var publishParams2 = new ServicesPublishParameters(
                    prefix + ".1.bar",
                    prefixList: new List <String> {
                    prefix, prefix + ".1", prefix + ".1."
                }
                    );
                WFDSvcWrapperHandle advertiser2 = ExecutePublishScenario(publishParams2);
                var publishParams3 = new ServicesPublishParameters(
                    prefix + ".2.foo",
                    prefixList: new List <String> {
                    prefix, prefix + ".2"
                }
                    );
                WFDSvcWrapperHandle advertiser3 = ExecutePublishScenario(publishParams3);

                // Discover first 2 services using common prefix
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    prefix + ".1*",
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser1, advertiser2
                },
                    expectedMatchCount: 2
                    );
                ExecuteDiscoveryScenario(discoveryParams1);
            }
        }
Beispiel #12
0
        public void UnPublishNoMatchDiscovery()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                // Publish one service on remote
                var publishParams = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName()
                    );
                WFDSvcWrapperHandle advertiser = ExecutePublishScenario(publishParams);

                // Unpublish service
                var unpublishParams = new ServicesUnpublishParameters(advertiser);
                ExecuteUnpublishScenario(unpublishParams);

                // Discover same service from local, should not be found
                var discoveryParams = new ServicesDiscoveryParameters(
                    publishParams.ServiceName,
                    0
                    );
                ExecuteDiscoveryScenario(discoveryParams);
            }
        }
Beispiel #13
0
        public void ExactServiceNameMatchingSkipsPrefixes()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                // Publish 2 services on remote with same prefix, 3rd service with name==prefix
                string prefix         = remoteWFDController.GenerateUniqueServiceName();
                var    publishParams1 = new ServicesPublishParameters(
                    prefix + ".1",
                    prefixList: new List <String> {
                    prefix
                }
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);
                var publishParams2 = new ServicesPublishParameters(
                    prefix + ".2",
                    prefixList: new List <String> {
                    prefix
                }
                    );
                WFDSvcWrapperHandle advertiser2 = ExecutePublishScenario(publishParams2);
                var publishParams3 = new ServicesPublishParameters(
                    prefix
                    );
                WFDSvcWrapperHandle advertiser3 = ExecutePublishScenario(publishParams3);

                // Discover last service only, don't discover prefixed services
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    prefix,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser3
                },
                    expectedMatchCount: 1
                    );
                ExecuteDiscoveryScenario(discoveryParams1);
            }
        }