public void LoadState_ViewModelFromPropDisposed_AssignOnlyModel() { // Arrange FakeLiveProjectAnalysisState state = new FakeLiveProjectAnalysisState(); LMProject project = Utils.CreateProject(); LMProjectVM projectVM = new LMProjectVM { Model = project }; LMProjectAnalysisVM analysisVM = new LMProjectAnalysisVM { Project = projectVM }; var panel = new Mock <Utils.IDummyCapturerPanel> (); panel.Setup(p => p.Capturer).Returns(capturerMock.Object); state.Panel = panel.Object; // Act state.LoadState(analysisVM); // Assert capturerMock.Verify(c => c.Run(It.IsAny <CaptureSettings> (), It.IsAny <MediaFile> ()), Times.Once); Assert.AreNotEqual(projectVM, state.ViewModel.Project); Assert.AreEqual(project, state.ViewModel.Project.Model); }
public void Setup() { settings.EncodingSettings.OutputFile = Path.GetTempFileName(); App.Current.DatabaseManager = new LocalDatabaseManager(); project = Utils.CreateProject(); projectVM = new LMProjectVM { Model = project }; LMProjectAnalysisVM viewModel = new LMProjectAnalysisVM(); viewModel.VideoPlayer = videoPlayerVM; viewModel.Project = projectVM; projectsManager = new ProjectAnalysisController(); projectsManager.SetViewModel(viewModel); projectsManager.Start(); KeyContext context = new KeyContext(); foreach (KeyAction action in projectsManager.GetDefaultKeyActions()) { context.AddAction(action); } App.Current.KeyContextManager.NewKeyContexts(new List <KeyContext> { context }); }
protected override void CreateViewModel(dynamic data) { ViewModel = new LMProjectAnalysisVM(); ViewModel.Project.Model = data.Project.Model; ViewModel.VideoPlayer = new VideoPlayerVM(); ViewModel.VideoPlayer.ShowCenterPlayHeadButton = false; ViewModel.VideoPlayer.ViewMode = PlayerViewOperationMode.Analysis; }
protected override void CreateViewModel(dynamic data) { ViewModel = new LMProjectAnalysisVM(); ViewModel.Project.Model = data.Project.Model; ViewModel.CaptureSettings = data.CaptureSettings; ViewModel.VideoPlayer = new VideoPlayerVM(); // FIXME: use this hack until the capturer uses a controller ViewModel.Capturer = (ICapturerBin)(Panel.GetType().GetProperty("Capturer").GetValue(Panel)); }
protected override void CreateViewModel(dynamic data) { ViewModel = new LMProjectAnalysisVM(); ViewModel.Project.Model = data.Project.Model; ViewModel.CaptureSettings = data.CaptureSettings; ViewModel.VideoPlayer = new VideoPlayerVM(); ViewModel.VideoPlayer.ViewMode = PlayerViewOperationMode.LiveAnalysisReview; ViewModel.VideoPlayer.ShowDetachButton = false; ViewModel.VideoPlayer.ShowCenterPlayHeadButton = false; // FIXME: use this hack until the capturer uses a controller ViewModel.Capturer = (ICapturerBin)(Panel.GetType().GetProperty("Capturer").GetValue(Panel)); CreateLimitation(); }
public void Setup() { state = new ProjectAnalysisState(); project = Utils.CreateProject(); projectVM = new LMProjectVM { Model = project }; analysisVM = new LMProjectAnalysisVM { Project = projectVM }; state.Panel = new Mock <IPanel> ().Object; gtkMock.Setup(g => g.SelectMediaFiles(It.IsAny <MediaFileSet> ())).Returns(true); }
/// <summary> /// Loads the file menu for a given project /// </summary> /// <param name="projectVM">Project view model.</param> public void LoadMenu(LMProjectAnalysisVM projectVM) { MainWindow window = App.Current.GUIToolkit.MainController as MainWindow; MenuItem fileMenu = ((MenuItem)window.GetUIManager().GetWidget(window.FileMenuEntry.MenuName)); MenuItem save = projectVM.SaveCommand.CreateMenuItem( Catalog.GetString("Save Project"), window.GetUIManager().AccelGroup, GeneralUIHotkeys.SAVE); RegisterMenuItem(save, fileMenu.Submenu as Menu, window.FileMenuEntry); MenuItem close = projectVM.CloseCommand.CreateMenuItem( Catalog.GetString("Close Project"), window.GetUIManager().AccelGroup, GeneralUIHotkeys.CLOSE); RegisterMenuItem(close, fileMenu.Submenu as Menu, window.FileMenuEntry); }
public void Setup() { state = new LiveProjectAnalysisState(); project = Utils.CreateProject(); projectVM = new LMProjectVM { Model = project }; analysisVM = new LMProjectAnalysisVM { Project = projectVM }; var panel = new Mock <Utils.IDummyCapturerPanel> (); panel.Setup(p => p.Capturer).Returns(capturerMock.Object); state.Panel = panel.Object; }
void AnalysisSetUp() { var viewModel = new LMProjectAnalysisVM(); viewModel.VideoPlayer = new VideoPlayerVM(); videoPlayer = viewModel.VideoPlayer; teamTagger = viewModel.TeamTagger; viewModel.Project = new LMProjectVM { Model = Utils.CreateProject() }; ControllerSetUp(viewModel); eventsController = new LMEventsController(); eventsController.SetViewModel(viewModel); eventsController.Start(); }
public void SetUp() { project = Utils.CreateProject(true); project.Periods.Add(new Period()); projectVM = new LMProjectVM { Model = project }; widgetMock = new Mock <IWidget> (); widgetMock.SetupAllProperties(); timeline = new LMPlaysTimeline(widgetMock.Object); LMProjectAnalysisVM viewModel = new LMProjectAnalysisVM { Project = projectVM }; timeline.ViewModel = viewModel; }
public async Task ShowAsync_StatEvent_MoveToPlayEditorOk() { // Arrange var projectVM = new LMProjectAnalysisVM(); projectVM.Project.Model = Utils.CreateProject(); EventEditorController eventEditor = new EventEditorController(); eventEditor.SetViewModel(projectVM); eventEditor.Start(); // Act await App.Current.EventsBroker.Publish(new EditEventEvent { TimelineEvent = new LMTimelineEvent() }); // Assert mockStateControler.Verify(e => e.MoveToModal(PlayEditorState.NAME, It.IsAny <object> (), true), Times.Once); eventEditor.Stop(); }
public async Task Setup() { App.Current.GUIToolkit = mockGuiToolkit.Object; videoPlayerController = new Mock <IVideoPlayerController> (); videoPlayerVM = new VideoPlayerVM(); videoPlayerVM.Player = videoPlayerController.Object; LMProject project = Utils.CreateProject(true); project.ProjectType = ProjectType.FileProject; projectVM = new LMProjectVM { Model = project }; playlistCollectionVM = projectVM.Playlists; LMProjectAnalysisVM viewModel = new LMProjectAnalysisVM(); viewModel.Project = projectVM; viewModel.VideoPlayer = videoPlayerVM; sut = new LMPlaylistController(); sut.SetViewModel(viewModel); await sut.Start(); }
public void Setup() { mockDialogs = new Mock <IDialogs> (); App.Current.GUIToolkit = mockGuiToolkit.Object; App.Current.Dialogs = mockDialogs.Object; videoPlayerController = new Mock <IVideoPlayerController> (); videoPlayerVM = new VideoPlayerVM(); videoPlayerVM.Player = videoPlayerController.Object; LMProject project = Utils.CreateProject(true); project.ProjectType = ProjectType.FileProject; projectVM = new LMProjectVM { Model = project }; playlistCollectionVM = projectVM.Playlists; LMProjectAnalysisVM viewModel = new LMProjectAnalysisVM(); viewModel.Project = projectVM; viewModel.VideoPlayer = videoPlayerVM; controller = new LMPlaylistController(); controller.SetViewModel(viewModel); controller.Start(); }
public async Task Setup() { App.Current.HotkeysService = new HotkeysService(); LMGeneralUIHotkeys.RegisterDefaultHotkeys(); mockToolkit = new Mock <IGUIToolkit> (); mockToolkit.SetupGet(o => o.DeviceScaleFactor).Returns(1.0f); App.Current.GUIToolkit = mockToolkit.Object; VideoPlayerVM videoPlayer = new VideoPlayerVM { CamerasConfig = new RangeObservableCollection <CameraConfig> () }; LMProject project = Utils.CreateProject(); projectVM = new LMProjectVM { Model = project }; var projectAnalysisVM = new LMProjectAnalysisVM { VideoPlayer = videoPlayer, Project = projectVM }; controller = new LMTaggingController(); controller.SetViewModel(projectAnalysisVM); await controller.Start(); teamController = new LMTeamTaggerController(); teamController.SetViewModel(projectAnalysisVM); await teamController.Start(); resetEvent = new AutoResetEvent(false); mockToolkit.Setup(x => x.Invoke(It.IsAny <EventHandler> ())).Callback((EventHandler e) => { Task actionExecution = Task.Factory.StartNew(() => e(null, null)); actionExecution.Wait(); resetEvent.Set(); }); }
async Task AnalysisSetUpAsync() { var viewModel = new LMProjectAnalysisVM(); viewModel.VideoPlayer = new VideoPlayerVM(); videoPlayer = viewModel.VideoPlayer; teamTagger = viewModel.TeamTagger; projectVM = new LMProjectVM { Model = Utils.CreateProject() }; viewModel.Project = projectVM; await ControllerSetUp(viewModel); eventsController = new LMEventsController(); eventsController.SetViewModel(viewModel); await eventsController.Start(); taggingController = new LMTaggingController(); taggingController.SetViewModel(new ProjectAnalysisVM <LMProjectVM> { VideoPlayer = videoPlayer, Project = projectVM }); await taggingController.Start(); }
/// <summary> /// Loads the tools menu for a given project /// </summary> /// <param name="projectVM">Project view model.</param> public void LoadMenu(LMProjectAnalysisVM projectVM) { MainWindow window = App.Current.GUIToolkit.MainController as MainWindow; MenuItem toolMenu = ((MenuItem)window.GetUIManager().GetWidget(window.ToolMenuEntry.MenuName)); // Add separator SeparatorMenuItem separator = new SeparatorMenuItem() { Visible = true }; (toolMenu.Submenu as Menu).Insert(separator, window.ToolMenuEntry.LastPosition); window.ToolMenuEntry.UpdateLastPosition(); // show stats menu item MenuItem show = projectVM.ShowStatsCommand.CreateMenuItem( Catalog.GetString("Show projects stats"), window.GetUIManager().AccelGroup, null); RegisterMenuItem(show, toolMenu.Submenu as Menu, window.ToolMenuEntry); // Export menu item MenuItem exportMenu = new MenuItem(Catalog.GetString("Export Project")) { Name = "ExportProjectAction", Submenu = new Menu(), Visible = true }; (toolMenu.Submenu as Menu).Insert(exportMenu, window.ToolMenuEntry.LastPosition); window.ToolMenuEntry.UpdateLastPosition(); this.MenuItems.Add(exportMenu); foreach (IProjectExporter exporter in App.Current.DependencyRegistry.RetrieveAll <IProjectExporter> (InstanceType.Default)) { AddExportEntry(exportMenu, exporter.Description, new Func <Project, bool, Task> (exporter.Export), projectVM); } }
public override void SetViewModel(IViewModel viewModel) { ViewModel = (LMProjectAnalysisVM)viewModel; }
public override void SetViewModel(IViewModel viewModel) { this.viewModel = (LMProjectAnalysisVM)viewModel; base.SetViewModel(viewModel); }
public async Task TestGameAnalysis() { Guid projectID; App.Init(); CoreServices.Init(); App.Current.DependencyRegistry.Register <VAS.DB.IFileStorage, FileStorage> (0); AddinsManager.Initialize(App.Current.PluginsConfigDir, App.Current.PluginsDir); App.Current.DrawingToolkit = drawingToolkitMock.Object; App.Current.MultimediaToolkit = multimediaToolkitMock.Object; App.Current.GUIToolkit = guiToolkitMock.Object; App.Current.Dialogs = mockDialogs.Object; App.Current.Config.AutoSave = true; App.Current.LicenseManager = mockLicenseManager.Object; App.Current.LicenseLimitationsService = mockLicenseLimitationService.Object; App.Current.PreviewService = new Mock <IPreviewService> ().Object; CoreServices.Start(App.Current.GUIToolkit, App.Current.MultimediaToolkit); // Start importing templates App.Current.TeamTemplatesProvider.Save( App.Current.TeamTemplatesProvider.LoadFile(Utils.SaveResource("spain.ltt", tmpPath))); App.Current.TeamTemplatesProvider.Save( App.Current.TeamTemplatesProvider.LoadFile(Utils.SaveResource("france.ltt", tmpPath))); App.Current.CategoriesTemplatesProvider.Save( App.Current.CategoriesTemplatesProvider.LoadFile(Utils.SaveResource("basket.lct", tmpPath))); Assert.AreEqual(4, App.Current.TeamTemplatesProvider.Templates.Count); Assert.AreEqual(2, App.Current.CategoriesTemplatesProvider.Templates.Count); // Create a new project and open it LMProject p = CreateProject(); projectID = p.ID; LMProjectAnalysisVM viewModel; viewModel = new LMProjectAnalysisVM(); IVideoPlayerController playerController = new Mock <IVideoPlayerController> ().Object; viewModel.Project = new LMProjectVM { Model = p }; viewModel.VideoPlayer = new VideoPlayerVM { Player = playerController }; eventsController.SetViewModel(viewModel); // Do controllers start in here since the EventBroker is instantiante again in the test await eventsController.Start(); toolsManager.Start(); App.Current.DatabaseManager.ActiveDB.Store <LMProject> (p, true); // Tag some events Assert.AreEqual(0, p.Timeline.Count); AddEvent(p, 5, 3000, 3050, 3025); Assert.AreEqual(1, p.Timeline.Count); LMProject savedP = App.Current.DatabaseManager.ActiveDB.Retrieve <LMProject> (p.ID); Assert.AreEqual(1, savedP.Timeline.Count); AddEvent(p, 6, 3000, 3050, 3025); AddEvent(p, 7, 3000, 3050, 3025); AddEvent(p, 8, 3000, 3050, 3025); AddEvent(p, 5, 3000, 3050, 3025); Assert.AreEqual(5, p.Timeline.Count); savedP = App.Current.DatabaseManager.ActiveDB.Retrieve <LMProject> (p.ID); Assert.AreEqual(5, savedP.Timeline.Count); // Delete some events var events = new List <TimelineEvent> { p.Timeline [0], p.Timeline [1] }; await App.Current.EventsBroker.Publish <EventsDeletedEvent> ( new EventsDeletedEvent { TimelineEvents = events.Select(e => new TimelineEventVM() { Model = e }) } ); Assert.AreEqual(3, p.Timeline.Count); savedP = App.Current.DatabaseManager.ActiveDB.Retrieve <LMProject> (p.ID); Assert.AreEqual(3, savedP.Timeline.Count); // Now create a new LMProject with the same templates LMProject newProject = CreateProject(); viewModel.Project.Model = newProject; App.Current.DatabaseManager.ActiveDB.Store <LMProject> (newProject); Assert.AreEqual(2, App.Current.DatabaseManager.ActiveDB.Count <LMProject> ()); // Add some events and than remove it from the DB AddEvent(newProject, 6, 3000, 3050, 3025); AddEvent(newProject, 7, 3000, 3050, 3025); AddEvent(newProject, 8, 3000, 3050, 3025); AddEvent(newProject, 5, 3000, 3050, 3025); App.Current.DatabaseManager.ActiveDB.Delete <LMProject> (newProject); // Reopen the old project savedP = App.Current.DatabaseManager.ActiveDB.RetrieveAll <LMProject> ().FirstOrDefault(pr => pr.ID == projectID); viewModel.Project.Model = savedP; await App.Current.EventsBroker.Publish <SaveProjectEvent> ( new SaveProjectEvent { Project = savedP, ProjectType = ProjectType.FileProject } ); // Export this project to a new file savedP = App.Current.DatabaseManager.ActiveDB.Retrieve <LMProject> (projectID); Assert.AreEqual(3, savedP.Timeline.Count); Assert.AreEqual(12, savedP.LocalTeamTemplate.List.Count); Assert.AreEqual(12, savedP.VisitorTeamTemplate.List.Count); string tmpFile = Path.Combine(tmpPath, "longomatch.lgm"); mockDialogs.Setup(g => g.SaveFile(It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string []> ())).Returns(tmpFile); await App.Current.EventsBroker.Publish <ExportProjectEvent> (new ExportProjectEvent { Project = p }); Assert.IsTrue(File.Exists(tmpFile)); savedP = Project.Import(tmpFile) as LMProject; Assert.IsNotNull(savedP); // Import a new project LongoMatchImporter importPlugin = new LongoMatchImporter(); ProjectImporter importer = new ProjectImporter { Description = importPlugin.Description + " test ", ImportFunction = new Func <Project> (importPlugin.ImportProject), FilterName = importPlugin.FilterName, Extensions = importPlugin.FilterExtensions, NeedsEdition = importPlugin.NeedsEdition, CanOverwrite = importPlugin.CanOverwrite, }; CoreServices.toolsManager.ProjectImporters.Add(importer); string projectPath = Utils.SaveResource("spain_france_test.lgm", tmpPath); mockDialogs.Setup(g => g.ChooseOption( It.IsAny <Dictionary <string, object> > (), It.IsAny <string> (), It.IsAny <object> ())). Returns(Task.Factory.StartNew(() => (object)importer) ); mockDialogs.Setup(g => g.OpenFile(It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string> (), It.IsAny <string []> ())).Returns(projectPath); await App.Current.EventsBroker.Publish <ImportProjectEvent> (new ImportProjectEvent()); Assert.AreEqual(2, App.Current.DatabaseManager.ActiveDB.Count <LMProject> ()); LMProject importedProject = App.Current.DatabaseManager.ActiveDB.RetrieveAll <LMProject> (). SortByCreationDate(true).ToList() [0]; Assert.IsNotNull(importedProject); Assert.AreNotEqual(importedProject.ID, p.ID); int eventsCount = p.Timeline.Count; AddEvent(p, 2, 3000, 3050, 3025); AddEvent(p, 3, 3000, 3050, 3025); savedP = App.Current.DatabaseManager.ActiveDB.Retrieve <LMProject> (p.ID); Assert.AreEqual(eventsCount + 2, savedP.Timeline.Count); await eventsController.Stop(); toolsManager.Stop(); }
void AddExportEntry(MenuItem parent, string name, Func <Project, bool, Task> exportAction, LMProjectAnalysisVM viewModel) { MenuItem item = new MenuItem(name) { Visible = true }; item.Activated += (sender, e) => exportAction(viewModel.Project.Model, false); (parent.Submenu as Menu).Append(item); }