public static IMarshalWindow WaitAndPush <T>(this IWindowStackManager windowStackManager, Action action, string name, int timeout = 5000) where T : DispatcherObject { IntPtr handle = WindowWatcher.Push(name, action, timeout); IMarshalWindow window = windowStackManager.Push(handle); Assert.IsNotNull(window); Assert.IsTrue(window.IsType <T>()); Assert.IsTrue(name == null || name == window.Title); return(window); }
private void ConnectPpl() { const int waitTime = 3000; int retryCount = 5; while (retryCount > 0) { // if already connected, break if (PplFeatures != null && PpOperations != null && WindowStackManager != null) { break; } // otherwise keep trying to connect for some times try { IPowerPointLabsFT ftInstance = (IPowerPointLabsFT)Activator.GetObject(typeof(IPowerPointLabsFT), "ipc://PowerPointLabsFT/PowerPointLabsFT"); PplFeatures = ftInstance.GetFeatures(); PpOperations = ftInstance.GetOperations(); WindowStackManager = ftInstance.GetWindowStackManager(); WindowStackManager.Setup(); break; } catch (RemotingException) { retryCount--; ThreadUtil.WaitFor(waitTime); } } if (PplFeatures == null || PpOperations == null) { Assert.Fail("Failed to connect to PowerPointLabs add-in. You can try to increase retryCount."); } PpOperations.EnterFunctionalTest(); // activate the thread of presentation window // Sometimes it takes very long for message box to pop up MessageBoxUtil.ExpectMessageBoxWillPopUp( "PowerPointLabs FT", "{*}", PpOperations.ActivatePresentation, null, 5, 10000); IntPtr window = Gethwnd(); PPLClipboard.Init(window, true); }