Esempio n. 1
0
		public override void FixtureSetup()
		{
			CheckDisposed();
			base.FixtureSetup();

			Unpacker.UnPackParatextTestProjects();
			m_regData = Unpacker.PrepareRegistryForPTData();

			// TeApp derives from FwApp
			m_testTeApp = new TestTeApp(new string[] {
														 "-c", m_sSvrName,			// ComputerName (aka the SQL server)
														 "-proj", m_ProjName,		// ProjectName
														 "-db", m_sDbName});			// DatabaseName

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();
		}
Esempio n. 2
0
		public void Init()
		{
			CheckDisposed();

			Unpacker.UnPackParatextTestProjects();
			m_regData = Unpacker.PrepareRegistryForPTData();

			// TeApp derives from FwApp
			m_testTeApp = new TestTeApp(new string[] {
				"-c", m_sSvrName,			// ComputerName (aka the SQL server)
				"-proj", m_ProjName,		// ProjectName
				"-db", m_sDbName});			// DatabaseName

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();

			if (m_fMainWindowOpened)
			{
				m_firstMainWnd = (TestTeMainWnd)m_testTeApp.MainWindows[0];
				// reload the styles from the database (test may have inserted new styles!)
				m_firstMainWnd.Synchronize(new SyncInfo(SyncMsg.ksyncStyle, 0, 0));
				// Set the view to the DraftView
				m_firstMainWnd.SelectScriptureDraftView();
				Application.DoEvents();

				// insert book tests create filters - turn them off to prevent interaction
				// between tests
				m_firstMainWnd.TurnOffAllFilters();

				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);

				// we don't want to open a transaction!
			}
		}
Esempio n. 3
0
		public void TestTearDown()
		{
			// Close the footnote view if it was showing
			if (m_firstMainWnd.TheDraftViewWrapper.FootnoteViewShowing)
				m_firstMainWnd.TheDraftViewWrapper.HideFootnoteView();

			m_testTeApp.ExitAppplication();
			//m_firstMainWnd.Cache = null; // Bad idea, since it has been disposed.
			m_testTeApp.Dispose();
			m_testTeApp = null;

			m_regData.RestoreRegistryData();
			// restore the value we saved in Init
			if (m_draftAreaStyleWidth != -1)
				m_teSubKey.SetValue("DraftStyleAreaWidth", m_draftAreaStyleWidth);

			m_firstMainWnd = null; // The app should have disposed this.
			m_firstDraftView = null; // The app should have disposed this.

			//			// Cleanup (and Release?) the ICU memory mapping.
			//			SIL.FieldWorks.Common.Utils.Icu.Cleanup();
			m_teSubKey = null;
			m_regData = null;
		}
Esempio n. 4
0
		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();
			}
		}
Esempio n. 5
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_testTeApp != null)
				{
					m_testTeApp.ExitAppplication();
					m_testTeApp.Dispose();
				}
				if (m_regData != null)
					m_regData.RestoreRegistryData();
				// restore the value we saved in Init
				if (m_draftAreaStyleWidth != -1)
					m_teSubKey.SetValue("DraftStyleAreaWidth", m_draftAreaStyleWidth);
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_firstMainWnd = null; // The app should have disposed this.
			m_firstDraftView = null; // The app should have disposed this.
			m_testTeApp = null;

			// This used to be done by the dispose of the FwFindReplaceDlg control, but doing it
			// that often is wrong, because other instances of the control (or other controls)
			// may have the default WSF open. However, later tests depend on ShutDown writing
			// stuff out.
#if !__MonoCS__
			ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
#else
			// TODO-Linux: above code hangs - FIXME
			// Currently doing without the Invoke - see FwKernel.cs LgWritingSystemFactoryClass.Create.
			ILgWritingSystemFactory wsf = new LgWritingSystemFactory();
#endif
			wsf.Shutdown();
			Marshal.ReleaseComObject(wsf);
			wsf = null;
			//			// Cleanup (and Release?) the ICU memory mapping.
			//			SIL.FieldWorks.Common.Utils.Icu.Cleanup();
			m_DefParaCharsStyle = null;
			m_teSubKey = null;
			m_regData = null;

			base.Dispose(disposing);
		}
