[chronojump] Added guiTests class (WIP)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Added guiTests class (WIP)
- Date: Wed, 3 Aug 2016 13:06:32 +0000 (UTC)
commit 75bfd73d93d5465a00cbe6d380c8f93a72fc4f40
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Aug 3 15:01:26 2016 +0200
Added guiTests class (WIP)
glade/chronojump.glade | 82 +++++++++++++++++++--
src/Makefile.am | 1 +
src/gui/chronojump.cs | 9 ++-
src/gui/encoder.cs | 22 +++++--
src/gui/guiTests.cs | 188 ++++++++++++++++++++++++++++++++++++++++++++++++
src/logB.cs | 40 ++++++++++-
6 files changed, 328 insertions(+), 14 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 72b83f7..00f07ff 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -1042,6 +1042,19 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
+ <widget class="GtkButton" id="button_gui_tests">
+ <property name="label">GUI TESTS</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="on_button_gui_tests_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkButton" id="button_crash">
<property name="label">CRASH_ME
(debug purposes)</property>
@@ -1052,7 +1065,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -1077,7 +1090,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -1318,7 +1331,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
@@ -13024,6 +13037,9 @@ low ressistance</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -17950,6 +17966,9 @@ low ressistance</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -22723,6 +22742,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -23977,6 +23999,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -25723,6 +25748,9 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -26526,6 +26554,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -40002,6 +40033,24 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -42981,6 +43030,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -44152,9 +44213,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<placeholder/>
</child>
<child>
- <placeholder/>
- </child>
- <child>
<widget class="GtkLabel" id="label218">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -45408,6 +45466,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -49629,6 +49690,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -50547,6 +50611,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -51480,6 +51547,9 @@ It starts before and arrives there with some speed.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/Makefile.am b/src/Makefile.am
index bead878..5fb529a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,6 +17,7 @@ SOURCES = \
gui/eventGraphConfigure.cs\
gui/event.cs\
gui/executeAuto.cs\
+ gui/guiTests.cs\
gui/jump.cs\
gui/jumpsProfile.cs\
gui/jumpType.cs\
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 53f1ed8..0a5d888 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -40,6 +40,8 @@ public partial class ChronoJumpWindow
[Widget] Gtk.MenuBar main_menu;
[Widget] Gtk.MenuItem menuitem_mode;
+ [Widget] Gtk.Button button_gui_tests;
+
[Widget] Gtk.RadioMenuItem radio_menuitem_mode_jumps;
[Widget] Gtk.RadioMenuItem radio_menuitem_mode_runs;
[Widget] Gtk.RadioMenuItem radio_menuitem_mode_power_gravitatory;
@@ -6516,10 +6518,15 @@ LogB.Debug("X");
encoderRProcCapture.Debug = true;
encoderRProcAnalyze.Debug = true;
-
+
+ button_gui_tests.Visible = true;
+
preferencesWin.DebugActivated();
}
+ private void on_button_gui_tests_clicked (object o, EventArgs args) {
+ chronojumpWindowTests();
+ }
private void on_about1_activate (object o, EventArgs args) {
string translator_credits = Catalog.GetString ("translator-credits");
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 30c5a06..f972cac 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1144,12 +1144,21 @@ public partial class ChronoJumpWindow
return currentEncoderGI;
}
- void on_button_encoder_load_signal_clicked (object o, EventArgs args)
- {
- ArrayList data = SqliteEncoder.Select(
+ //separated to be called also from guiT
+ ArrayList encoderLoadSignalData() {
+ return SqliteEncoder.Select(
false, -1, currentPerson.UniqueID, currentSession.UniqueID, getEncoderGI(),
-1, "signal", EncoderSQL.Eccons.ALL,
false, true);
+ }
+ //this is called when user clicks on load signal
+ void on_button_encoder_load_signal_clicked (object o, EventArgs args) {
+ on_encoder_load_signal_clicked (Convert.ToInt32(encoderSignalUniqueID));
+ }
+ //this can be called also by guiT
+ void on_encoder_load_signal_clicked (int myEncoderSignalUniqueID)
+ {
+ ArrayList data = encoderLoadSignalData();
ArrayList dataPrint = new ArrayList();
int count = 1;
@@ -1200,7 +1209,7 @@ public partial class ChronoJumpWindow
genericWin.ShowEditRow(false);
//select row corresponding to current signal
- genericWin.SelectRowWithID(0, Convert.ToInt32(encoderSignalUniqueID)); //colNum, id
+ genericWin.SelectRowWithID(0, myEncoderSignalUniqueID); //colNum, id
genericWin.CommentColumn = 9;
@@ -1275,6 +1284,10 @@ public partial class ChronoJumpWindow
encoderButtonsSensitive(encoderSensEnumStored);
}
+ //guiT stuff
+ //end but wait two seconds to allow encoderCalculeCurves thread end
+ if(GuiTLoadSignalObject != null)
+ GuiTLoadSignalObject.End(2);
}
protected void on_encoder_load_signal_row_edit (object o, EventArgs args) {
@@ -5547,7 +5560,6 @@ public partial class ChronoJumpWindow
if(action == encoderActions.CURVES_AC && radio_encoder_capture_cont.Active && !
encoderProcessFinishContMode)
on_button_encoder_capture_clicked (new object (), new EventArgs ());
-
} else { //ANALYZE
if(encoderProcessCancel) {
encoder_pulsebar_analyze.Text = Catalog.GetString("Cancelled");
diff --git a/src/gui/guiTests.cs b/src/gui/guiTests.cs
new file mode 100644
index 0000000..118a536
--- /dev/null
+++ b/src/gui/guiTests.cs
@@ -0,0 +1,188 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2004-2016 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+using System.Collections; //ArrayList
+using System.Threading;
+
+public class GuiT
+{
+ protected enum StatusTypes { WAITING, RUNNING } //WAITING means waiting or done
+ protected StatusTypes status = StatusTypes.WAITING;
+ protected string message;
+
+ public GuiT() {
+ }
+
+ protected void logStart() {
+ LogB.TestStart(message);
+ }
+ protected void logEnd() {
+ LogB.TestEnd(message);
+ }
+
+ //called from chronojump gui
+ public void End(int seconds)
+ {
+ LogB.Information("End (sleep start)");
+ Thread.Sleep(seconds*1000);
+
+ LogB.Information("End (changing to waiting)");
+ status = StatusTypes.WAITING;
+ LogB.Information("End (changed to waiting)");
+ }
+
+ public void WaitEnd() {
+ LogB.Information("at waitEnd");
+ while(status == StatusTypes.RUNNING)
+ Thread.Sleep(50);
+
+ LogB.Information("ended waitEnd");
+
+ logEnd();
+ }
+}
+
+public class GuiTLoadSignal : GuiT
+{
+
+ public GuiTLoadSignal()
+ {
+ message = "guiTLoadSignal";
+ status = StatusTypes.RUNNING;
+ logStart();
+ }
+}
+
+public partial class ChronoJumpWindow
+{
+ public GuiTLoadSignal GuiTLoadSignalObject;
+
+ private void chronojumpWindowTests()
+ {
+ chronojumpWindowTestsMode(Constants.Menuitem_modes.POWERINERTIAL);
+
+ //using tutorial (or demo) session
+ chronojumpWindowTestsLoadSession(); //this also selects first person
+
+ chronojumpWindowTestsSelectPerson(1); //select 2nd person (Giles)
+
+ chronojumpWindowTestsEncoderLoadSignal();
+
+// chronojumpWindowTestsWaitS(4);
+
+// chronojumpWindowTestsEncoderEccConInvert();
+
+// chronojumpWindowTestsWaitS(1);
+
+// chronojumpWindowTestsEncoderRecalculate();
+
+// chronojumpWindowTestsWaitS(4);
+
+/*
+ chronojumpWindowTestsEncoderEccConInvert();
+ chronojumpWindowTestsEncoderRecalculate();
+*/
+
+ /*
+ chronojumpWindowTestsEncoderSave(EncoderAutoSaveCurve.ALL);
+ chronojumpWindowTestsEncoderSave(EncoderAutoSaveCurve.NONE);
+ chronojumpWindowTestsEncoderSave(EncoderAutoSaveCurve.BEST);
+ chronojumpWindowTestsEncoderSave(EncoderAutoSaveCurve.FROM4TOPENULTIMATE);
+ */
+ }
+
+ private void chronojumpWindowTestsWaitS(int seconds)
+ {
+ LogB.TestStart("chronojumpWindowTestsWaitS");
+
+ Thread.Sleep(1000 * seconds);
+
+ LogB.TestEnd("chronojumpWindowTestsWaitS");
+ }
+
+
+ private void chronojumpWindowTestsMode(Constants.Menuitem_modes m)
+ {
+ LogB.TestStart("chronojumpWindowTestsMode", m.ToString());
+
+ //disable autodetect
+ //configAutodetectPort = Config.AutodetectPortEnum.INACTIVE;
+
+ select_menuitem_mode_toggled(m);
+
+ LogB.TestEnd("chronojumpWindowTestsMode");
+ }
+
+ private void chronojumpWindowTestsLoadSession()
+ {
+ LogB.TestStart("chronojumpWindowTestsLoadSession");
+
+ currentSession = SqliteSession.Select ("1"); //select first session (if is not deleted)
+ on_load_session_accepted();
+
+ LogB.TestEnd("chronojumpWindowTestsLoadSession");
+ }
+
+ private void chronojumpWindowTestsSelectPerson(int numInPersonTV)
+ {
+ LogB.TestStart("chronojumpWindowTestsSelectPerson");
+
+ selectRowTreeView_persons(treeview_persons, treeview_persons_store, numInPersonTV);
+
+ LogB.TestEnd("chronojumpWindowTestsSelectPerson");
+ }
+
+ private void chronojumpWindowTestsEncoderLoadSignal()
+ {
+ GuiTLoadSignalObject = new GuiTLoadSignal();
+ //LogB.TestStart("chronojumpWindowTestsLoadSignal");
+
+ ArrayList data = encoderLoadSignalData(); //selects signals of this person, this session,
this encoderGI
+ EncoderSQL es = (EncoderSQL) data[0]; //gets first
+
+ on_encoder_load_signal_clicked (Convert.ToInt32(es.uniqueID)); //opens load window with first
selected
+
+ genericWin.Button_accept.Click(); //this will call accepted
+
+ GuiTLoadSignalObject.WaitEnd();
+ }
+
+ private void chronojumpWindowTestsEncoderEccConInvert()
+ {
+ LogB.TestStart("chronojumpWindowTestsEncoderEccConInvert");
+
+ if(combo_encoder_eccon.Active == 0)
+ combo_encoder_eccon.Active = 1;
+ else
+ combo_encoder_eccon.Active = 0;
+
+ LogB.TestEnd("chronojumpWindowTestsEncoderEccConInvert");
+ }
+
+ private void chronojumpWindowTestsEncoderRecalculate()
+ {
+ LogB.TestStart("chronojumpWindowTestsEncoderRecalculate");
+
+ on_button_encoder_recalculate_clicked (new Object (), new EventArgs ());
+
+ LogB.TestEnd("chronojumpWindowTestsEncoderRecalculate");
+ }
+}
diff --git a/src/logB.cs b/src/logB.cs
index bae6975..8a88c99 100644
--- a/src/logB.cs
+++ b/src/logB.cs
@@ -59,7 +59,8 @@ public enum LogEntryType
Error,
Information,
SQL, SQLon, SQLoff,
- ThreadStart, ThreadEnding, ThreadEnded
+ ThreadStart, ThreadEnding, ThreadEnded,
+ TestStart, TestEnd
}
public class LogEntry
@@ -167,6 +168,14 @@ public static class LogB
ConsoleCrayon.BackgroundColor = ConsoleColor.Red;
ConsoleCrayon.ForegroundColor = ConsoleColor.Black;
break;
+ case LogEntryType.TestStart:
+ ConsoleCrayon.BackgroundColor = ConsoleColor.Blue;
+ ConsoleCrayon.ForegroundColor = ConsoleColor.Black;
+ break;
+ case LogEntryType.TestEnd:
+ ConsoleCrayon.BackgroundColor = ConsoleColor.Blue;
+ ConsoleCrayon.ForegroundColor = ConsoleColor.Black;
+ break;
}
var thread_name = String.Empty;
@@ -222,6 +231,10 @@ public static class LogB
return " <.......................... Thread Ending";
case LogEntryType.ThreadEnded:
return " <-------------------------- Thread Ended";
+ case LogEntryType.TestStart:
+ return "Test Start t_t_t_t_t_t_t_t_t_t_->";
+ case LogEntryType.TestEnd:
+ return "Test End <-_t_t_t_t_t_t_t_t_t_t";
}
return null;
}
@@ -491,7 +504,7 @@ public static class LogB
#endregion
-#region Public SQL Methods
+#region Public Thread Methods
public static void ThreadStart()
{
@@ -508,6 +521,29 @@ public static class LogB
Commit(LogEntryType.ThreadEnded, null, null, false);
}
+#endregion
+
+#region Public Test Methods
+
+ public static void TestStart(string test)
+ {
+ Commit(LogEntryType.TestStart, test, null, false);
+ }
+
+ public static void TestStart(string test, string details)
+ {
+ Commit(LogEntryType.TestStart, test, details, false);
+ }
+
+ public static void TestEnd(string test)
+ {
+ Commit(LogEntryType.TestEnd, test, null, false);
+ }
+
+ public static void TestEnd(string test, string details)
+ {
+ Commit(LogEntryType.TestEnd, test, details, false);
+ }
#endregion
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]