示例#1
0
        public void TestMethodSetup()
        {
            Verify.IsTrue(localWFDController.Reset());
            Verify.IsTrue(remoteWFDController.Reset());

            // Also try to remove existing DAF association (if it exists)
            localWFDController.TryRemoveDafAssociation(remoteWFDController.DeviceAddress);
            remoteWFDController.TryRemoveDafAssociation(localWFDController.DeviceAddress);

            localWFDController.WaitForAllWFDSessionClose(true);
            remoteWFDController.WaitForAllWFDSessionClose(true);

            localWFDController.FlushVisibleDeviceList();
            remoteWFDController.FlushVisibleDeviceList();
        }
        private void ExecuteInternal()
        {
            try
            {
                if (discoverTestIe)
                {
                    remoteWFDController.SetTestIe();
                }

                if (discoveryScenarioType == DiscoveryScenarioType.DiscoverAsDevice)
                {
                    // Enable listen state on the remote device if it is not already enabled.
                    remoteWFDController.ConfigureListenState(true);
                }
                else if (discoveryScenarioType == DiscoveryScenarioType.DiscoverAsGo)
                {
                    // Start autonomous GO on the remote device if it is not already running
                    remoteWFDController.StartAutonomousGo();
                }

                // Flush the visible device list on the local device
                localWFDController.FlushVisibleDeviceList();

                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                WfdDeviceDescriptor discoveredDeviceDescriptor;
                if (isTargetedDiscovery)
                {
                    discoveredDeviceDescriptor = PerformTargetedDiscovery();
                }
                else
                {
                    discoveredDeviceDescriptor = PerformWildcardDiscovery();
                }

                if (discoveredDeviceDescriptor == null)
                {
                    return;
                }

                WiFiDirectTestLogger.Log("Successfully discovered device {0} ({1})", remoteWFDController.DeviceAddress, remoteWFDController.MachineName);

                stopwatch.Stop();
                WiFiDirectTestLogger.Log("Discovery completed in {0} ms.", stopwatch.ElapsedMilliseconds);

                if (discoverTestIe)
                {
                    Guid discoveredGuid;
                    bool parsed = TestIeManager.TryParseIeBuffer(discoveredDeviceDescriptor.IE, out discoveredGuid);
                    if (!parsed)
                    {
                        WiFiDirectTestLogger.Error("Expected vendor extension IE not present in discovery result.");
                        return;
                    }

                    if (discoveredGuid == remoteWFDController.CurrentIEGuid)
                    {
                        WiFiDirectTestLogger.Log("Validated expected GUID {0} is present in vendor extension IE.", discoveredGuid);
                    }
                    else
                    {
                        WiFiDirectTestLogger.Error("Found incorrect GUID in vendor extension IE.  Expected: {0}, Found: {1}", remoteWFDController.CurrentIEGuid, discoveredGuid);
                        return;
                    }
                }

                succeeded = true;
            }
            catch (Exception e)
            {
                WiFiDirectTestLogger.Error("Caught exception while running discovery scenario: {0}", e);
            }
        }