public void TestWindowSupportsSafeAreaEnabled() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.MultiviewToggleSafeArea, helper => { var cmds = helper.Server.GetParsedDataDump().OfType <MultiviewWindowInputGetCommand>().ToList(); foreach (Tuple <uint, IBMDSwitcherMultiView> mv in GetMultiviewers(helper)) { mv.Item2.CanToggleSafeAreaEnabled(out int supported); Assert.Equal(1, supported); mv.Item2.SupportsQuadrantLayout(out int supportsQuadrant); int[] windows = Randomiser .SelectionOfGroup(Enumerable.Range(0, supportsQuadrant == 0 ? 10 : 16).ToList()).ToArray(); foreach (int window in windows) { AtemState stateBefore = helper.Helper.BuildLibState(); MultiViewerState.WindowState windowState = stateBefore.Settings.MultiViewers[(int)mv.Item1].Windows[window]; MultiviewWindowInputGetCommand cmd = cmds.Single(c => c.WindowIndex == window && c.MultiviewIndex == mv.Item1); for (int i = 0; i < 5; i++) { windowState.SupportsSafeArea = cmd.SupportsSafeArea = !windowState.SupportsSafeArea; helper.SendFromServerAndWaitForChange(stateBefore, cmd); } } } }); }
public void TestPreviewInput() { var ignorePortTypes = new HashSet <InternalPortType> { InternalPortType.Mask, InternalPortType.Auxiliary, InternalPortType.MEOutput }; bool tested = false; var handler = CommandGenerator.CreateAutoCommandHandler <PreviewInputSetCommand, PreviewInputGetCommand>("Source", true); AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper => { // TODO - this could be better and use the availabilitymask List <VideoSource> validSources = helper.Helper.BuildLibState().Settings.Inputs .Where(s => !ignorePortTypes.Contains(s.Value.Properties.InternalPortType)).Select(s => s.Key) .ToList(); VideoSource[] sampleSources = Randomiser.SelectionOfGroup(validSources).ToArray(); EachMixEffect <IBMDSwitcherMixEffectBlock>(helper, (stateBefore, meBefore, sdk, meId, i) => { tested = true; VideoSource target = sampleSources[i]; meBefore.Sources.Preview = target; helper.SendAndWaitForChange(stateBefore, () => { sdk.SetPreviewInput((long)target); }); }, sampleSources.Length); }); Assert.True(tested); }
public void TestVuMeterEnabled() { var handler = CommandGenerator.CreateAutoCommandHandler <MultiviewWindowVuMeterSetCommand, MultiviewWindowVuMeterGetCommand>("VuEnabled", true); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.MultiviewVuMeters, helper => { foreach (Tuple <uint, IBMDSwitcherMultiView> mv in GetMultiviewers(helper)) { mv.Item2.SupportsVuMeters(out int supportsVu); Assert.Equal(1, supportsVu); mv.Item2.SupportsQuadrantLayout(out int supportsQuadrant); int[] windows = Randomiser .SelectionOfGroup(Enumerable.Range(0, supportsQuadrant == 0 ? 10 : 16).ToList()).ToArray(); foreach (int window in windows) { AtemState stateBefore = helper.Helper.BuildLibState(); for (int i = 0; i < 5; i++) { bool newValue = i % 2 == 0; stateBefore.Settings.MultiViewers[(int)mv.Item1].Windows[window].VuMeterEnabled = newValue; helper.SendAndWaitForChange(stateBefore, () => { mv.Item2.SetVuMeterEnabled((uint)window, newValue ? 1 : 0); }); } } } }); }
protected static void EachSuperSourceBox(AtemMockServerWrapper helper, Action <AtemState, SuperSourceState.BoxState, IBMDSwitcherSuperSourceBox, SuperSourceId, SuperSourceBoxId, int> fcn, int iterations = 5) { var allBoxes = new List <Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> >(); foreach (KeyValuePair <VideoSource, IBMDSwitcherInputSuperSource> ssrc in helper.GetSdkInputsOfType <IBMDSwitcherInputSuperSource>()) { SuperSourceId id = (SuperSourceId)(ssrc.Key - VideoSource.SuperSource); var iterator = AtemSDKConverter.CastSdk <IBMDSwitcherSuperSourceBoxIterator>(ssrc.Value.CreateIterator); AtemSDKConverter.Iterate <IBMDSwitcherSuperSourceBox>(iterator.Next, (box, i) => { allBoxes.Add(Tuple.Create(id, (SuperSourceBoxId)i, box)); }); } var boxes = Randomiser.SelectionOfGroup(allBoxes); foreach (Tuple <SuperSourceId, SuperSourceBoxId, IBMDSwitcherSuperSourceBox> box in boxes) { AtemState stateBefore = helper.Helper.BuildLibState(); SuperSourceState.BoxState boxBefore = stateBefore.SuperSources[(int)box.Item1].Boxes[(int)box.Item2]; Assert.NotNull(boxBefore); for (int i = 0; i < iterations; i++) { fcn(stateBefore, boxBefore, box.Item3, box.Item1, box.Item2, i); } } }
public void TestStyle() { bool tested = false; var handler = CommandGenerator.CreateAutoCommandHandler <TransitionDVESetCommand, TransitionDVEGetCommand>("Style"); AtemMockServerWrapper.Each(Output, Pool, handler, DeviceTestCases.All, helper => { EachMixEffect <IBMDSwitcherTransitionDVEParameters>(helper, (stateBefore, meBefore, sdk, meId, i) => { if (stateBefore.Info.DVE != null && stateBefore.Info.DVE.SupportedTransitions.Count > 0) { var selection = Randomiser .SelectionOfGroup(stateBefore.Info.DVE.SupportedTransitions.ToList(), 3).ToList(); tested = true; Assert.NotNull(meBefore.Transition.DVE); foreach (DVEEffect style in selection) { meBefore.Transition.DVE.Style = style; helper.SendAndWaitForChange(stateBefore, () => { sdk.SetStyle(AtemEnumMaps.DVEStyleMap[style]); }); } } }); }); Assert.True(tested); }
internal static void EachRandomSource(AtemMockServerWrapper helper, Action <AtemState, FairlightAudioState.InputSourceState, long, IBMDSwitcherFairlightAudioSource, int> fcn, int maxIterations = 5, bool useAll = false) { List <long> useIds = helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList(); if (!useAll) { useIds = Randomiser.SelectionOfGroup(useIds, 2).ToList(); } foreach (long id in useIds) { helper.Helper.SyncStates(); IBMDSwitcherFairlightAudioSource src = GetSource(helper, id); src.GetId(out long sourceId); AtemState stateBefore = helper.Helper.BuildLibState(); FairlightAudioState.InputSourceState srcState = stateBefore.Fairlight.Inputs[id].Sources.Single(s => s.SourceId == sourceId); for (int i = 0; i < maxIterations; i++) { fcn(stateBefore, srcState, id, src, i); } } }
public void TestTally() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper => { List <VideoSource> inputIds = helper.Helper.BuildLibState().Settings.Inputs .Where(i => i.Value.Properties.InternalPortType == InternalPortType.External).Select(i => i.Key) .ToList(); TallyBySourceCommand tallyCmd = helper.Server.GetParsedDataDump().OfType <TallyBySourceCommand>().Single(); foreach (VideoSource id in Randomiser.SelectionOfGroup(inputIds)) { AtemState stateBefore = helper.Helper.BuildLibState(); InputState.TallyState tallyState = stateBefore.Settings.Inputs[id].Tally; for (int i = 0; i < 5; i++) { bool isProgram = tallyState.ProgramTally = Randomiser.RangeInt(10) > 5; bool isPreview = tallyState.PreviewTally = Randomiser.RangeInt(10) > 5; tallyCmd.Tally[id] = Tuple.Create(isProgram, isPreview); helper.SendFromServerAndWaitForChange(stateBefore, tallyCmd); } } }); }
public void TestActiveConfiguration() { var handler = CommandGenerator.CreateAutoCommandHandler <FairlightMixerInputSetCommand, FairlightMixerInputGetCommand>("ActiveConfiguration"); bool tested = false; AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.FairlightMain, helper => { IEnumerable <long> useIds = Randomiser.SelectionOfGroup(helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList()); foreach (long id in useIds) { IBMDSwitcherFairlightAudioInput input = GetInput(helper, id); AtemState stateBefore = helper.Helper.BuildLibState(); FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id]; var testConfigs = AtemSDKConverter.GetFlagsValues(input.GetSupportedConfigurations, AtemEnumMaps.FairlightInputConfigurationMap); // Need more than 1 config to allow for switching around if (1 == testConfigs.Count) { continue; } tested = true; for (int i = 0; i < 5; i++) { var target = testConfigs[i % testConfigs.Count]; inputState.ActiveConfiguration = target.Item2; helper.SendAndWaitForChange(stateBefore, () => { input.SetConfiguration(target.Item1); }); } } }); Assert.True(tested); }
public void TestInput() { var handler = CommandGenerator.CreateAutoCommandHandler <HyperDeckSettingsSetCommand, HyperDeckSettingsGetCommand>( "Input"); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.HyperDecks, helper => { var possibleValues = helper.Helper.BuildLibState().Settings.Inputs .Where(s => s.Value.Properties.InternalPortType == InternalPortType.External).Select(s => s.Key) .ToList(); possibleValues.Add(VideoSource.Black); foreach (IBMDSwitcherHyperDeck deck in GetHyperDecks(helper)) { List <VideoSource> selectedValues = Randomiser.SelectionOfGroup(possibleValues).ToList(); foreach (VideoSource src in selectedValues) { deck.GetId(out long id); AtemState stateBefore = helper.Helper.BuildLibState(); HyperdeckState hyperdeckState = stateBefore.Hyperdecks[(int)id]; hyperdeckState.Settings.Input = src; helper.SendAndWaitForChange(stateBefore, () => { deck.SetSwitcherInput((long)src); }); } } }); }
private static List <Tuple <IBMDSwitcherFairlightAudioEqualizerBand, uint> > GetSampleOfBands(IBMDSwitcherFairlightAudioEqualizer eq) { var it = AtemSDKConverter.CastSdk <IBMDSwitcherFairlightAudioEqualizerBandIterator>(eq.CreateIterator); var allBands = AtemSDKConverter .IterateList <IBMDSwitcherFairlightAudioEqualizerBand, Tuple <IBMDSwitcherFairlightAudioEqualizerBand, uint> >(it.Next, Tuple.Create); return(Randomiser.SelectionOfGroup(allBands, 3).ToList()); }
public void TestAddRemoveSources() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.FairlightMain, helper => { IEnumerable <long> useIds = Randomiser.SelectionOfGroup(helper.Helper.BuildLibState().Fairlight.Inputs.Keys.ToList()); foreach (long id in useIds) { helper.Helper.SyncStates(); IBMDSwitcherFairlightAudioInput input = GetInput(helper, id); AtemState stateBefore = helper.Helper.BuildLibState(); FairlightAudioState.InputState inputState = stateBefore.Fairlight.Inputs[id]; inputState.Sources.Add(new FairlightAudioState.InputSourceState { SourceId = 944, MixOption = FairlightAudioMixOption.Off, Gain = -23.7, }); int sourceId = 944; void mangleState(AtemState sdkState, AtemState libState) { FairlightAudioState.InputSourceState srcState = sdkState.Fairlight.Inputs[id].Sources.Single(s => s.SourceId == sourceId); srcState.Dynamics.Limiter = null; srcState.Dynamics.Compressor = null; srcState.Dynamics.Expander = null; } helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(new FairlightMixerSourceGetCommand { Index = (AudioSource)id, SourceId = sourceId, MixOption = FairlightAudioMixOption.Off, Gain = -23.7, }); }, -1, mangleState); var removeSourceId = inputState.Sources[0].SourceId; inputState.Sources.RemoveAt(0); helper.SendAndWaitForChange(stateBefore, () => { helper.Server.SendCommands(new FairlightMixerSourceDeleteCommand { Index = (AudioSource)id, SourceId = removeSourceId, }); }, -1, mangleState); } }); }
protected static void SelectionOfKeyers <T>(AtemMockServerWrapper helper, Action <AtemState, MixEffectState.KeyerState, T, MixEffectBlockId, UpstreamKeyId, int> fcn, int iterations = 5) where T : class { var keyers = GetKeyers <T>(helper); var useKeyers = Randomiser.SelectionOfGroup(keyers); foreach (Tuple <MixEffectBlockId, UpstreamKeyId, T> keyer in useKeyers) { AtemState stateBefore = helper.Helper.BuildLibState(); MixEffectState.KeyerState keyerBefore = stateBefore.MixEffects[(int)keyer.Item1].Keyers[(int)keyer.Item2]; for (int i = 0; i < iterations; i++) { fcn(stateBefore, keyerBefore, keyer.Item3, keyer.Item1, keyer.Item2, i); } } }
public void TestLongName() { LongNameHandler worker = null; AtemMockServerWrapper.Each(_output, _pool, (a, b) => worker?.HandleCommand(a, b), DeviceTestCases.MultiviewLabelSample, helper => { helper.DisposeSdkClient = true; List <VideoSource> inputIds = helper.Helper.BuildLibState().Settings.Inputs.Keys.ToList(); foreach (VideoSource id in Randomiser.SelectionOfGroup(inputIds)) { AtemState stateBefore = helper.Helper.BuildLibState(); IBMDSwitcherInput input = GetInput(helper, id); bool hasMultiviewers = stateBefore.Info.MultiViewers != null; // TODO - this should really use a real byte count worker = new LongNameHandler(0, _output, id, hasMultiviewers); string newName = Guid.NewGuid().ToString().Substring(0, 20); stateBefore.Settings.Inputs[id].Properties.LongName = newName; // Send the change input.SetLongName(newName); if (hasMultiviewers) { // Process the upload helper.HandleUntil(worker.Wait, 5000); Assert.True(worker.Wait.WaitOne(500)); } // TODO remove this, but we need to ensure we let the work queue drain sufficiently helper.HandleUntil(null, 1000); // The name property should be updated helper.Helper.CheckStateChanges(stateBefore); } }); }
public void TestResetNames() { var expectedCmd = new InputNameResetCommand(); AtemMockServerWrapper.Each(_output, _pool, CommandGenerator.MatchCommand(expectedCmd), DeviceTestCases.All, helper => { List <VideoSource> inputIds = helper.Helper.BuildLibState().Settings.Inputs.Keys.ToList(); foreach (VideoSource id in Randomiser.SelectionOfGroup(inputIds)) { AtemState stateBefore = helper.Helper.BuildLibState(); expectedCmd.Id = id; IBMDSwitcherInput input = GetInput(helper, id); helper.SendAndWaitForChange(stateBefore, () => { input.ResetNames(); }); } }); }
public void TestSetVideoMode() { var handler = CommandGenerator.CreateAutoCommandHandler <VideoModeSetCommand, VideoModeGetCommand>("VideoMode", true); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper => { AtemState stateBefore = helper.Helper.BuildLibState(); IBMDSwitcher switcher = helper.SdkClient.SdkSwitcher; List <VideoMode> possibleModes = Enum.GetValues(typeof(VideoMode)).OfType <VideoMode>().Where(v => { switcher.DoesSupportVideoMode(AtemEnumMaps.VideoModesMap[v], out int supported); return(supported != 0); }).ToList(); foreach (VideoMode videoMode in Randomiser.SelectionOfGroup(possibleModes, 5)) { stateBefore.Settings.VideoMode = videoMode; helper.SendAndWaitForChange(stateBefore, () => { switcher.SetVideoMode(AtemEnumMaps.VideoModesMap[videoMode]); }); } });
public void TestShortName() { var handler = CommandGenerator.CreateAutoCommandHandler <InputPropertiesSetCommand, InputPropertiesGetCommand>("ShortName"); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper => { List <VideoSource> inputIds = helper.Helper.BuildLibState().Settings.Inputs.Keys.ToList(); foreach (VideoSource id in Randomiser.SelectionOfGroup(inputIds)) { AtemState stateBefore = helper.Helper.BuildLibState(); IBMDSwitcherInput input = GetInput(helper, id); for (int i = 0; i < 5; i++) { string newName = Guid.NewGuid().ToString().Substring(0, 4); stateBefore.Settings.Inputs[id].Properties.ShortName = newName; helper.SendAndWaitForChange(stateBefore, () => { input.SetShortName(newName); }); } } }); }
public void TestSource() { AtemMockServerWrapper.Each(_output, _pool, SourceCommandHandler, DeviceTestCases.MultiviewRouteInputs, helper => { VideoSource[] validSources = helper.Helper.BuildLibState().Settings.Inputs .Where(i => i.Value.Properties.SourceAvailability.HasFlag(SourceAvailability.Multiviewer)) .Select(i => i.Key).ToArray(); foreach (Tuple <uint, IBMDSwitcherMultiView> mv in GetMultiviewers(helper)) { mv.Item2.CanRouteInputs(out int supported); Assert.Equal(1, supported); mv.Item2.SupportsQuadrantLayout(out int supportsQuadrant); int[] windows = Randomiser .SelectionOfGroup(Enumerable.Range(supportsQuadrant == 0 ? 2 : 0, supportsQuadrant == 0 ? 8 : 16).ToList()).ToArray(); foreach (int window in windows) { AtemState stateBefore = helper.Helper.BuildLibState(); MultiViewerState.WindowState windowState = stateBefore.Settings.MultiViewers[(int)mv.Item1].Windows[window]; //var sampleSources = VideoSourceUtil.TakeSelection(validSources); var sampleSources = Randomiser.SelectionOfGroup(validSources.ToList(), 5); foreach (VideoSource src in sampleSources) { windowState.Source = src; helper.SendAndWaitForChange(stateBefore, () => { mv.Item2.SetWindowInput((uint)window, (long)src); }); } } } }); }
public void TestCurrentExternalPortType() { bool tested = false; var handler = CommandGenerator.CreateAutoCommandHandler <InputPropertiesSetCommand, InputPropertiesGetCommand>("ExternalPortType"); AtemMockServerWrapper.Each(_output, _pool, handler, DeviceTestCases.All, helper => { AtemState tmpState = helper.Helper.BuildLibState(); List <VideoSource> inputIds = tmpState.Settings.Inputs.Keys.Where(i => tmpState.Settings.Inputs[i].Properties.AvailableExternalPortTypes.Count > 1).ToList(); foreach (VideoSource id in Randomiser.SelectionOfGroup(inputIds)) { AtemState stateBefore = helper.Helper.BuildLibState(); InputState inputState = stateBefore.Settings.Inputs[id]; IBMDSwitcherInput input = GetInput(helper, id); List <VideoPortType> targets = Randomiser.SelectionOfGroup(inputState.Properties.AvailableExternalPortTypes.ToList()) .ToList(); tested = true; foreach (VideoPortType value in targets) { _BMDSwitcherExternalPortType value2 = AtemEnumMaps.VideoPortTypeMap[value]; inputState.Properties.CurrentExternalPortType = value; helper.SendAndWaitForChange(stateBefore, () => { input.SetCurrentExternalPortType(value2); }); } } }); Assert.True(tested); }
public void TestAreNamesDefault() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper => { List <VideoSource> inputIds = helper.Helper.BuildLibState().Settings.Inputs.Keys.ToList(); foreach (VideoSource id in Randomiser.SelectionOfGroup(inputIds)) { AtemState stateBefore = helper.Helper.BuildLibState(); InputState.PropertiesState inputState = stateBefore.Settings.Inputs[id].Properties; var cmd = helper.Server.GetParsedDataDump() .OfType <InputPropertiesGetCommand>().Single(c => c.Id == id); IBMDSwitcherInput input = GetInput(helper, id); for (int i = 0; i < 5; i++) { inputState.AreNamesDefault = cmd.AreNamesDefault = !inputState.AreNamesDefault; helper.SendFromServerAndWaitForChange(stateBefore, cmd); } } }); }
public void TestAvailableExternalPortType() { AtemMockServerWrapper.Each(_output, _pool, null, DeviceTestCases.All, helper => { List <VideoSource> inputIds = helper.Helper.BuildLibState().Settings.Inputs.Keys.ToList(); List <InputPropertiesGetCommand> previousCommands = helper.Server.GetParsedDataDump().OfType <InputPropertiesGetCommand>().ToList(); foreach (VideoSource id in Randomiser.SelectionOfGroup(inputIds)) { AtemState stateBefore = helper.Helper.BuildLibState(); var inputCmd = previousCommands.Single(c => c.Id == id); for (int i = 0; i < 5; i++) { var portTypes = Randomiser.FlagComponents <VideoPortType>(VideoPortType.None); stateBefore.Settings.Inputs[id].Properties.AvailableExternalPortTypes = portTypes; inputCmd.AvailableExternalPorts = portTypes.CombineFlagComponents(); helper.SendFromServerAndWaitForChange(stateBefore, inputCmd); } } }); }
private List <long> SampleOfInputs(SettingsState.TalkbackState state) { return(Randomiser.SelectionOfGroup(state.Inputs.Keys.Select(k => (long)k).ToList(), 3).ToList()); }