Esempio n. 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Start up the test application
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void StartTestApp()
		{
			// 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-Linux: calling added close method on RegistryBoolSetting
			successfulStartup.Close();

			// TODO: Figure out what to pass into the app
			m_testTeApp = new TestTeApp(new string[0]);

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();
			Assert.AreEqual(1, m_testTeApp.MainWindows.Count);

			m_DefParaCharsStyle = ResourceHelper.DefaultParaCharsStyleName;

			// 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();
			}
			((TestTeMainWnd)m_testTeApp.MainWindows[0]).CreateDraftView();
		}
Esempio n. 7
0
		/// <summary>
		/// Correct way to deal with FixtureTearDown for class that derive from BaseTest.
		/// </summary>
		/// <param name="disposing"></param>
		protected override void Dispose(bool disposing)
		{
			if (IsDisposed)
				return;

			if (disposing)
			{
				if (m_testTeApp != null)
				{
					m_testTeApp.ExitAppplication();
					m_testTeApp.Dispose();
				}
			}
			m_testTeApp = null;

			base.Dispose(disposing);
		}
Esempio n. 8
0
		public override void FixtureSetup()
		{
			CheckDisposed();
			base.FixtureSetup();

			// TeApp derives from FwApp
			m_testTeApp = new TestTeApp(new string[] {
														 "-c", m_sSvrName,			// ComputerName (aka the SQL server)
														 "-proj", m_ProjName,		// ProjectName
														 "-db", m_sDbName});			// DatabaseName

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();
		}
Esempio n. 9
0
        /// <summary>
        /// Correct way to deal with FixtureTearDown for class that derive from BaseTest.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed)
                return;

            if (disposing)
            {
                if (m_testTeApp != null)
                {
                    m_testTeApp.ExitAppplication();
                    m_testTeApp.Dispose();
                }

                if (m_regData != null)
                    m_regData.RestoreRegistryData();

                Unpacker.RemoveParatextTestProjects();
            }
            m_testTeApp = null;

            base.Dispose(disposing);
        }
Esempio n. 10
0
        public void CleanUp()
        {
            CheckDisposed();

            bool wipedOutStuff = false;
            if (m_fMainWindowOpened)
            {
                try
                {
                    // Undo everything that we can undo - checking to make sure we are not
                    // in an infinite loop
                    int undoCount = 0;
                    while (m_firstMainWnd.Cache.CanUndo)
                    {
                        if (++undoCount <= 10)
                        {
                            m_firstMainWnd.SimulateEditUndoClick();
                            Application.DoEvents();
                        }
                        else
                        {
                            // Do a complete clean up and re-init so next test can run
                            // without impact from this test.
                            wipedOutStuff = true;
                            if (m_testTeApp != null)
                            {
                                m_testTeApp.ExitAppplication();
                                m_testTeApp.Dispose();
                                m_testTeApp = null;
                            }

                            if (m_regData != null)
                                m_regData.RestoreRegistryData();
                            Unpacker.RemoveParatextTestProjects();

                            return;
                        }
                    }
                    m_firstMainWnd.Cache.ActionHandlerAccessor.Commit();
                }
                catch(Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Got exception in UndoRedoTests.CleanUp: "
                        + e.Message);
                }
            }
            if (!wipedOutStuff)
            {
                if (m_testTeApp != null)
                {
                    m_testTeApp.ExitAppplication();
                    m_testTeApp.Dispose();
                    m_testTeApp = null;
                }

                if (m_regData != null)
                    m_regData.RestoreRegistryData();
                Unpacker.RemoveParatextTestProjects();
            }
        }
Esempio n. 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Start up the test application
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void StartTestApp()
		{
			// 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;

			m_testTeApp = new TestTeApp(new string[] {
														 "-c", m_sSvrName,		// ComputerName (aka the SQL server)
														 "-db", m_sDbName});	// DatabaseName

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();
			Assert.AreEqual(1, m_testTeApp.MainWindows.Count);

			m_DefParaCharsStyle = FdoResources.DefaultParaCharsStyleName;

			// 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();
			}
			((TestTeMainWnd)m_testTeApp.MainWindows[0]).CreateDraftView();
		}