public void TestSetup() { Debug.Assert(m_testTeApp == null, "Why does it have something in m_testTeApp here?"); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_teSubKey = Registry.CurrentUser.CreateSubKey(@"Software\SIL\FieldWorks\Translation Editor"); // save the width of the style pane, only if it already has a value // Tests will fail if the style pane is showing, so we turn it off. object keyValue = m_teSubKey.GetValue("DraftStyleAreaWidth"); if (keyValue != null) { m_draftAreaStyleWidth = (int)keyValue; m_teSubKey.SetValue("DraftStyleAreaWidth", 0); } // TeApp derives from FwApp // Make sure the registry thinks the last time an attempt was made to open TE // was successful. Otherwise, the welcome dialog shows up in the middle of tests. RegistryBoolSetting successfulStartup = new RegistryBoolSetting(FwSubKey.TE, "OpenSuccessful", true); successfulStartup.Value = true; // TODO: Figure out what we need to pass into the app m_testTeApp = new TestTeApp(new string[0]); m_fMainWindowOpened = m_testTeApp.OpenMainWindow(); Assert.AreEqual(1, m_testTeApp.MainWindows.Count); // Sidebar buttons get pressed as part of main window initialization; // wait for that initialization to finish before we proceed. while (DataUpdateMonitor.IsUpdateInProgress( ((TestTeMainWnd)m_testTeApp.MainWindows[0]).Cache.MainCacheAccessor)) { Application.DoEvents(); } if (m_fMainWindowOpened) { m_firstMainWnd = (TestTeMainWnd)m_testTeApp.MainWindows[0]; m_firstMainWnd.CreateDraftView(); // Set the view to the DraftView m_firstMainWnd.SwitchActiveView(m_firstMainWnd.TheDraftViewWrapper); Application.DoEvents(); m_firstDraftView = (TestTeDraftView)m_firstMainWnd.TheDraftView; m_firstDraftView.ActivateView(); SelectionHelper helper = m_firstDraftView.SetInsertionPoint(0, 0, 0, 0, true); // helper.IhvoEndPara = -1; helper.SetSelection(m_firstDraftView, true, true); Application.DoEvents(); } }
public void Init() { if (m_fMainWindowOpened) { if (m_testTeApp == null) StartTestApp(); m_firstMainWnd = (TestTeMainWnd)m_testTeApp.MainWindows[0]; if (m_firstMainWnd.ClientWindows.Count == 0) m_firstMainWnd.CreateDraftView(); // Set the view to the DraftView m_firstMainWnd.SwitchActiveView(m_firstMainWnd.TheDraftViewWrapper); Application.DoEvents(); m_firstDraftView = (TestTeDraftView)m_firstMainWnd.TheDraftView; m_firstDraftView.ActivateView(); SelectionHelper helper = m_firstDraftView.SetInsertionPoint(0, 0, 0, 0, true); // helper.IhvoEndPara = -1; helper.SetSelection(m_firstDraftView, true, true); Application.DoEvents(); } }