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); }
public void Setup() { CultureUtil.SetDefaultCulture(CultureInfo.GetCultureInfo("en-US")); try { App = new PowerPoint.Application(); } catch (COMException) { // in case a warm-up is needed App = new PowerPoint.Application(); } Pres = App.Presentations.Open( PathUtil.GetDocTestPath() + GetTestingSlideName(), WithWindow: MsoTriState.msoFalse); PpOperations = new UnitTestPpOperations(Pres, App); PPLClipboard.Init(PpOperations.Window, true); int processId = Process.GetCurrentProcess().Id; WindowWatcher.HeadlessSetup(processId); }